From 4097eaed388501b28e0a35a8c6913b98f40ac7e1 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 4 May 2020 18:02:39 +0200 Subject: [PATCH] Add ___() function to allow declaration of messages that will be translated at display time --- public_html/includes/functions.php | 21 +++++++++++++++++++++ public_html/lang/generate_ldapsaisie.pot.sh | 1 + 2 files changed, 22 insertions(+) diff --git a/public_html/includes/functions.php b/public_html/includes/functions.php index 9ac76f09..cf9e43f9 100644 --- a/public_html/includes/functions.php +++ b/public_html/includes/functions.php @@ -494,6 +494,13 @@ function LSdebugDefined() { return 1; } + /** + * Translate message by using LSlang or Gettext methods + * + * @param[in] @msg string The message + * + * @retval string The translated message if translation available, the original message otherwise + **/ function __($msg) { if (empty($msg)) return $msg; if (isset($GLOBALS['LSlang'][$msg])) { @@ -502,6 +509,20 @@ function LSdebugDefined() { return _($msg); } + /** + * Non-translate message + * + * Just-return the input message. This function permit the detection of message + * that will be translated only at display time and not at declare time. + * + * @param[in] @msg string The message + * + * @retval string The message (unchanged) + **/ + function ___($msg) { + return $msg; + } + /** * Supprime les accents d'une chaine * diff --git a/public_html/lang/generate_ldapsaisie.pot.sh b/public_html/lang/generate_ldapsaisie.pot.sh index 7917c76a..2875c8a8 100755 --- a/public_html/lang/generate_ldapsaisie.pot.sh +++ b/public_html/lang/generate_ldapsaisie.pot.sh @@ -12,6 +12,7 @@ xgettext --from-code utf-8 \ --omit-header \ --copyright-holder="Easter-eggs" \ --keyword="__" \ + --keyword="___" \ $( find "$PUBLIC_HTML" -name "*.php" ) # Extract other messages from LdapSaisie templates files