Dropdowns Translation » History » Version 24

« Previous - Version 24/33 (diff) - Next » - Current version
walid, 07/17/2011 11:34 AM


Translate dropdowns

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

A new glpi_dropdown_translations table:

CREATE TABLE IF NOT EXISTS `glpi_dropdown_translations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `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,
  `language` 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,
  PRIMARY KEY (`id`),
  UNIQUE KEY `typeid` (`items_id`,`itemtype`),
  UNIQUE KEY `language` (`language`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 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.

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',
    

Right to add

Add a new right : translate_dropdown in glpi_profiles with values NULL / 'r' / 'w'.

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.