From: Janusz Dobrowolski Date: Tue, 3 Jan 2012 15:12:49 +0000 (+0100) Subject: Gettext domain was not properly restored after invoking hook provided by extension. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=5c6b8bbe3b9ce35fe6a32171aaa2c4e1ce236021;p=textcart.git Gettext domain was not properly restored after invoking hook provided by extension. --- diff --git a/includes/hooks.inc b/includes/hooks.inc index fedbc4c..90bf207 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 178ec3c..a8ddcfc 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