aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-11-01 15:34:30 +0000
committermistic100 <mistic@piwigo.org>2013-11-01 15:34:30 +0000
commitaf040415e2019c6403bd62c816d30133d4b80ac9 (patch)
tree98dfcbb9125d80c0e39c1a0da2091caa88a3e929
parent41a74a821eca70280706353eb12df80d796acf7e (diff)
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
Diffstat (limited to '')
-rw-r--r--include/functions.inc.php31
1 files changed, 30 insertions, 1 deletions
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
@@ -1353,6 +1353,31 @@ function get_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));
}