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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

firstOfKind = 0;

if (subs) {
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/filterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ describe('filter', function () {
versionAlt: 'v%major.%minor.%patch',
fullNameAlt: 'My name is {1} {2}',
'key with whitespace': 'valuewithoutwhitespace',
'fullNameDups': 'My full name is {firstName} {lastName} so my "good name" is {firstName}.'
'fullNameDups': 'My full name is {firstName} {lastName} so my "good name" is {firstName}.',
'multiline' : ['line1',
'line2',
'line3']
});
});
});
Expand Down Expand Up @@ -78,5 +81,10 @@ describe('filter', function () {
lastName: 'Smith'
})).toEqual('My full name is John Smith so my "good name" is John.');
}));

it('should combine multiple lines in one line',inject(function(i18nFilter){
expect(i18nFilter('common.multiline'))
.toEqual("line1line2line3");
}));
});
});