Conversation
Added support for multiple strings for localization, ex. …. "message" : [ "line 1 to", "line 2 of message", "line 3 of message" ], ….
src/localization.js
Outdated
|
|
||
| function applySubstitutions(text, subs) { | ||
| var res = text, | ||
| var res = (text instanceof Array ? text.join('') : text), |
There was a problem hiding this comment.
please use angular.isArray instead
|
Can u provide the use case? Why should the message be joined at runtime? |
Used angular.isArray instead of 'instanceof'
|
Some special cases we have on our localization for an application from english to spanish, in spanish some sentences are longer and in our case made more ease (for reading) to have multiple 'lines' on the json instead of a long string. You may say the editor has some times the 'wrap words' function, however it helped us (made it more easy to check). Believe it is something that may be useful for somebody else. |
|
|
||
| function applySubstitutions(text, subs) { | ||
| var res = text, | ||
| var res = (angular.isArray(text) ? text.join('') : text), |
There was a problem hiding this comment.
I think it will be more intuitive to join with a space.
There was a problem hiding this comment.
Based on the use case presented for the split if we want to split "this is a very long string to be splitted in two" we can split in [ "this is a very long string ","to be splitted in two" ] and after the join the string will be "this is a very long string to be splitted in two" if the join is an space it will become "this is a very long string to be splitted in two" with a double space between "string" and "to"
There was a problem hiding this comment.
It's weird to have trailing whitespace in strings you wish to join, is there a specific reason why you can't remove the whitespace from your string array in the json and let the joiner do the work? I think that's the 99% use case anyway.
Added support for multiple strings for localization, ex.
….
"message" : [ "line 1 to",
"line 2 of message",
"line 3 of message" ],
….
This change is