Ignore:
Timestamp:
Mar 17, 2010, 10:22:51 AM (14 years ago)
Author:
nikrou
Message:

Revert gettext stuff.
Keep english values for language keys translation.
Provide a script to use english values for key in language files.

Todo : provide a script (to help transition) to keep using
original keys in language files for translators.

File:
1 edited

Legend:

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

    r5153 r5156  
    3131include_once( PHPWG_ROOT_PATH .'include/functions_url.inc.php' );
    3232include_once( PHPWG_ROOT_PATH .'include/functions_plugins.inc.php' );
    33 include_once( PHPWG_ROOT_PATH .'include/php-gettext/gettext.inc.php' );
    3433
    3534//----------------------------------------------------------- generic functions
     
    873872function l10n($key, $textdomain='messages')
    874873{
    875   global $user;
    876 
    877   if (empty($user['language']))
    878   {
    879     $locale = $GLOBALS['language'];
    880   }
    881   else
    882   {
    883     $locale = $user['language'];
    884   }
    885 
    886   T_setlocale(LC_ALL, $locale.'.UTF-8');
    887 
    888   // Specify location of translation tables
    889   T_bindtextdomain($textdomain, "./language");
    890 
    891   // Choose domain
    892   T_textdomain($textdomain);
    893  
    894   return T_gettext($key);
     874  global $lang, $conf;
     875
     876  if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key))
     877  {
     878    trigger_error('[l10n] language key "'.$key.'" is not defined', E_USER_WARNING);
     879  }
     880
     881  return isset($lang[$key]) ? $lang[$key] : $key;
    895882}
    896883
     
    904891 * @return string
    905892 */
    906 function l10n_dec($singular_fmt_key, $plural_fmt_key,
    907                   $decimal, $textdomain='messages')
    908 {
    909   global $user;
    910 
    911   if (empty($user['language']))
    912   {
    913     $locale = $GLOBALS['language'];
    914   }
    915   else
    916   {
    917     $locale = $user['language'];
    918   }
    919 
    920   T_setlocale(LC_ALL, $locale.'.UTF-8');
    921 
    922   // Specify location of translation tables
    923   T_bindtextdomain($textdomain, "./language");
    924 
    925   // Choose domain
    926   T_textdomain($textdomain);
    927 
    928   return sprintf(T_ngettext($singular_fmt_key,
    929                             $plural_fmt_key,
    930                             $decimal),
    931                  $decimal
    932                  );
     893function l10n_dec($singular_fmt_key, $plural_fmt_key, $decimal)
     894{
     895  global $lang_info;
     896
     897  return
     898    sprintf(
     899      l10n((
     900        (($decimal > 1) or ($decimal == 0 and $lang_info['zero_plural']))
     901          ? $plural_fmt_key
     902          : $singular_fmt_key
     903        )), $decimal);
    933904}
    934905
Note: See TracChangeset for help on using the changeset viewer.