From 08cd9a5c251dd8fe2d8b5f5a8a19239d36800f4c Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 3 Jan 2012 16:12:49 +0100 Subject: [PATCH] Gettext domain was not properly restored after invoking hook provided by extension. --- includes/hooks.inc | 6 +++--- includes/lang/gettext.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/hooks.inc b/includes/hooks.inc index fedbc4c2..90bf2071 100644 --- a/includes/hooks.inc +++ b/includes/hooks.inc @@ -261,8 +261,8 @@ function hook_invoke_all($method, &$data, $opts=null) } else if (isset($result)) { $return[] = $result; } + set_ext_domain(); } - set_ext_domain(); return $return; } /* @@ -280,9 +280,9 @@ function hook_invoke_first($method, &$data, $opts=null) $result = $hook->$method($data, $opts); if (isset($result)) break; + set_ext_domain(); } } - set_ext_domain(); return $result; } /* @@ -302,9 +302,9 @@ function hook_invoke_last($method, &$data, $opts=null) $result = $hook->$method($data, $opts); if (isset($result)) break; + set_ext_domain(); } } - set_ext_domain(); return $result; } //------------------------------------------------------------------------------------------ diff --git a/includes/lang/gettext.php b/includes/lang/gettext.php index 178ec3c8..a8ddcfc9 100644 --- a/includes/lang/gettext.php +++ b/includes/lang/gettext.php @@ -550,6 +550,17 @@ class gettext_php_support_compiler */ function set_ext_domain($path='') { global $path_to_root; + static $domain_stack = array(''); + + if ($path) // save path on domain stack + array_unshift($domain_stack, $path); + else + { + array_shift($domain_stack); + $path = $domain_stack[0]; + } + $lang_path = $path_to_root . ($path ? '/' : '') .$path.'/lang'; + $lang_path = $path_to_root . ($path ? '/' : '') .$path.'/lang'; // ignore change when extension does not provide translation structure -- 2.30.2