Changeset 71ced07 in github


Ignore:
Timestamp:
May 9, 2012 7:09:36 AM (13 months ago)
Author:
Aleksander Machniak <alec@…>
Branches:
release-0.8
Children:
951c9b3a
Parents:
f5d2f08
git-author:
Aleksander Machniak <alec@…> (05/09/12 06:47:44)
git-committer:
Aleksander Machniak <alec@…> (05/09/12 07:09:36)
Message:

Use similar language as a fallback for plugin localization (#1488401)
Don't load en_US localization more than once

Conflicts:

CHANGELOG
program/include/rcube.php

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    raca50c1 r71ced07  
    22=========================== 
    33 
     4- Use similar language as a fallback for plugin localization (#1488401) 
    45- Fix issue where signature wasn't re-added on draft compose (#1488322) 
    56- Update to TinyMCE 3.5 (#1488459) 
  • program/include/rcmail.php

    ra9c1b87 r71ced07  
    11681168 
    11691169      // include user language files 
    1170       if ($lang != 'en' && is_dir(INSTALL_PATH . 'program/localization/' . $lang)) { 
     1170      if ($lang != 'en' && $lang != 'en_US' && is_dir(INSTALL_PATH . 'program/localization/' . $lang)) { 
    11711171        include_once(INSTALL_PATH . 'program/localization/' . $lang . '/labels.inc'); 
    11721172        include_once(INSTALL_PATH . 'program/localization/' . $lang . '/messages.inc'); 
  • program/include/rcube_plugin.php

    r479af905 r71ced07  
    153153  { 
    154154    $domain = $this->ID; 
    155  
    156     $lang = $_SESSION['language']; 
     155    $lang   = $_SESSION['language']; 
     156    $langs  = array_unique(array('en_US', $lang)); 
    157157    $locdir = slashify(realpath(slashify($this->home) . $dir)); 
    158     $texts = array(); 
     158    $texts  = array(); 
     159 
     160    // Language aliases used to find localization in similar lang, see below 
     161    $aliases = array( 
     162        'de_CH' => 'de_DE', 
     163        'es_AR' => 'es_ES', 
     164        'fa_AF' => 'fa_IR', 
     165        'nl_BE' => 'nl_NL', 
     166        'pt_BR' => 'pt_PT', 
     167        'zh_CN' => 'zh_TW', 
     168    ); 
    159169 
    160170    // use buffering to handle empty lines/spaces after closing PHP tag 
    161171    ob_start(); 
    162172 
    163     foreach (array('en_US', $lang) as $lng) { 
     173    foreach ($langs as $lng) { 
    164174      $fpath = $locdir . $lng . '.inc'; 
    165175      if (is_file($fpath) && is_readable($fpath)) { 
    166         include($fpath); 
     176        include $fpath; 
    167177        $texts = (array)$labels + (array)$messages + (array)$texts; 
     178      } 
     179      else if ($lng != 'en_US') { 
     180        // Find localization in similar language (#1488401) 
     181        $alias = null; 
     182        if (!empty($aliases[$lng])) { 
     183          $alias = $aliases[$lng]; 
     184        } 
     185        else if ($key = array_search($lng, $aliases)) { 
     186          $alias = $key; 
     187        } 
     188 
     189        if (!empty($alias)) { 
     190          $fpath = $locdir . $alias . '.inc'; 
     191          if (is_file($fpath) && is_readable($fpath)) { 
     192            include $fpath; 
     193            $texts = (array)$labels + (array)$messages + (array)$texts; 
     194          } 
     195        } 
    168196      } 
    169197    } 
Note: See TracChangeset for help on using the changeset viewer.