1) { return $plural; } return $singular; } /** * Get the available languages for the plugin * * @return array */ function plugin_cve_getLanguages() { return [ 'en_GB' => 'English', 'fr_FR' => 'Français', 'de_DE' => 'Deutsch', 'it_IT' => 'Italiano', 'pl_PL' => 'Polski', 'es_ES' => 'Español', 'pt_PT' => 'Português' ]; } /** * Initialize plugin localization * * @param string $hook_param Hook parameter * @return void */ function plugin_cve_load_language($hook_param) { global $CFG_GLPI; // Get user language $user_language = Session::getLanguage(); // Path to plugin locales $langpath = PLUGIN_CVE_DIR . '/locales/'; // Available languages for the plugin $languages = plugin_cve_getLanguages(); // If user language is not available, fallback to English if (!array_key_exists($user_language, $languages)) { $user_language = 'en_GB'; } // Load .mo file for the selected language $mofile = $langpath . $user_language . '.mo'; // Check if the file exists if (file_exists($mofile)) { // Load the translation load_plugin_textdomain('cve', false, $mofile); } else { // Try to fallback to English $mofile = $langpath . 'en_GB.mo'; if (file_exists($mofile)) { load_plugin_textdomain('cve', false, $mofile); } } }