Translation Dashboard

Translation Dashboard

Translation Languages
Generate POT files from Source Code Strings
Save Strings from POT files in Database Translale Strings
Generate PO Files from Database


Test Links

ENHI



About Translate Plugin

  • Simple and Easy to Use: This plugin is designed for simplicity and ease of use.
  • Multi-Language Support: Perfect for creating multi-language websites.
  • Automated POT File Generation: Automatically generates POT files from your source code and displays all strings for translation into your desired languages.
  • Manual or Automatic Translation: Supports manual string translation or automatic translation using the Google Translation library.
  • Language Switcher: Provides a user-friendly language switcher for changing the website language.
  • URL Language Persistence: Ensures the selected language persists across all URLs (requires using CakePHP syntax to generate links).
  • Locale Setting: Utilizes CakePHP's setLocale method to set the correct language in your app.
  • Common Language Functions: Offers utility functions to easily retrieve the current language or a list of all available languages.
  • Plugin Translation: Enables translation of strings from other plugins and supports language prefixes for plugin pages.
  • Automatic Cache Clearing: Automatically clears translation cache when new PO files are generated.

How to Use the Translate Plugin

  1. Wrap Strings for Translation:
    Ensure your source code strings are wrapped in CakePHP's __() function.
  2. Add Required Languages:
    • Navigate to the plugin dashboard.
    • Click on the "Translation Languages" button.
    • Add valid language codes and locales.
  3. Generate POT Files:
    Use the "Generate POT files from Source Code Strings" button to generate POT files.
  4. Save POT Files Strings:
    Use the "Save Strings from POT files in Database" button to save POT files strings into database.
  5. Translate Strings:
    • Go to the "Translation Strings" page using the "Translation Strings" button.
    • Select a language in the filter and hit the "Search" button.
    • Translate one or multiple strings by selecting checkboxes and clicking the "Translate Selected Strings" button at the bottom of the page.
  6. Inline Translation:
    Translate individual strings using the inline feature. Click the three dots next to a string or the translated language to open the edit box.
  7. Generate PO Files:
    Once translations are complete, generate PO files using the "Generate PO Files from Database" button on the plugin dashboard.
  8. Add Language Switcher:
    Insert the language switcher element in your code wherever required:
    echo $this->element('Translate.language_switcher');

Changes Required in Your App

  1. Install the Plugin:
    Ensure the Translate plugin is installed following the instructions in the README file.
  2. Update Routes Configuration:
    Add the following code to yourapp/config/routes.php before the $builder->fallbacks(); line:
    
    $langs = getRouterLangs();
    
    $builder->connect('/{lang}/{plugin}/{controller}/{action}/*', [], ['lang' => $langs, 'persist' => ['lang', 'plugin']]);
    $builder->connect('/{lang}/{plugin}/{controller}', [], ['lang' => $langs, 'persist' => ['lang', 'plugin']]);
    $builder->connect('/{lang}/{controller}/{action}/*', [], ['lang' => $langs, 'persist' => ['lang']]);
    $builder->connect('/{lang}/{controller}', [], ['lang' => $langs, 'persist' => ['lang']]);
    
    $builder->connect('/{plugin}/{controller}/{action}/*', [], ['persist' => ['plugin']]);
    $builder->connect('/{plugin}/{controller}', [], ['persist' => ['plugin']]);
    				
  3. Modify Existing Routes:
    If you have existing routes in routes.php or plugin routes.php, update them as shown below:
    
    $langs = getRouterLangs();
    
    $builder->connect('/{lang}/dashboard', ['controller' => 'Users', 'action' => 'dashboard'], ['lang' => $langs, 'persist' => ['lang']]);
    $builder->connect('/dashboard', ['controller' => 'Users', 'action' => 'dashboard']);
    
    $builder->connect('/{lang}/stats/*', ['controller' => 'Visits', 'action' => 'index'], ['lang' => $langs, 'persist' => ['lang']]);
    $builder->connect('/stats/*', ['controller' => 'Visits', 'action' => 'index']);