diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-08-07 11:52:49 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-08-07 11:54:39 +0200 |
commit | edf3ff5a53b353ed4a5d9d617bfd06a6c13b3bac (patch) | |
tree | 04bdab4db1ef5e8c68ea161e198bf2aef7ae9396 /application | |
parent | 65b2c795d00f638d6ca08519e1435efd989c8117 (diff) | |
download | Shaarli-edf3ff5a53b353ed4a5d9d617bfd06a6c13b3bac.tar.gz Shaarli-edf3ff5a53b353ed4a5d9d617bfd06a6c13b3bac.tar.zst Shaarli-edf3ff5a53b353ed4a5d9d617bfd06a6c13b3bac.zip |
Initialize a translation function
It matches the API of ngettext().
Diffstat (limited to 'application')
-rw-r--r-- | application/Languages.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/application/Languages.php b/application/Languages.php new file mode 100644 index 00000000..c8b0a25a --- /dev/null +++ b/application/Languages.php | |||
@@ -0,0 +1,21 @@ | |||
1 | <?php | ||
2 | |||
3 | /** | ||
4 | * Wrapper function for translation which match the API | ||
5 | * of gettext()/_() and ngettext(). | ||
6 | * | ||
7 | * Not doing translation for now. | ||
8 | * | ||
9 | * @param string $text Text to translate. | ||
10 | * @param string $nText The plural message ID. | ||
11 | * @param int $nb The number of items for plural forms. | ||
12 | * | ||
13 | * @return String Text translated. | ||
14 | */ | ||
15 | function t($text, $nText = '', $nb = 0) { | ||
16 | if (empty($nText)) { | ||
17 | return $text; | ||
18 | } | ||
19 | $actualForm = $nb > 1 ? $nText : $text; | ||
20 | return sprintf($actualForm, $nb); | ||
21 | } | ||