Changeset 1908 for trunk/include/functions.inc.php
- Timestamp:
- Mar 16, 2007, 12:20:41 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r1900 r1908 1019 1019 global $lang, $conf; 1020 1020 1021 if ($conf['debug_l10n'] and !isset($lang[$key]) )1021 if ($conf['debug_l10n'] and !isset($lang[$key]) and !empty($key)) 1022 1022 { 1023 1023 echo '[l10n] language key "'.$key.'" is not defined<br />'; … … 1048 1048 )), $decimal); 1049 1049 } 1050 /* 1051 * returns a single element to use with l10n_args 1052 * 1053 * @param string key: translation key 1054 * @param array/string/../number args: 1055 * arguments to use on sprintf($key, args) 1056 * if args is a array, each values are used on sprintf 1057 * @return string 1058 */ 1059 function get_l10n_args($key, $args) 1060 { 1061 if (is_array($args)) 1062 { 1063 $key_arg = array_merge(array($key), $args); 1064 } 1065 else 1066 { 1067 $key_arg = array($key, $args); 1068 } 1069 return array('key_args' => $key_arg); 1070 } 1071 1072 /* 1073 * returns a string with formated with l10n_args elements 1074 * 1075 * @param element/array $key_args: element or array of l10n_args elements 1076 * @param $sep: if $key_args is array, 1077 * separator is used when translated l10n_args elements are concated 1078 * @return string 1079 */ 1080 function l10n_args($key_args, $sep = "\n") 1081 { 1082 if (is_array($key_args)) 1083 { 1084 foreach ($key_args as $key => $element) 1085 { 1086 if (isset($result)) 1087 { 1088 $result .= $sep; 1089 } 1090 else 1091 { 1092 $result = ''; 1093 } 1094 1095 if ($key === 'key_args') 1096 { 1097 array_unshift($element, l10n(array_shift($element))); 1098 $result .= call_user_func_array('sprintf', $element); 1099 } 1100 else 1101 { 1102 $result .= l10n_args($element, $sep); 1103 } 1104 } 1105 } 1106 else 1107 { 1108 die('l10n_args: Invalid arguments'); 1109 } 1110 1111 return $result; 1112 } 1050 1113 1051 1114 /**
Note: See TracChangeset
for help on using the changeset viewer.