Add the ability to add locale strings in plugins

This commit is contained in:
Dmitriy Simushev 2013-04-10 11:42:12 +00:00
parent 803f2ba075
commit 58fd82ca36

View File

@ -130,6 +130,7 @@ function get_locale_links($href)
function load_messages($locale) { function load_messages($locale) {
global $messages, $output_encoding; global $messages, $output_encoding;
// Load core localization
$locale_file = dirname(__FILE__) . "/../../locales/{$locale}/properties"; $locale_file = dirname(__FILE__) . "/../../locales/{$locale}/properties";
$locale_data = read_locale_file($locale_file); $locale_data = read_locale_file($locale_file);
@ -138,6 +139,23 @@ function load_messages($locale) {
} }
$messages[$locale] = $locale_data['messages']; $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']
);
}
}
} }
/** /**