Skip to content

Commit

Permalink
Fix get_message on intl_icu if domain is undefined (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
spras authored Jul 3, 2021
1 parent fdf1540 commit d9bc690
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Resources/js/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
if (has_message(_locale, _domains[i], id) ||
has_message(nationalLocaleFallback, _domains[i], id) ||
has_message(localeFallback, _domains[i], id)) {
_domain = _domains[i];
_domain = _domains[i].replace(INTL_DOMAIN_SUFFIX, '');

break;
}
Expand Down
7 changes: 6 additions & 1 deletion Resources/js/translatorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('add()', function() {
});

test('trans()', function() {
expect(14);
expect(17);

Translator.add('foo', 'bar', 'Foo');
Translator.add('foo.with.arg', 'This is Ba %arg%');
Expand Down Expand Up @@ -57,6 +57,11 @@ test('trans()', function() {
equal(Translator.trans('messages.with.args', { name: 'John', projectCount: 0 }, 'messages'), 'John has no projects.', 'Returns the ICU-formatted message with correct replaces.');
equal(Translator.trans('messages.with.args', { name: 'John', projectCount: 1 }, 'messages'), 'John has 1 project.', 'Returns the ICU-formatted message with correct replaces.');
equal(Translator.trans('messages.with.args', { name: 'John', projectCount: 4 }, 'messages'), 'John has 4 projects.', 'Returns the ICU-formatted message with correct replaces.');

equal(Translator.trans('messages.with.args', { name: 'John', projectCount: 0 }), 'John has no projects.', 'Returns the ICU-formatted message with correct replaces.');
equal(Translator.trans('messages.with.args', { name: 'John', projectCount: 1 }), 'John has 1 project.', 'Returns the ICU-formatted message with correct replaces.');
equal(Translator.trans('messages.with.args', { name: 'John', projectCount: 4 }), 'John has 4 projects.', 'Returns the ICU-formatted message with correct replaces.');

});

test('transChoice()', function() {
Expand Down

0 comments on commit d9bc690

Please sign in to comment.