Feature ini adapter translate #2706

Closed
wants to merge 11 commits into
from

Projects

None yet

4 participants

@blanchonvincent
Contributor

Feature ini adapter translate

@weierophinney weierophinney commented on an outdated diff Oct 10, 2012
library/Zend/I18n/Translator/Loader/Ini.php
+ } else {
+ $messages[array_shift($message)] = array_shift($message);
+ }
+ }
+
+ if (!is_array($messages)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Expected an array, but received %s',
+ gettype($messages)
+ ));
+ }
+
+ $textDomain = new TextDomain($messages);
+
+ if (array_key_exists('plural', $messagesNamespaced)) {
+ if (isset($messagesNamespaced['plural']['plural_forms'])) {
@weierophinney
weierophinney Oct 10, 2012 Member

Combine these into a single conditional using '&&'.

@weierophinney weierophinney commented on an outdated diff Oct 10, 2012
library/Zend/I18n/Translator/Loader/Ini.php
+
+ $list = $messagesNamespaced;
+ if(isset($messagesNamespaced['translation'])) {
+ $list = $messagesNamespaced['translation'];
+ }
+ foreach($list as $message) {
+ if(!is_array($message) || count($message) < 2) {
+ throw new Exception\InvalidArgumentException(
+ 'Each INI row must be an array with message and translation'
+ );
+ }
+ if(isset($message['message']) && isset($message['translation'])) {
+ $messages[$message['message']] = $message['translation'];
+ } else {
+ $messages[array_shift($message)] = array_shift($message);
+ }
@weierophinney
weierophinney Oct 10, 2012 Member

Rewrite the above as:

if (isset($message['message'] && isset($message['translation'])) {
    $messages[$message['message'] = $message['translation'];
    continue;
}
$messages[array_shift($message)] = array_shift($message);
@DASPRiD DASPRiD was assigned Oct 10, 2012
@weierophinney
Member

Looks clean enough -- have you had any feedback on the mailing list or @DASPRiD ?

@blanchonvincent
Contributor

Code change is done. Thx.
No, i had no feedback from the mailing list.

@ThomasCantonnet ThomasCantonnet and 1 other commented on an outdated diff Nov 14, 2012
...8n/Translator/_files/translation_en_simple_syntax.ini
+idenfitier3[] = "Message 3"
+idenfitier3[] = "Message 3 (en)"
+
+idenfitier4[] = "Message 4"
+idenfitier4[] = "Message 4 (en)"
+
+idenfitier5.message = "Message 5"
+idenfitier5.translation.0 = "Message 5 (en) Plural 0"
+idenfitier5.translation.1 = "Message 5 (en) Plural 1"
+idenfitier5.translation.2 = "Message 5 (en) Plural 2"
+
+idenfitier6[] = "Cooking furniture"
+idenfitier6[] = "Küchen Möbel (en)"
+
+idenfitier7[] = "Küchen Möbel"
+idenfitier7[] = "Cooking furniture (en)"
@ThomasCantonnet
ThomasCantonnet Nov 14, 2012 Contributor

Dunno if you wanna correct everything, but you wrote identifier wrong everywhere (idenfitier) :p

@blanchonvincent
blanchonvincent Nov 14, 2012 Contributor

Oops, i will change this :)

@blanchonvincent
blanchonvincent Nov 14, 2012 Contributor

It's fixed, thank you.

@weierophinney weierophinney added a commit that referenced this pull request Dec 10, 2012
@weierophinney weierophinney [#2706] CS cleanup
- whitespace around conditionals
- remove commented code
- EOF markers
c6a496c
@weierophinney
Member

@blanchonvincent If you haven't yet, please submit some docs on using the new adapter. :)

@weierophinney weierophinney added a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015
@weierophinney weierophinney [zendframework/zendframework#2706] CS cleanup
- whitespace around conditionals
- remove commented code
- EOF markers
fd6f1d5
@weierophinney weierophinney added a commit to zendframework/zend-i18n that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'feature/i18n-translator-ini' into develop 9e59ae6
@weierophinney weierophinney added a commit to zendframework/zend-i18n-resources that referenced this pull request May 28, 2015
@weierophinney weierophinney Merge branch 'feature/i18n-translator-ini' into develop beb876e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment