aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php33
1 files changed, 27 insertions, 6 deletions
diff --git a/application/Utils.php b/application/Utils.php
index bc1c9f5d..db046893 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -327,6 +327,23 @@ function format_date($date, $time = true, $intl = true)
327} 327}
328 328
329/** 329/**
330 * Format the date month according to the locale.
331 *
332 * @param DateTimeInterface $date to format.
333 *
334 * @return bool|string Formatted date, or false if the input is invalid.
335 */
336function format_month(DateTimeInterface $date)
337{
338 if (! $date instanceof DateTimeInterface) {
339 return false;
340 }
341
342 return strftime('%B', $date->getTimestamp());
343}
344
345
346/**
330 * Check if the input is an integer, no matter its real type. 347 * Check if the input is an integer, no matter its real type.
331 * 348 *
332 * PHP is a bit messy regarding this: 349 * PHP is a bit messy regarding this:
@@ -454,16 +471,20 @@ function alphabetical_sort(&$data, $reverse = false, $byKeys = false)
454 * Wrapper function for translation which match the API 471 * Wrapper function for translation which match the API
455 * of gettext()/_() and ngettext(). 472 * of gettext()/_() and ngettext().
456 * 473 *
457 * @param string $text Text to translate. 474 * @param string $text Text to translate.
458 * @param string $nText The plural message ID. 475 * @param string $nText The plural message ID.
459 * @param int $nb The number of items for plural forms. 476 * @param int $nb The number of items for plural forms.
460 * @param string $domain The domain where the translation is stored (default: shaarli). 477 * @param string $domain The domain where the translation is stored (default: shaarli).
478 * @param array $variables Associative array of variables to replace in translated text.
479 * @param bool $fixCase Apply `ucfirst` on the translated string, might be useful for strings with variables.
461 * 480 *
462 * @return string Text translated. 481 * @return string Text translated.
463 */ 482 */
464function t($text, $nText = '', $nb = 1, $domain = 'shaarli') 483function t($text, $nText = '', $nb = 1, $domain = 'shaarli', $variables = [], $fixCase = false)
465{ 484{
466 return dn__($domain, $text, $nText, $nb); 485 $postFunction = $fixCase ? 'ucfirst' : function ($input) { return $input; };
486
487 return $postFunction(dn__($domain, $text, $nText, $nb, $variables));
467} 488}
468 489
469/** 490/**