mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 03:22:39 +00:00
Merge pull request #3703 from MMS-Projects/i18n-context-2.6
Basic support for I18n contexts as requested by #2063
This commit is contained in:
commit
dbe7329e54
7 changed files with 124 additions and 19 deletions
|
@ -781,6 +781,30 @@ if (!function_exists('__c')) {
|
|||
|
||||
}
|
||||
|
||||
if (!function_exists('__x')) {
|
||||
|
||||
/**
|
||||
* Returns a translated string if one is found; Otherwise, the submitted message.
|
||||
*
|
||||
* @param string $context Context of the text
|
||||
* @param string $singular Text to translate
|
||||
* @param mixed $args Array with arguments or multiple arguments in function
|
||||
* @return mixed translated string
|
||||
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__
|
||||
*/
|
||||
function __x($context, $singular, $args = null) {
|
||||
if (!$singular) {
|
||||
return;
|
||||
}
|
||||
|
||||
App::uses('I18n', 'I18n');
|
||||
$translated = I18n::translate($singular, null, null, null, null, null, $context);
|
||||
$arguments = func_get_args();
|
||||
return I18n::insertArgs($translated, array_slice($arguments, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!function_exists('LogError')) {
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue