Add multilanguage support to GLPI SOC Plugin

This commit is contained in:
tips-of-mine
2025-05-31 10:57:31 +02:00
committed by GitHub
parent 5f97834036
commit c428a4271b
11 changed files with 745 additions and 4 deletions

View File

@ -70,6 +70,9 @@ function plugin_init_soc() {
$PLUGIN_HOOKS['javascript']['soc'] = ['/plugins/soc/js/soc.js'];
$PLUGIN_HOOKS['add_css']['soc'] = ['/plugins/soc/css/soc.css'];
// Initialize translations
$PLUGIN_HOOKS['init_translations']['soc'] = 'initTranslations';
if (Session::haveRight('plugin_soc_case', READ)) {
$PLUGIN_HOOKS['menu_toadd']['soc'] = ['management' => 'PluginSocCase'];
}
@ -87,4 +90,21 @@ function plugin_init_soc() {
'addtabtypes' => ['Ticket']
]);
}
}
/**
* Initialize plugin translations
*
* @return void
*/
function initTranslations() {
global $CFG_GLPI;
$domain = 'soc';
$locale_dir = GLPI_ROOT . '/plugins/soc/locales/';
if (file_exists($locale_dir)) {
// Load plugin translations
$GLOBALS['LANG']->addTranslationFile('gettext', $locale_dir, $domain, $_SESSION['glpilanguage']);
}
}