I18n: Move ___() function in functions.php

This commit is contained in:
Benjamin Renard 2023-03-22 18:12:43 +01:00
parent ffb0e64439
commit 32e27b931e
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC
5 changed files with 42 additions and 41 deletions

View file

@ -3,9 +3,10 @@
use EesyPHP\Check; use EesyPHP\Check;
use EesyPHP\Cli; use EesyPHP\Cli;
use EesyPHP\Date; use EesyPHP\Date;
use EesyPHP\I18n;
use EesyPHP\Log; use EesyPHP\Log;
use function EesyPHP\___;
/* /*
************************************************************************************************* *************************************************************************************************
* /!\ Code after this message will only be execute on CLI context /!\ * /!\ Code after this message will only be execute on CLI context /!\
@ -113,13 +114,13 @@ function cli_list($command_args) {
Cli :: add_command( Cli :: add_command(
'list', 'list',
'cli_list', 'cli_list',
I18n :: ___("List/search items"), ___("List/search items"),
I18n :: ___("[patterns]"), ___("[patterns]"),
array( array(
I18n :: ___("-o|--orderby Ordering list criterion. Possible values:"), ___("-o|--orderby Ordering list criterion. Possible values:"),
" - ".implode("\n - ", $orderbys), " - ".implode("\n - ", $orderbys),
I18n :: ___("-r|--reverse Reverse order"), ___("-r|--reverse Reverse order"),
I18n :: ___("-s|--status Filter on status. Possible values:"), ___("-s|--status Filter on status. Possible values:"),
" - ".implode("\n - ", array_keys($status_list)), " - ".implode("\n - ", array_keys($status_list)),
) )
); );
@ -140,8 +141,8 @@ function cli_show($command_args) {
Cli :: add_command( Cli :: add_command(
'show', 'show',
'cli_show', 'cli_show',
I18n :: ___("Show item"), ___("Show item"),
I18n :: ___("[ID]") ___("[ID]")
); );
function cli_delete($command_args) { function cli_delete($command_args) {
@ -178,8 +179,8 @@ function cli_delete($command_args) {
Cli :: add_command( Cli :: add_command(
'delete', 'delete',
'cli_delete', 'cli_delete',
I18n :: ___("Delete item"), ___("Delete item"),
I18n :: ___("[item ID]") ___("[item ID]")
); );
function cli_export($command_args) { function cli_export($command_args) {
@ -191,8 +192,8 @@ function cli_export($command_args) {
Cli :: add_command( Cli :: add_command(
'export', 'export',
'cli_export', 'cli_export',
I18n :: ___("Export items (as CSV)"), ___("Export items (as CSV)"),
I18n :: ___("[output file path]") ___("[output file path]")
); );
function cli_restore($command_args) { function cli_restore($command_args) {
@ -207,8 +208,8 @@ function cli_restore($command_args) {
Cli :: add_command( Cli :: add_command(
'restore', 'restore',
'cli_restore', 'cli_restore',
I18n :: ___("Restore items (from CSV)"), ___("Restore items (from CSV)"),
I18n :: ___("[input file path]") ___("[input file path]")
); );
function cli_cron($command_args) { function cli_cron($command_args) {
@ -275,11 +276,11 @@ function cli_cron($command_args) {
Cli :: add_command( Cli :: add_command(
'cron', 'cron',
'cli_cron', 'cli_cron',
I18n :: ___("Cron to handle item expiration"), ___("Cron to handle item expiration"),
null, null,
array ( array (
I18n :: ___("-j/--just-try Just-try mode : do not really removed expired item(s)"), ___("-j/--just-try Just-try mode : do not really removed expired item(s)"),
I18n :: ___("-m/--max-age Item expiration limit (in days, optional)"), ___("-m/--max-age Item expiration limit (in days, optional)"),
) )
); );

View file

@ -1,9 +1,10 @@
<?php <?php
use EesyPHP\App; use EesyPHP\App;
use EesyPHP\I18n;
use EesyPHP\SentrySpan; use EesyPHP\SentrySpan;
use function EesyPHP\___;
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED); error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
// Root directory path // Root directory path
@ -54,10 +55,10 @@ require_once('functions.php');
// Nomenclatures // Nomenclatures
$status_list = array ( $status_list = array (
'pending' => I18n :: ___('Pending'), 'pending' => ___('Pending'),
'validated' => I18n :: ___('Validated'), 'validated' => ___('Validated'),
'refused' => I18n :: ___('Refused'), 'refused' => ___('Refused'),
'archived' => I18n :: ___('Archived'), 'archived' => ___('Archived'),
); );
foreach($status_list as $key => $value) foreach($status_list as $key => $value)
$status_list[$key] = _($value); $status_list[$key] = _($value);

View file

@ -41,9 +41,9 @@ class Cli {
self :: add_command( self :: add_command(
'new_project', 'new_project',
array('\\EesyPHP\\Cli', 'cli_new_project'), array('\\EesyPHP\\Cli', 'cli_new_project'),
I18n :: ___("Create a new project using EesyPHP framework"), ___("Create a new project using EesyPHP framework"),
null, null,
I18n :: ___( ___(
"This command could be used to easily build the structure of a new project using the ". "This command could be used to easily build the structure of a new project using the ".
"EesyPHP framework.") "EesyPHP framework.")
); );
@ -52,9 +52,9 @@ class Cli {
self :: add_command( self :: add_command(
'serve', 'serve',
array('\\EesyPHP\\Cli', 'cli_serve'), array('\\EesyPHP\\Cli', 'cli_serve'),
I18n :: ___("Start the PHP built-in HTTP server to serve the application"), ___("Start the PHP built-in HTTP server to serve the application"),
null, null,
I18n :: ___( ___(
"This command could be used to start the PHP built-in HTTP server to serve the ". "This command could be used to start the PHP built-in HTTP server to serve the ".
"application.") "application.")
); );

View file

@ -135,28 +135,28 @@ class I18n {
Cli :: add_command( Cli :: add_command(
'extract_messages', 'extract_messages',
array('\\EesyPHP\\I18n', 'cli_extract_messages'), array('\\EesyPHP\\I18n', 'cli_extract_messages'),
self :: ___("Extract messages that need to be translated"), ___("Extract messages that need to be translated"),
null, null,
self :: ___("This command could be used to generate/update locales/messages.pot file.") ___("This command could be used to generate/update locales/messages.pot file.")
); );
Cli :: add_command( Cli :: add_command(
'update_messages', 'update_messages',
array('\\EesyPHP\\I18n', 'cli_update_messages'), array('\\EesyPHP\\I18n', 'cli_update_messages'),
self :: ___("Update messages in translation PO lang files"), ___("Update messages in translation PO lang files"),
null, null,
self :: ___("This command could be used to init/update PO files in locales/*/LC_MESSAGES directories.") ___("This command could be used to init/update PO files in locales/*/LC_MESSAGES directories.")
); );
Cli :: add_command( Cli :: add_command(
'compile_messages', 'compile_messages',
array('\\EesyPHP\\I18n', 'cli_compile_messages'), array('\\EesyPHP\\I18n', 'cli_compile_messages'),
self :: ___( ___(
"Compile messages from existing translation PO lang files to ". "Compile messages from existing translation PO lang files to ".
"corresponding MO files and JS catalogs" "corresponding MO files and JS catalogs"
), ),
null, null,
self :: ___( ___(
"This command could be used to compile PO files in locales/*/LC_MESSAGES ". "This command could be used to compile PO files in locales/*/LC_MESSAGES ".
"directories to MO files and as JS catalogs in locales directory." "directories to MO files and as JS catalogs in locales directory."
) )
@ -260,15 +260,6 @@ class I18n {
return $return; return $return;
} }
/**
* Just mark message for translation
* @param string $msg The message to translate
* @return string The message without transformation
*/
public static function ___($msg) {
return $msg;
}
/* /*
******************************************************************** ********************************************************************
* Translations CLI commands * * Translations CLI commands *

View file

@ -282,4 +282,12 @@ function check_ajax_request($session_key=null) {
Log :: debug("Ajax Request : ".vardump($_REQUEST)); Log :: debug("Ajax Request : ".vardump($_REQUEST));
} }
/**
* Just mark message for translation
* @param string $msg The message to translate
* @return string The message without transformation
*/
function ___($msg) {
return $msg;
}
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab # vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab