From 9a97bb727e382bcec0d6ba153511fc5065d8a648 Mon Sep 17 00:00:00 2001 From: hellekin Date: Tue, 4 Dec 2012 21:33:29 -0300 Subject: Be nice to other plugins (fixes #1534102) The plugin *must* now come *after* other plugins it should update translation strings for. - Add an init,system handler - Do not force reloading all strings all the time --- start.php | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'start.php') diff --git a/start.php b/start.php index a481c8877..1b392dd49 100644 --- a/start.php +++ b/start.php @@ -4,6 +4,34 @@ * */ +elgg_register_event_handler('init', 'system', 'languages_init'); + +function languages_init() { + + register_translations(elgg_get_plugins_path() . "languages/languages/es"); + register_translations(elgg_get_plugins_path() . "languages/languages/nl"); + register_translations(elgg_get_plugins_path() . "languages/languages/de"); + register_translations(elgg_get_plugins_path() . "languages/languages/pt"); + register_translations(elgg_get_plugins_path() . "languages/languages/fr"); + register_translations(elgg_get_plugins_path() . "languages/languages/ca"); + register_translations(elgg_get_plugins_path() . "languages/languages/da"); + register_translations(elgg_get_plugins_path() . "languages/languages/eu"); + register_translations(elgg_get_plugins_path() . "languages/languages/gl"); + register_translations(elgg_get_plugins_path() . "languages/languages/it"); + register_translations(elgg_get_plugins_path() . "languages/languages/ja"); + register_translations(elgg_get_plugins_path() . "languages/languages/sr"); + register_translations(elgg_get_plugins_path() . "languages/languages/th"); + register_translations(elgg_get_plugins_path() . "languages/languages/zh"); + + if (!elgg_is_logged_in()) { + global $CONFIG; + if ($useragent_language = languages_get_useragent_language()) { + $CONFIG->language = $useragent_language; + } + } + +} + function languages_get_useragent_language() { global $CONFIG; if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { @@ -25,24 +53,3 @@ function languages_get_useragent_language() { } } -register_translations(elgg_get_plugins_path() . "languages/languages/es", true); -register_translations(elgg_get_plugins_path() . "languages/languages/nl", true); -register_translations(elgg_get_plugins_path() . "languages/languages/de", true); -register_translations(elgg_get_plugins_path() . "languages/languages/pt", true); -register_translations(elgg_get_plugins_path() . "languages/languages/fr", true); -register_translations(elgg_get_plugins_path() . "languages/languages/ca", true); -register_translations(elgg_get_plugins_path() . "languages/languages/da", true); -register_translations(elgg_get_plugins_path() . "languages/languages/eu", true); -register_translations(elgg_get_plugins_path() . "languages/languages/gl", true); -register_translations(elgg_get_plugins_path() . "languages/languages/it", true); -register_translations(elgg_get_plugins_path() . "languages/languages/ja", true); -register_translations(elgg_get_plugins_path() . "languages/languages/sr", true); -register_translations(elgg_get_plugins_path() . "languages/languages/th", true); -register_translations(elgg_get_plugins_path() . "languages/languages/zh", true); - -if (!elgg_is_logged_in()) { - global $CONFIG; - if ($useragent_language = languages_get_useragent_language()) { - $CONFIG->language = $useragent_language; - } -} \ No newline at end of file -- cgit v1.2.3