Overriding translations

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Overriding translations

Aday Talavera
My current and default app locale is "es_ES".

I generated my default.pot using I18n shell and my en_US translations in default.po and default.mo inside en_US folder.
es_ES doesn't have .po and .mo files at all, because the "native language" of the app strings is es_ES.

How can I override a translation in es_ES using I18n translators?

For example, a message like:

__('Hola')

I want to define a custom "array" translator so I can change this string into another:

$translator = ['Hola' => 'Adios'];

__
('Adios')

Tried to follow the examples in the book without success.


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Overriding translations

José Lorenzo
Did you read this part?

http://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#creating-your-own-translators

On Tuesday, November 24, 2015 at 3:00:30 PM UTC+1, Aday Talavera wrote:
My current and default app locale is "es_ES".

I generated my default.pot using I18n shell and my en_US translations in default.po and default.mo inside en_US folder.
es_ES doesn't have .po and .mo files at all, because the "native language" of the app strings is es_ES.

How can I override a translation in es_ES using I18n translators?

For example, a message like:

__('Hola')

I want to define a custom "array" translator so I can change this string into another:

$translator = ['Hola' => 'Adios'];

__
('Adios')

Tried to follow the examples in the book without success.


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Overriding translations

Aday Talavera
Fragment of code not working as expected:

Cake\I18n\I18n::translator('default', 'es_ES', function () {
    $package
= new Aura\Intl\Package(
       
'default', // The formatting strategy (ICU)
       
'default'  // The fallback domain
   
);
    $package
->setMessages([
       
'Llegada' => 'foo',
   
]);
   
return $package;
});

// Output is es_ES
echo
Cake\I18n\I18n::defaultLocale();

// Output is "Llegada" not "foo"
echo __
('Llegada');



El viernes, 27 de noviembre de 2015, 13:38:48 (UTC), José Lorenzo escribió:
Did you read this part?

<a href="http://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#creating-your-own-translators" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fbook.cakephp.org%2F3.0%2Fen%2Fcore-libraries%2Finternationalization-and-localization.html%23creating-your-own-translators\46sa\75D\46sntz\0751\46usg\75AFQjCNH-FUETZ2lgvPoU788TE-31TP-qzw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fbook.cakephp.org%2F3.0%2Fen%2Fcore-libraries%2Finternationalization-and-localization.html%23creating-your-own-translators\46sa\75D\46sntz\0751\46usg\75AFQjCNH-FUETZ2lgvPoU788TE-31TP-qzw&#39;;return true;">http://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#creating-your-own-translators

On Tuesday, November 24, 2015 at 3:00:30 PM UTC+1, Aday Talavera wrote:
My current and default app locale is "es_ES".

I generated my default.pot using I18n shell and my en_US translations in default.po and default.mo inside en_US folder.
es_ES doesn't have .po and .mo files at all, because the "native language" of the app strings is es_ES.

How can I override a translation in es_ES using I18n translators?

For example, a message like:

__('Hola')

I want to define a custom "array" translator so I can change this string into another:

$translator = ['Hola' => 'Adios'];

__
('Adios')

Tried to follow the examples in the book without success.


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.