Add ___() function to allow declaration of messages that will be translated at display time

This commit is contained in:
Benjamin Renard 2020-05-04 18:02:39 +02:00
parent 07cdad29a4
commit 4097eaed38
2 changed files with 22 additions and 0 deletions

View file

@ -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
*

View file

@ -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