diff options
author | filip <filip.komar@gmail.com> | 2016-06-14 22:17:39 +0200 |
---|---|---|
committer | filip <filip.komar@gmail.com> | 2016-06-14 22:17:39 +0200 |
commit | 066e0791dfd3928ae5dd8b1bde3983eda6765ffa (patch) | |
tree | c6eff6cc16c269d2cb5a1a2ab9b215702c62c15c /langs.inc.php | |
parent | f32086d574de2e61771621455b05092aa2efbe75 (diff) | |
download | www-066e0791dfd3928ae5dd8b1bde3983eda6765ffa.tar www-066e0791dfd3928ae5dd8b1bde3983eda6765ffa.tar.gz www-066e0791dfd3928ae5dd8b1bde3983eda6765ffa.tar.bz2 www-066e0791dfd3928ae5dd8b1bde3983eda6765ffa.tar.xz www-066e0791dfd3928ae5dd8b1bde3983eda6765ffa.zip |
a bit more flexible i18n helper
Diffstat (limited to 'langs.inc.php')
-rw-r--r-- | langs.inc.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/langs.inc.php b/langs.inc.php index 42bb3a748..3a67aa463 100644 --- a/langs.inc.php +++ b/langs.inc.php @@ -500,7 +500,9 @@ function _r($string_for_translation, $sufix = '') * will just echo translation * * _g('Download Mageia %d!', array(5), 'a href="" style="color: blue;"') - * will echo blue link + * OR for only one member of array: + * _g('Download Mageia %s!', 5, 'a href="" style="color: blue;"') + * will both echo blue link * * _g("Hey there.", null, ' '); _g("How are you?") * will just echo translation: Hey there. How are you? @@ -509,7 +511,7 @@ function _r($string_for_translation, $sufix = '') * Do not exit the process. * * @param string $string_for_translation which we want to translate - * @param array $args for vsprintf + * @param array OR string $args for vsprintf/sprintf * @param string $tag_or_space HTML tag or space to append * * @return null @@ -517,8 +519,12 @@ function _r($string_for_translation, $sufix = '') function _g($string_for_translation, $args = null, $tag_or_space = '') { $translated_string = _r($string_for_translation); - if(is_array($args)) { - $translated_string = vsprintf($translated_string, $args); + if(!is_null($args)) { + if(is_array($args)) { + $translated_string = vsprintf($translated_string, $args); + } else { + $translated_string = sprintf($translated_string, $args); + } } if(!empty($tag_or_space) && $tag_or_space != ' ') { $tag_or_space_w_args = explode(' ', $tag_or_space); |