#1488401 closed Feature Patches (fixed)

Plugin Localization improvement

Reported by: rosali Owned by:
Priority: 5 Milestone: 0.8-rc
Component: Plugin API Version: 0.8-beta
Severity: normal Keywords:
Cc:

Description (last modified by alec)

Most of the plugin localizations are incomplete. I have noticed that
the plugin api
always defaults to en_US if a language set is missing. This is
basically ok because en_US is the "always complete" set.

Nethertheless it should not default to en_US if, f.e., de_DE is present
but de_CH is missing.
In this case it should load de_DE instead of en_US. Same for pt_BR, if
pt_PT is present.

Here is a small patch for class rcube_plugin, method add_texts to
archive this behavior:

     foreach (array('en_US', $lang) as $lng) {
       $fpath = $locdir . $lng . '.inc';
       if (is_file($fpath) && is_readable($fpath)) {
         include($fpath);
         $texts = (array)$labels + (array)$messages + (array)$texts;
       }
       // begin mod
       else {
         $atemp = explode('_', $lang);
         if ($handle = opendir($locdir)) {
           while (false !== ($file = readdir($handle))) {
             if ($file != "." && $file != "..") {
               if(strpos($file, '.inc') && substr($file, 0, 2) == 
$atemp[0]){
                 if (is_file($locdir . $file) && is_readable($locdir . 
$file)) {
                   include($locdir . $file);
                   $texts = (array)$labels + (array)$messages + 
(array)$texts;
                   // maybe it would be better not to break and merge 
all the 'sub' langs
                   break;
                 }
               }
             }
           }
           closedir($handle);
         }
       }
       // end mod
     }

Change History (1)

comment:1 Changed 13 months ago by alec

  • Description modified (diff)
  • Resolution set to fixed
  • Status changed from new to closed

I think use of hardcoded list of possible aliases would be much more faster. Done in [49ab20c8e790fdbcb43dd2f317f67583b061ce14].

Note: See TracTickets for help on using tickets.