Dropdowns Translation » History » Version 22

Version 21 (walid, 07/17/2011 11:03 AM) → Version 22/33 (walid, 07/17/2011 11:03 AM)

h1. Translate dropdowns

Since GLPI 0.78, dropdown items are now objects.
In order to translate theses fields, here are the proposed modifications.

h2. A new glpi_dropdown_translations glpi_dropdowns_translations table:

CREATE TABLE `glpi_dropdown_translations` `glpi_dropdowns_translations` (
`items_id` int(11) NOT NULL DEFAULT '0',
`itemtype` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`field` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`lang` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`completename` text COLLATE utf8_unicode_ci,
`comment` text COLLATE utf8_unicode_ci,

Here is an example to translate in french the 'name' field of computer types from 'laptop' to 'portable':

INSERT INTO `glpi_dropdowns_lang`
(`id`, `items_id`, `itemtype`, `field`, `lang`, `traduction`) VALUES
(1, 10, 'ComputerType', 'name', 'fr_FR', 'Portable');

Moyo : how do you manage hierarchical dropdowns to rebuild the tree ?
David : each tree dropdown item is an object, so it'll get a new 'Translation' tab. I'll need to modify dropdown functions to get translations (if there's one when the translation feature is activated in the general configuration. If a field is not translated, then we'll get the default value (ie the one defined in the main dropdown table).

Moyo : my question was about the completename management, which is processed for tree dropdowns. In this case, do you recommand regenerating it when needed ?
soin ?

David : yes you're right. The most logical would be to regenerate it when a new langage translation is added or modified. Let's adde a 'completename' field in the 'glpi_dropdown_lang' table which corresponds to his language.

h2. Add a new configuration option

* In Menu > Configuration > General > General config, add a new option to activate/deactive this feature (by default set to no)

* Add a new field in "glpi_configs"
`translate_dropdowns` tinyint(1) NOT NULL DEFAULT '0',

Donc :
Les champs des tables intitulés auraient une valeur définie par l'utilisateur (par exemple tous les champs en anglais) et on gère la traduction pour chacun de ces champs en base MySQL. c'est la référence absolue (pour les règles / dictionnaires par exemple) ou si la traduction n'existe pas en russe, il affiche cette valeur.

Un onglet "traduction" permettra de traduire ces champs dans la/les langues que l'on souhaite.

Lors de l'affichage de ces champs, on irait chercher les champs dans la langue de l'utilisateur si l'option est activés dans la configuration.