Capabilities/tool/customlang:edit

Capabilities/tool/customlang:edit

Jump to: navigation, search

  • This allows a user to modify the words and phrases used in a LMS site via Settings > Site Administration > Language > Language customisation.
  • The default Manager role has this capability set to allow.

Capabilities/tool/customlang:view

Capabilities/tool/customlang:view

Jump to: navigation, search

  • This allows a user to see the modified words and phrases used in a LMS site via Settings > Site Administration > Language > Language customisation.
  • The default Manager role has this capability set to allow.

See also

Language packs

1 Language pack installation and uninstallation

1.1 Language packs and manual download

2 Parent language packs and child language packs

3 Manual language pack installation

4 Language pack updates

5 Language pack failure to update

6 LMS cannot connect to download.paradisolms.net

7 Inside a language pack

8 Can I personalize language strings per theme?

8.1 Changing the look of a course

8.2 Changing the behavior of a course

9 Can I install one particular language pack and supplement the missing translations using a second (related) language pack?

10 Can I make a language pack for kids?

11 Why has my language pack suddenly forgotten some translations?

12 Why do I have a language pack named xx_old’ that I never installed?

Language pack installation and uninstallation

Installing a language pack

Over 100 language packs are available for an administrator to install on your LMS site in ‘Language packs’ in the Site administration. Simply select the languages you require from the list of available language packs and click on the “Install selected language pack” button.

Multiple language packs may be selected for install by holding down the Apple or Ctrl key whilst clicking on the language packs.

Installing many (20+) language packs has almost 0 impacts on LMS performance.

Multiple language packs may be uninstalled, once selected, by clicking the ‘Uninstall selected language packs” button.

Language packs and manual download

Language packs are a work-in-progress since new language strings are added for new features in each new version of LMS. Lang packs can be manually downloaded. The page also lists the percentage of language strings translated in each language pack.

Parent language packs and child language packs

Certain language packs (a child language pack) contain only the modified language strings from their parent language, rather than a complete set. Thus, it is necessary to install the parent language pack too. These language packs are:

  • ca_valencià (which requires ca)
  • de_du, de_kids and de_comm (which require de)
  • en_us, en_ar, en_kids (which require the default en)
  • es_ve (which requires es)
  • es_ve, es_co (which requires es)
  • es_mx_kids (which require es_mx)
  • fil (which requires fi)
  • fr_ca (which requires fr)
  • he_kids (which requires he)
  • ja_kids (which requires ja)
  • lt_uni (which requires lt)
  • no_gr (which requires no)
  • sv_fi (which requires sv)
  • wo (which requires fr)

Note: If your site uses a child language pack (see the list above), if you use the Multi-language content filter, you need to be very careful about how to use it.

Manual language pack installation

In general, the easiest way to install additional language packs is from within LMS. However, it is also possible to install a language pack manually by downloading the zip file and unzipping it to a directory called lang in your lmsdata directory.

Language pack updates

  • Language packs can be updated via Administration > Site administration > Language > Language packs.
  • You can see which language packs have updates because they are listed in both ‘Installed language packs’ and ‘Available language packs’.
  • To update all installed language packs (except English and any local language packs) click the ‘Update all installed language packs’ button.
  • For sites with a large number of language packs installed, to update just a few installed language packs at a time, select the languages from the ‘Available language packs’ list and click the ‘Install selected language pack(s)’ button.
  • The English language pack is updated automatically each time the site is upgraded.
  • As most language packs are a work in progress, it is a good idea to update them regularly.

All installed language packs are updated as a scheduled task. By default, the task is run daily.

Language pack failure to update

  • Language packs cannot be updated if your LMS hosting company sets cURL to use IP6.
  • Basically, the symptom is this in the Available language packs area:
(Failed to connect to 2400:cb00:2048:1::6814:ef: Network is unreachable)
  • And this fix is add this to your lib/filelib.php file in the right place where curl is set (around line 1250 in M 3.1).
$options['CURLOPT_IPRESOLVE'] = CURL_IPRESOLVE_V4;

LMS cannot connect to download.paradisolms.net

This can happen if:

  • You configured over-zealous security restrictions in your server. Check that your server can contact the download.paradisolms.net server.
  • The download.paradisolms.net server is down and if you try to manually download the language pack, it fails too. Please try again later.
  • Your internet service is faulty 🙁

ERROR language import not available.png

Inside a language pack

A standard LMS comes with an English language pack only. It is installed in lmsdata/lang/en.

The English language terms (or ‘strings’) for the main (core) LMS features such as administration, roles etc, are stored in lang/en. Language files relating to modules, blocks, and other plugins are stored with the files of that particular plugin. So if you wanted to see the language strings for the badges block, for example, you would look in blocks/badges/lang/en. If you wanted to see the language files for the workshop module, you would look in mod/workshop/lang/en.

If you install another language pack, you will then get a folder such as lang/fr which would have French translations of LMS terms. Unlike with English, other language packs such as lang/fr will contain all translations along with the main core terms so you would find see for example the badges strings in lang/fr/block_badges.php and the workshop strings in lang/fr/workshop.php.

These files (which all end in .php) contain short phrases, often called “strings”. Strings may contain a placeholder (between the curly brackets below). This placeholder is replaced with the chosen words from the language pack when the string is displayed. The term between the square brackets is called the ‘string identifier’ or the ‘string name’. Examples:

$string['addnewcourse'] = 'Add a new course';
$string['hidesection'] = 'Hide section {$a}';

If a string hasn’t been translated, then LMS will use the parent language or the original English version. Thus, you might see an LMS site where some terms have been translated into a language but others still display in English.

Can I personalize language strings per theme?

Not directly, but you can use new local (child) language packs to achieve different courses behaviors/looks

Changing the look of a course

You can have a course with a different theme ‘and’ a different child language pack. You will then have personalized language strings in the only course that uses that particular theme.

Changing the behaviour of a course

  • If you do not want a user to see any reference to grades when he/she finishes a lesson, by editing the correct text string, it is possible to replace “Your score is 9 (out of 10)” with “Be sure to get your certificate”. Or change “Congratulations – end of lesson reached” to “We hoped this lesson helped you”. See how to change the end of lesson page display.
  • You can have several different courses, each using a different (child) language pack and each one showing personalized language strings.

Can I install one particular language pack and supplement the missing translations using a second (related) language pack?

Can I make a language pack for kids?

  • Yes.
  • The current existing language packs for kids are:
    • de_kids (which require de)
    • en_kids (which require the default en)
    • he_kids (which requires he)
    • ja_kids (which requires ja)
  • If you want to make a language pack for kids in a language different from the ones listed above, use the following method:
    • Install the (en_kids) English for kids language pack in your local LMS server
    • You will have to edit 10 files (which are stored in the lmsdata/lang/en_kids folder).
    • You can use Notepad++ or any other text editor, but avoid using MS Word or MS Notepad.
  • Start with langconfig.php and choose your main language as the parent language
  • When you have finished translating all the strings, you can request a new language pack to the person administering all LMS language packs.
  • Upload into AMOS the 10 files in your lmsdata/lang/en_kids folder
  • Remember to keep updating and expanding your new language pack

Why has my language pack suddenly forgotten some translations?

See the following image showing (Insignias) a properly translated Spanish language string (green rectangle) and an untranslated English language string (red rectangle) for ‘Badges’ plus a mixture of translated and untranslated strings with a language pack that should have 100% of the core strings translated.

Language packs mixed-up llanguages shown.png

If you try to update your language packs you will get a message indicating ‘Update of ‘xxxx_old’ language pack skipped.

Something old language pack can not be updated.png

Read the following section for the cause and the fix.

Why do I have a language pack named xx_old’ that I never installed?

Sometimes you may find (see image below) that your server has, in addition to your usual language packs (eg, en, es_mx), an odd-named language pack with an _old name ending (eg, es_mx_old), that -obviously- cannot be updated.

  • This came from an incomplete automated language pack update because the lang pack update fails in the middle of the process.
    • The update first renames the existing lang directory so that it has the _old suffix and then it tries to unzip the new one.
    • If unzipping is successful, the old directory is removed.
    • Check that the ZIP PHP extension is OK in the Environment.
    • If your server has languages other than English, the language packs update process will need to download all the corresponding language packs, which will take some time. If you have a low-speed internet provider, you could get a script timeout error. To prevent this, you will need to edit the server/php/php.ini file and change the line that has ‘max_execution_time = 30’ into ‘max_execution_time = 600’.
  • There may also be a language pack that has mixed languages, like ‘English (es_mx)’, that obviously cannot be.

Odd-named installed language pack.png

  • You must uninstall all strange-looking language packs and re-install your usual language packs.

Language packs uninstall all mixed-up languages.png

 

Language customization

Changing words or phrases

Words or phrases (in any language) used on the site may be easily changed by an administrator using the language customization feature. For example, you may want to change the word “Course” to “Unit”.

  1. Go to Settings > Site administration > Language > Language customization and choose the language you wish to customize.
  2. Click the “Open language pack for editing” button. (This may take some time to process.)
  3. Once the language pack has loaded, click the “Continue” button.
  4. Find the string you wish to customize using the filter settings, then clicking “Show strings”. See below for details of how to find the component and string identifier.
  5. Make your changes in the “Local customization” box.
  6. Click “Apply changes and continue editing” if you want to use another filter or edit another file e(s), otherwise click “Save changes to the language pack” to save all of the changes you have made.

Finding the component and string identifier

  • We will use an example where the user wants to replace ‘Courses’ with ‘Assessments’ in the Dashboard.
 
  • Go to Settings > Development > Debugging.
  • Tick the ‘Show origin of languages strings’ tickbox then save changes.
  • Go to the page containing the string you want to customize and in the address bar, append the following to the URL: either
    ?strings=1

     

    &strings=1

    (depending on whether there is already a parameter).

  • Reload the page.

  • The page will then be displayed with component and string identifies in curly brackets after each string, for example, “{nocourses/block_myoverview}”. The first part, before the /, is the string identifier. The last part is the component e.g block_myoverview.php. If there is nothing after the / (e.g. “{courses/}” ) then the string is in lms.php.
  • You will then use this information to customize your language strings.

