Topics

Extensions - Manage Translations

This command allows you to select or create a language translation.

In addition to switching translations, it displays the number of phrases in the selected translation.

To create a new translation:

  1. Select and switch to the translation you'd like to make a copy of
    • In most cases you'd make a copy of the 'English - US' default language
    • If you are updating a dialect of a translation, you'd select it first.
  2. Enter the name of the translation, preferably in the translation itself...e.g., Deutsch instead of German
  3. Enter the author's name, if desired
  4. Change the translation character set, if it's something other than UTF-8
  5. Enter the translation locale.  You can find it by visiting the associated link.  In most cases this is a two lower case letter identifier, but some have a dash and a two letter sub-identifier.
  6. Click the create button to create and select the new translation.
    • The new translation is only a copy of the previously selected language.
  7. Edit your new translation found in the '/framework/core/lang' folder as 'languagename.php'
    • The translation dictionary follows this format:
      • "English Key Phrase"=>"Translated Phrase",
    • Find the 'key' phrase in the first part of the line, and translate the second phrase.
      • ONLY change the second phrase, since the key phase is how it's found!
      • NEVER place a double quote in the phrase as this will crash the site!
      • You should 'escape' a quote by using a backslash before it such as '

To help automate the translation creation process, there is a script which runs two additional helper scripts in the './cron' folder

  1. 'lang_update.php' scans files and folders for phrases and adds them to the default 'English - US.php' language file if they do not already exist.  Then it attempts to auto-translate each of the existing translations.  It can be run from the unix command line from within the /cron folder.
  2. 'lang_extract.php' is the script called by lang_update.php to extract phrases and place them in the default language file.
    • Command line parameters include:
      • '-r' to PREVENT recursive searching.  This is useful to scan the file in the root folder since we do NOT want to scan the /external folder for time sake.
      • You may enter any number of file or folder names to scan, folder are scanned recursively unless the -r flag is used.
      • examples:
        • php cron/lang_extract.php -r .
        • php cron/lang_extract.php conf cron framework install themes
  3. 'lang_translate.php' is the script called by lang_update.php which attempts to (machine) translate the untranslated phrases in the current translation by running them through the Bing language API.
    • Current list of Bing language translations: ar, bg, ca, zh-CHS, zh-CHT, cs, da, nl, et ,fi ,fr ,de ,el ,ht ,he, hi, hu, id ,it ,ja ,ko ,lv ,lt ,no ,pl ,pt ,ro ,ru ,sk ,sl ,es ,sv ,th ,tr ,uk,vi
    • Obtain a Bing Search API key for your application by starting at this link
    • Add the API key to your '/conf/config.php' file
      • define('BING_API', '12345678901234567890');
    • Select the translation you want to update
    • Run the script
      • php cron/lang_update.php
      • You must be patient as each phrase is translated separately.
      • When the operation is completed, you'll be given a report of:
        • Number of new phrases added to the translation from the default language
        • Number of phrases removed from the translation because they do not exisit in the default language
        • Number of phrases needing translation (those where the translation is still the English version)
        • Number of phrases translated, meaning those where the translation call succeeded.  In some cases, the translated phrase is the same as the English phrase.
      • Your translation should now be updated with the current list of phrases and any translation that Bing could offer.
Loading Help