From 32e27b931e4768dcc884dead10576b62525c8a88 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 22 Mar 2023 18:12:43 +0100 Subject: [PATCH] I18n: Move ___() function in functions.php --- example/includes/cli.php | 35 ++++++++++++++++++----------------- example/includes/core.php | 11 ++++++----- src/Cli.php | 8 ++++---- src/I18n.php | 21 ++++++--------------- src/functions.php | 8 ++++++++ 5 files changed, 42 insertions(+), 41 deletions(-) diff --git a/example/includes/cli.php b/example/includes/cli.php index ba1bfa9..5f04f34 100644 --- a/example/includes/cli.php +++ b/example/includes/cli.php @@ -3,9 +3,10 @@ use EesyPHP\Check; use EesyPHP\Cli; use EesyPHP\Date; -use EesyPHP\I18n; use EesyPHP\Log; +use function EesyPHP\___; + /* ************************************************************************************************* * /!\ Code after this message will only be execute on CLI context /!\ @@ -113,13 +114,13 @@ function cli_list($command_args) { Cli :: add_command( 'list', 'cli_list', - I18n :: ___("List/search items"), - I18n :: ___("[patterns]"), + ___("List/search items"), + ___("[patterns]"), array( - I18n :: ___("-o|--orderby Ordering list criterion. Possible values:"), + ___("-o|--orderby Ordering list criterion. Possible values:"), " - ".implode("\n - ", $orderbys), - I18n :: ___("-r|--reverse Reverse order"), - I18n :: ___("-s|--status Filter on status. Possible values:"), + ___("-r|--reverse Reverse order"), + ___("-s|--status Filter on status. Possible values:"), " - ".implode("\n - ", array_keys($status_list)), ) ); @@ -140,8 +141,8 @@ function cli_show($command_args) { Cli :: add_command( 'show', 'cli_show', - I18n :: ___("Show item"), - I18n :: ___("[ID]") + ___("Show item"), + ___("[ID]") ); function cli_delete($command_args) { @@ -178,8 +179,8 @@ function cli_delete($command_args) { Cli :: add_command( 'delete', 'cli_delete', - I18n :: ___("Delete item"), - I18n :: ___("[item ID]") + ___("Delete item"), + ___("[item ID]") ); function cli_export($command_args) { @@ -191,8 +192,8 @@ function cli_export($command_args) { Cli :: add_command( 'export', 'cli_export', - I18n :: ___("Export items (as CSV)"), - I18n :: ___("[output file path]") + ___("Export items (as CSV)"), + ___("[output file path]") ); function cli_restore($command_args) { @@ -207,8 +208,8 @@ function cli_restore($command_args) { Cli :: add_command( 'restore', 'cli_restore', - I18n :: ___("Restore items (from CSV)"), - I18n :: ___("[input file path]") + ___("Restore items (from CSV)"), + ___("[input file path]") ); function cli_cron($command_args) { @@ -275,11 +276,11 @@ function cli_cron($command_args) { Cli :: add_command( 'cron', 'cli_cron', - I18n :: ___("Cron to handle item expiration"), + ___("Cron to handle item expiration"), null, array ( - I18n :: ___("-j/--just-try Just-try mode : do not really removed expired item(s)"), - I18n :: ___("-m/--max-age Item expiration limit (in days, optional)"), + ___("-j/--just-try Just-try mode : do not really removed expired item(s)"), + ___("-m/--max-age Item expiration limit (in days, optional)"), ) ); diff --git a/example/includes/core.php b/example/includes/core.php index 0bdad7e..f00b7f5 100644 --- a/example/includes/core.php +++ b/example/includes/core.php @@ -1,9 +1,10 @@ I18n :: ___('Pending'), - 'validated' => I18n :: ___('Validated'), - 'refused' => I18n :: ___('Refused'), - 'archived' => I18n :: ___('Archived'), + 'pending' => ___('Pending'), + 'validated' => ___('Validated'), + 'refused' => ___('Refused'), + 'archived' => ___('Archived'), ); foreach($status_list as $key => $value) $status_list[$key] = _($value); diff --git a/src/Cli.php b/src/Cli.php index 9a197e9..92c57a3 100644 --- a/src/Cli.php +++ b/src/Cli.php @@ -41,9 +41,9 @@ class Cli { self :: add_command( 'new_project', array('\\EesyPHP\\Cli', 'cli_new_project'), - I18n :: ___("Create a new project using EesyPHP framework"), + ___("Create a new project using EesyPHP framework"), null, - I18n :: ___( + ___( "This command could be used to easily build the structure of a new project using the ". "EesyPHP framework.") ); @@ -52,9 +52,9 @@ class Cli { self :: add_command( '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, - I18n :: ___( + ___( "This command could be used to start the PHP built-in HTTP server to serve the ". "application.") ); diff --git a/src/I18n.php b/src/I18n.php index b63e060..f0f82dd 100644 --- a/src/I18n.php +++ b/src/I18n.php @@ -135,28 +135,28 @@ class I18n { Cli :: add_command( 'extract_messages', array('\\EesyPHP\\I18n', 'cli_extract_messages'), - self :: ___("Extract messages that need to be translated"), + ___("Extract messages that need to be translated"), 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( 'update_messages', array('\\EesyPHP\\I18n', 'cli_update_messages'), - self :: ___("Update messages in translation PO lang files"), + ___("Update messages in translation PO lang files"), 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( 'compile_messages', array('\\EesyPHP\\I18n', 'cli_compile_messages'), - self :: ___( + ___( "Compile messages from existing translation PO lang files to ". "corresponding MO files and JS catalogs" ), null, - self :: ___( + ___( "This command could be used to compile PO files in locales/*/LC_MESSAGES ". "directories to MO files and as JS catalogs in locales directory." ) @@ -260,15 +260,6 @@ class I18n { 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 * diff --git a/src/functions.php b/src/functions.php index eee6f66..5159cb1 100644 --- a/src/functions.php +++ b/src/functions.php @@ -282,4 +282,12 @@ function check_ajax_request($session_key=null) { 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