Using the obtained information in order to change the intended strings

  • You must go to Site administration > Language > Language customization.
  • Choose the English (en) language pack.
  • Open language pack for editing.
  • Click on tne ‘Continue’ button.
  • Select the lms.php component (in this particular case)
  • Type courses as the string identifier (in this case)
  • Click on the ‘Show strings’ button
  • Type your locally customized string, replacing ‘Courses’ with ‘Assessments’.

  • After saving the changes into the language pack, you can check that you achieved the intended change:

We have replaced 'Courses' with 'Assessments'

  • Remember to always check that you have only changed the intended strings in the intended places.
  • Repeat the procedure with all the strings that you want changed (e.g. course, no courses,…)
  • Clear language string caches by going to Settings > Development > Purge all caches.

Filter settings

Language filter

  • Show strings of these components – Click or Ctrl+click to select one or more files.
  • Customized only – tick the box to display only those strings that are already present in your xx_local pack.
  • Help only’ – tick the box to display only help strings, that is the texts used when clicking the yellow question mark icon.
  • Modified only – tick the box to display only the strings that are modified since the last checked in the string into the language pack.
  • Only strings containing – insert a phrase that must appear in the string. For example, if you put a word ‘student’ here, you will get only those strings that contain this word.
  • String identifier – see above.

Local customization highlighting

  • Customized strings (already saved in a file) are highlighted in green.
  • Modified strings (not saved in a file yet) are highlighted in blue.
  • Customized strings for deletion are highlighted in red.

More about language packs

LMS is translated into many languages. The translations are distributed as language packages (or just lang packs) that are maintained by kind volunteers, community contributors, and LMS Partners.

LMS site administrators can customize any language pack to fit their individual needs. Editing the language pack files directly is not recommended, since any changes would be silently overwritten during the next upgrade. Instead, you should use the language customisation feature, which automatically creates a local language pack that holds all your changes from the official pack.

Local language packs have the same structure as official ones. They are saved in your LMS data directory in lmsdata/lang/xx_local/ folder where ‘xx’ is the code of the language. You have to have the official language pack installed before you can customise it. A local language pack should contain just strings you have customised – there is no need to create a copy of a whole official language pack.

When displaying a string, LMS first looks at whether a local customisation exists in lmsdata/lang/xx_local/component_file.php. If so, it is used. If not, the string from the official language pack is used. (If the string has not been translated yet, the original English version is displayed). Please note that the strings are cached for better performance so if you modify a file directly in your xx_local pack then you will have to purge LMS caches afterwards. Caches are purged automatically when using the language customisation feature.

Workflow of the language customisation (click to enlarge)

 

How to backup and restore a customised language pack

This is handy when you have made customisations of your language pack and you want to install these changes on another server.

If you customised a language pack xx, the only folder you need to back up is $CFG->dataroot/lang/xx_local. All others without the _local suffix are standard packages that can be installed and uninstalled via the admin tool.

Once the folder is restored on another server, you will have to manually purge caches from the admin interface to allow the in-built string manager to re-read the *_local folders and start using them.

Sharing a language customisation

  • If you have made a language customisation for a specific need, which is shared by other people (e.g. a kids version of your national language, intended for your school, but also useful for other schools), please consider sharing it as a child language in AMOS.
  • If your country uses a language that is not exactly the same as an existing language pack listed in the translation credits, and you have made a customisation that better suits the needs of your fellow country LMS users, you might want to consider starting a child language pack in AMOS (e.g. Canadian French, which has over 1000 changes from the French parent language).

In either case, contact the parent language pack maintainer listed in the translation credits and/or our translation coordinator, Koen, translation@paradisolms.net.

Troubleshooting

Database error

Database error while language customization.png
If you encounter a database error when you try to customise a language pack, then it may be due to a recent plugin that corrupted the database. You are advised to check all plugins recently added to your site, and check whether removing a plugin prevents this error. If that is the case, please contact the maintainer for the involved plugin and report the error. Most cases seen in 2013 were fixed by the maintainers of those plugins. One case seen in 2014 was related to the Essential (additional) theme and language packs other than English; it was caused by a a bug with the notification language handling, and was fixed with a plugin update.

Or, you can execute a database query on your server in order to track down the plugin causing the problem.

Changing the font size and colour of a language string

You can use language customization to change the font size and colour for any (core or additional plugin) LMS string.

See the following example taken from a Spanish forum user who wanted to have a distinct large red coloured text for the ‘Answer the questions…’ prompt in the feedback activity:

Language customization changing font size and colour.png

LMS Mobile language strings customisation

See Custom language strings in the LMS Mobile guide for admins.