3 * Harvie's PHP Localization
4 * Copyright (C) 2o11 Thomas Mudrunka
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 require_once(DIR_LOCALE
.'/'.LOCALE_LANG
.'/messages.inc.php');
22 //Wrap regexes with slashes
23 foreach($LOCALE_MESSAGES['regexp'] as $regexp => $replace) {
24 $LOCALE_MESSAGES['regexp']['/'.$regexp.'/i'] = $LOCALE_MESSAGES['regexp'][$regexp];
25 unset($LOCALE_MESSAGES['regexp'][$regexp]);
28 //Uppercase alternative
29 /*$LOCALE_MESSAGES['map'] = array_merge($LOCALE_MESSAGES['map'],
30 array_flip(array_map('strtoupper',array_flip(array_map('strtoupper',$LOCALE_MESSAGES['map']))))
34 * !!! IMPORTANT NOTICE: This is ugly hack !!!
35 * !!! You should rather use PHP's internal gettext support !!!
38 if(is_array($text)) return array_map('T',$text);
40 if(isset($GLOBALS['LOCALE_MESSAGES']['map'][$text])) return $GLOBALS['LOCALE_MESSAGES']['map'][$text];
42 $t = strtolower($text);
43 if(isset($GLOBALS['LOCALE_MESSAGES']['map'][$t])) return $GLOBALS['LOCALE_MESSAGES']['map'][$t];
46 if(isset($GLOBALS['LOCALE_MESSAGES']['map'][$t])) return $GLOBALS['LOCALE_MESSAGES']['map'][$t];
48 $text = str_ireplace(array_keys($GLOBALS['LOCALE_MESSAGES']['map']), $GLOBALS['LOCALE_MESSAGES']['map'], $text);
50 return preg_replace(array_keys($GLOBALS['LOCALE_MESSAGES']['regexp']), $GLOBALS['LOCALE_MESSAGES']['regexp'], $text);
This page took 0.295226 seconds and 4 git commands to generate.