aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-10-22 13:19:51 +0200
committerGitHub <noreply@github.com>2017-10-22 13:19:51 +0200
commitd8acf8550480694d050091e270a06c01e7b313f0 (patch)
treef62befb2351c4b6550f71e11f6845bc3acb78a5d /application/Utils.php
parentefd3a6405a381501b070b8805ae37d1313969784 (diff)
parent1a47014f99d2f7aae00d37e62e0364d4eaa1ce29 (diff)
downloadShaarli-d8acf8550480694d050091e270a06c01e7b313f0.tar.gz
Shaarli-d8acf8550480694d050091e270a06c01e7b313f0.tar.zst
Shaarli-d8acf8550480694d050091e270a06c01e7b313f0.zip
Merge pull request #871 from ArthurHoaro/feature/translation
Shaarli's translation
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/application/Utils.php b/application/Utils.php
index 4a2f5561..2f38a8de 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -452,7 +452,7 @@ function get_max_upload_size($limitPost, $limitUpload, $format = true)
452 */ 452 */
453function alphabetical_sort(&$data, $reverse = false, $byKeys = false) 453function alphabetical_sort(&$data, $reverse = false, $byKeys = false)
454{ 454{
455 $callback = function($a, $b) use ($reverse) { 455 $callback = function ($a, $b) use ($reverse) {
456 // Collator is part of PHP intl. 456 // Collator is part of PHP intl.
457 if (class_exists('Collator')) { 457 if (class_exists('Collator')) {
458 $collator = new Collator(setlocale(LC_COLLATE, 0)); 458 $collator = new Collator(setlocale(LC_COLLATE, 0));
@@ -470,3 +470,18 @@ function alphabetical_sort(&$data, $reverse = false, $byKeys = false)
470 usort($data, $callback); 470 usort($data, $callback);
471 } 471 }
472} 472}
473
474/**
475 * Wrapper function for translation which match the API
476 * of gettext()/_() and ngettext().
477 *
478 * @param string $text Text to translate.
479 * @param string $nText The plural message ID.
480 * @param int $nb The number of items for plural forms.
481 * @param string $domain The domain where the translation is stored (default: shaarli).
482 *
483 * @return string Text translated.
484 */
485function t($text, $nText = '', $nb = 1, $domain = 'shaarli') {
486 return dn__($domain, $text, $nText, $nb);
487}