I18n: Move ___() function in functions.php
This commit is contained in:
parent
ffb0e64439
commit
32e27b931e
5 changed files with 42 additions and 41 deletions
|
@ -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)"),
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
use EesyPHP\App;
|
||||
use EesyPHP\I18n;
|
||||
use EesyPHP\SentrySpan;
|
||||
|
||||
use function EesyPHP\___;
|
||||
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
||||
|
||||
// Root directory path
|
||||
|
@ -54,10 +55,10 @@ require_once('functions.php');
|
|||
|
||||
// Nomenclatures
|
||||
$status_list = array (
|
||||
'pending' => 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);
|
||||
|
|
|
@ -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.")
|
||||
);
|
||||
|
|
21
src/I18n.php
21
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 *
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue