Ignore:
Timestamp:
Nov 1, 2013, 4:34:30 PM (10 years ago)
Author:
mistic100
Message:

feature 2651: fallback language, failed when the "child" file does not exists

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r25114 r25288  
    13541354
    13551355/**
     1356 * returns the parent language of the current language or any language
     1357 * @since 2.6
     1358 * @param string $lang_id
     1359 * @return string
     1360 */
     1361function get_parent_language($lang_id=null)
     1362{
     1363  if (empty($lang_id))
     1364  {
     1365    global $lang_info;
     1366    return !empty($lang_info['parent']) ? $lang_info['parent'] : null;
     1367  }
     1368  else
     1369  {
     1370    $f = PHPWG_ROOT_PATH.'language/'.$lang_id.'/common.lang.php';
     1371    if (file_exists($f))
     1372    {
     1373      include($f);
     1374      return !empty($lang_info['parent']) ? $lang_info['parent'] : null;
     1375    }
     1376  }
     1377  return null;
     1378}
     1379
     1380/**
    13561381 * includes a language file or returns the content of a language file
    13571382 * availability of the file
     
    14031428    $languages[] = $user['language'];
    14041429  }
     1430  if ( ($parent = get_parent_language()) != null)
     1431  {
     1432    $languages[] = $parent;
     1433  }
    14051434  if ( ! @$options['no_fallback'] )
    14061435  {
     
    14541483      $parent_language = !empty($load_lang_info['parent']) ? $load_lang_info['parent'] : (
    14551484                            !empty($lang_info['parent']) ? $lang_info['parent'] : null );
    1456       if (!empty($parent_language))
     1485      if (!empty($parent_language) and $parent_language != $selected_language)
    14571486      {
    14581487        @include(str_replace($selected_language, $parent_language, $source_file));
Note: See TracChangeset for help on using the changeset viewer.