#120: Layout localization doesn't work as expected
--------------------------+-------------------------------------------------
Reporter: pillgrim | Type: defect
Status: new | Priority: minor
Milestone: 0.9 | Component: Action Controller
Keywords: locale, i18n |
--------------------------+-------------------------------------------------
Suppose there is application.tpl file which contains some permanent
words/links, eg 'About Us'. Suppose there are 2 controllers/views a and b.
When AK_AUTOMATICALLY_UPDATE_LANGUAGE_FILES is set to true (default
value), both app/locales/a/ru.php and app/locales/b/ru.php do contain the
copy of 'About Us'. So instead of translating once these static words, I
must translate them for each controller. Translations in
app/locales/layout/ru.php are completely ignored if I don't miss enything.
To work around this problem, I've disabled
AK_AUTOMATICALLY_UPDATE_LANGUAGE_FILES and patched Ak.php in the following
way:
{{{
Index: Ak.php
===================================================================
--- Ak.php (revision 478)
+++ Ak.php (working copy)
@@ -186,6 +186,11 @@
return @$string[$try_whith_lang];
}
+ if(isset($controller) &&
!isset($framework_dictionary['layout_dictionary']) &&
is_file(AK_APP_DIR.DS.'locales'.DS.'layout'.DS.$lang.'.php')){
+ require(AK_APP_DIR.DS.'locales'.DS.'layout'.DS.$lang.'.php');
+ $framework_dictionary['layout_dictionary'] =
(array)$dictionary;
+ }
+
if(isset($controller) &&
!isset($framework_dictionary[$controller.'_dictionary']) &&
is_file(AK_APP_DIR.DS.'locales'.DS.$controller.DS.$lang.'.php')){
require(AK_APP_DIR.DS.'locales'.DS.$controller.DS.$lang.'.php');
$framework_dictionary[$controller.'_dictionary'] =
(array)$dictionary;
@@ -193,6 +198,8 @@
if(isset($controller) &&
isset($framework_dictionary[$controller.'_dictionary'][$string])){
$string =
$framework_dictionary[$controller.'_dictionary'][$string];
+ }else if (isset($controller) &&
isset($framework_dictionary['layout_dictionary'][$string])) {
+ $string =
$framework_dictionary['layout_dictionary'][$string];
}else {
$string = isset($framework_dictionary[$string]) ?
$framework_dictionary[$string] : $string;
}
}}}
--
Ticket URL: <
http://trac.akelos.org/ticket/120>
Akelos PHP Framework <
http://www.akelos.org/>
Akelos PHP Framework