From 58fd82ca36cb28267529bc7307b4d8e3acf74a58 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Wed, 10 Apr 2013 11:42:12 +0000 Subject: [PATCH] Add the ability to add locale strings in plugins --- src/messenger/webim/libs/common/locale.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/messenger/webim/libs/common/locale.php b/src/messenger/webim/libs/common/locale.php index 175e7bb3..99cd39f5 100644 --- a/src/messenger/webim/libs/common/locale.php +++ b/src/messenger/webim/libs/common/locale.php @@ -130,6 +130,7 @@ function get_locale_links($href) function load_messages($locale) { global $messages, $output_encoding; + // Load core localization $locale_file = dirname(__FILE__) . "/../../locales/{$locale}/properties"; $locale_data = read_locale_file($locale_file); @@ -138,6 +139,23 @@ function load_messages($locale) { } $messages[$locale] = $locale_data['messages']; + + // Load active plugins localization + $plugins_list = array_keys(PluginManager::getAllPlugins()); + + foreach($plugins_list as $plugin_name) { + $locale_file = dirname(__FILE__) . + "/../../plugins/{$plugin_name}/locales/{$locale}/properties"; + if (is_readable($locale_file)) { + $locale_data = read_locale_file($locale_file); + // array_merge used to provide an ability for plugins to override + // localized strings + $messages[$locale] = array_merge( + $messages[$locale], + $locale_data['messages'] + ); + } + } } /**