« Personnalisation de langue » : différence entre les versions

De MoodleDocs
Aller à :navigation, rechercher
(Page créée avec « {{Langue}} ==Changer les mots ou les phrases== Les mots ou expressions (de n’importe quelle langue) utilisés sur le site peuvent être facilement modifiés par un admi... »)
 
Ligne 13 : Ligne 13 :
==Recherche du composant et de l'identificateur de chaîne==
==Recherche du composant et de l'identificateur de chaîne==
* Nous allons utiliser un exemple où l'utilisateur souhaite remplacer 'Cours' par 'Évaluations' dans le tableau de bord de Moodle 3.3 avec le thème Boost. [[File:Lang string origins in Boost theme 01.png|400px|Ceci est le texte à changer]]
* Nous allons utiliser un exemple où l'utilisateur souhaite remplacer 'Cours' par 'Évaluations' dans le tableau de bord de Moodle 3.3 avec le thème Boost. [[File:Lang string origins in Boost theme 01.png|400px|Ceci est le texte à changer]]
* Go to ''Administration du site > Développement > Débogage''.
* Aller à ''Administration du site > Développement > Débogage''.
* Cochez la case 'Afficher l'origine des chaînes de langues' puis enregistrez les modifications.
* Cochez la case 'Afficher l'origine des chaînes de langues' puis enregistrez les modifications.
* Accédez à la page contenant la chaîne que vous souhaitez personnaliser et dans la barre d'adresse, ajoutez ce qui suit à l'URL: soit <pre>?strings=1</pre> ou <pre>&amp;strings=1</pre> (selon qu’il existe déjà un paramètre).
* Accédez à la page contenant la chaîne que vous souhaitez personnaliser et dans la barre d'adresse, ajoutez ce qui suit à l'URL: soit <pre>?strings=1</pre> ou <pre>&amp;strings=1</pre> (selon qu’il existe déjà un paramètre).
Ligne 23 : Ligne 23 :
* Vous utiliserez ensuite ces informations pour personnaliser vos chaînes de langue.
* Vous utiliserez ensuite ces informations pour personnaliser vos chaînes de langue.


===Using the obtained information in order to change the intended strings===
===Utiliser les informations obtenues pour changer les chaînes souhaitées===


# Go to ''Site administration > Language > Language customization''.
# Aller à ''Administration du site > Langue > Personnalisation de la langue''.
# Choose the English (en) language pack.
# Choisir le paquet de langue Français (fr).
# Open language pack for editing.
# Ouvrir le pack de langue pour modification.
# Click on the 'Continue' button.
# Cliquer sur le bouton 'Continuer'.
# Select the moodle.php component (in this particular case)
# Sélectionnez le composant moodle.php (dans ce cas particulier)
# Type courses as the string identifier (in this case)
# Tapez 'courses' comme identifiant de chaîne (dans ce cas)
# Click on the 'Show strings' button
# Cliquez sur le bouton 'Afficher les chaînes'
# Type your locally customized string, replacing 'Courses' with 'Assessments'.
# Tapez votre chaîne personnalisée, en remplaçant le texte standard 'Cours' par 'Évaluations'.


[[File:Lang string origins in Boost theme 03.png|400px|We will replace 'Courses' with 'Assessments']]
[[File:Lang string origins in Boost theme 03.png|400px|Nous allons remplacer 'cours' par 'évaluations']]


* After saving the changes into the language pack, you can check that you achieved the intended change:
* Après avoir enregistré les modifications dans le pack de langue, vous pouvez vérifier que vous avez atteint la modification souhaitée:
[[File:Lang string origins in Boost theme 04.png|400px|We have replaced 'Courses' with 'Assessments']]
[[File:Lang string origins in Boost theme 04.png|400px|Nous avons remplacé 'Cours' par 'Évaluations']]


* Remember to always check that you have only changed the intended strings in the intended places.
* N'oubliez pas de toujours vérifier que vous n'avez modifié que les chaînes prévues aux endroits prévus.
* Repeat the procedure with all the strings that you want changed (e.g. course, no courses,...)
* Répétez la procédure avec toutes les chaînes que vous souhaitez modifier (ex., cours, pas de cours, ...)
* Clear language string caches by going to ''Site administration > Development > Purge all caches''.
* réinitialisez les chaînes de caractères en langage clair en allant à ''Administration du site > Développement > Purger tous les caches''.


==Filter settings==
==Filter settings==

Version du 13 mai 2019 à 12:40

Changer les mots ou les phrases

Les mots ou expressions (de n’importe quelle langue) utilisés sur le site peuvent être facilement modifiés par un administrateur à l’aide de la fonction de personnalisation de la langue. Par exemple, vous souhaiterez peut-être remplacer le mot "Course" par "Unité".

  1. Aller à Administration du site > Langue > Personnalisation de la langue et choisissez la langue que vous souhaitez personnaliser.
  2. Cliquer sur le bouton "Ouvrir le paquetage de langue pour modification". (Cela peut prendre du temps à traiter.)
  3. Une fois le pack de langue chargé, cliquez sur le bouton "Continuer".
  4. Recherchez la chaîne que vous souhaitez personnaliser à l'aide des paramètres de filtre, puis cliquez sur "Afficher les chaînes". Voir ci-dessous pour savoir comment trouver l'identificateur de composant et de chaîne.
  5. Apportez vos modifications dans la zone "Modification locale'.
  6. Cliquez sur "Enregistrer et continuer les modifications" si vous souhaitez utiliser un autre filtre ou modifier un ou plusieurs fichiers, sinon cliquez sur "Enregistrer les modifications dans le paquetage de langue" pour enregistrer toutes les modifications que vous avez apportées.

Recherche du composant et de l'identificateur de chaîne

  • Nous allons utiliser un exemple où l'utilisateur souhaite remplacer 'Cours' par 'Évaluations' dans le tableau de bord de Moodle 3.3 avec le thème Boost. Ceci est le texte à changer
  • Aller à Administration du site > Développement > Débogage.
  • Cochez la case 'Afficher l'origine des chaînes de langues' puis enregistrez les modifications.
  • Accédez à la page contenant la chaîne que vous souhaitez personnaliser et dans la barre d'adresse, ajoutez ce qui suit à l'URL: soit
    ?strings=1
    ou
    &strings=1
    (selon qu’il existe déjà un paramètre).
  • Recharger la page.

Ce sont les chaînes que nous devons changer

  • La page sera ensuite affichée avec composant et chaîne identifie entre accolades après chaque chaîne, par exemple "{nocourses/block_myoverview}". La première partie, avant le /, est l'identifiant de la chaîne. La dernière partie est la composante, par exemple block_myoverview.php. S'il n'y a rien après le / (par exemple, "{cours /}"), la chaîne est dans moodle.php.
  • Vous utiliserez ensuite ces informations pour personnaliser vos chaînes de langue.

Utiliser les informations obtenues pour changer les chaînes souhaitées

  1. Aller à Administration du site > Langue > Personnalisation de la langue.
  2. Choisir le paquet de langue Français (fr).
  3. Ouvrir le pack de langue pour modification.
  4. Cliquer sur le bouton 'Continuer'.
  5. Sélectionnez le composant moodle.php (dans ce cas particulier)
  6. Tapez 'courses' comme identifiant de chaîne (dans ce cas)
  7. Cliquez sur le bouton 'Afficher les chaînes'
  8. Tapez votre chaîne personnalisée, en remplaçant le texte standard 'Cours' par 'Évaluations'.

Nous allons remplacer 'cours' par 'évaluations'

  • Après avoir enregistré les modifications dans le pack de langue, vous pouvez vérifier que vous avez atteint la modification souhaitée:

Nous avons remplacé 'Cours' par 'Évaluations'

  • N'oubliez pas de toujours vérifier que vous n'avez modifié que les chaînes prévues aux endroits prévus.
  • Répétez la procédure avec toutes les chaînes que vous souhaitez modifier (ex., cours, pas de cours, ...)
  • réinitialisez les chaînes de caractères en langage clair en allant à Administration du site > Développement > Purger tous les caches.

Filter settings

Language filter
  • Show strings of these components - Click or Ctrl+click to select one or more files.
  • Customised 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 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 customisation highlighting

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

More about language packs

Moodle is translated into many languages - see Modèle:Version/ Language packs for Moodle Modèle:Version for their list and the translation completion status. The translations are distributed as language packages (or just lang packs) that are maintained by kind volunteers, community contributors and Moodle Partners.

Moodle site administrators can customise 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 Moodle data directory in moodledata/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, Moodle first looks whether a local customisation exists in moodledata/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 Moodle 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 Moodle 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@moodle.org.

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) Moodle 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

You could also add an image to a customized language string, as in this forum post.

Moodle Mobile language strings customisation

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

See also

Any questions?

Please post in the Languages forum on moodle.org.