From af040415e2019c6403bd62c816d30133d4b80ac9 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Fri, 1 Nov 2013 15:34:30 +0000 Subject: feature 2651: fallback language, failed when the "child" file does not exists git-svn-id: http://piwigo.org/svn/trunk@25288 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/functions.inc.php b/include/functions.inc.php index c8f16a0c4..83edf45a2 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1352,6 +1352,31 @@ function get_pwg_charset() return $pwg_charset; } +/** + * returns the parent language of the current language or any language + * @since 2.6 + * @param string $lang_id + * @return string + */ +function get_parent_language($lang_id=null) +{ + if (empty($lang_id)) + { + global $lang_info; + return !empty($lang_info['parent']) ? $lang_info['parent'] : null; + } + else + { + $f = PHPWG_ROOT_PATH.'language/'.$lang_id.'/common.lang.php'; + if (file_exists($f)) + { + include($f); + return !empty($lang_info['parent']) ? $lang_info['parent'] : null; + } + } + return null; +} + /** * includes a language file or returns the content of a language file * availability of the file @@ -1402,6 +1427,10 @@ function load_language($filename, $dirname = '', { $languages[] = $user['language']; } + if ( ($parent = get_parent_language()) != null) + { + $languages[] = $parent; + } if ( ! @$options['no_fallback'] ) { if ( defined('PHPWG_INSTALLED') ) @@ -1453,7 +1482,7 @@ function load_language($filename, $dirname = '', $parent_language = !empty($load_lang_info['parent']) ? $load_lang_info['parent'] : ( !empty($lang_info['parent']) ? $lang_info['parent'] : null ); - if (!empty($parent_language)) + if (!empty($parent_language) and $parent_language != $selected_language) { @include(str_replace($selected_language, $parent_language, $source_file)); } -- cgit v1.2.3