Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added multi-line support #95

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

edgarzavala
Copy link

@edgarzavala edgarzavala commented Jun 3, 2016

Added support for multiple strings for localization, ex.

….
"message" : [ "line 1 to",
"line 2 of message",
"line 3 of message" ],
….


This change is Reviewable

Added support for multiple strings for localization, ex.

….
"message" : [ "line 1 to",
"line 2 of message",
"line 3 of message" ],
….
@@ -201,7 +201,7 @@ angular.module('ngLocalize')
}

function applySubstitutions(text, subs) {
var res = text,
var res = (text instanceof Array ? text.join('') : text),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use angular.isArray instead

@bretkikehara
Copy link
Collaborator

Can u provide the use case? Why should the message be joined at runtime?

Used angular.isArray instead of 'instanceof'
@edgarzavala
Copy link
Author

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.

@@ -201,7 +201,7 @@ angular.module('ngLocalize')
}

function applySubstitutions(text, subs) {
var res = text,
var res = (angular.isArray(text) ? text.join('') : text),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be more intuitive to join with a space.

Copy link
Author

@edgarzavala edgarzavala Jun 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants