Skip to content

Commit

Permalink
[I18n] Update locale objects format (#23917) (#24639)
Browse files Browse the repository at this point in the history
* Update output file format for i18n_check tool

* Update i18n engine to work with new format

* Update tests

* Fix UI bootstrap test

* Update loader tests and fix getTranslationsByLocale function

* Fix messages passing to IntlProvider

* Update messages interface

* Resolve comments

* Resolve comment
  • Loading branch information
LeanidShutau authored Oct 29, 2018
1 parent 31d30f8 commit b3086f2
Show file tree
Hide file tree
Showing 19 changed files with 294 additions and 289 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"a.b.c": "bar",
"d.e.f": "foo"
"messages": {
"a.b.c": "bar",
"d.e.f": "foo"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"a.b.c": "foo",
"d.e.f": "bar"
"messages": {
"a.b.c": "foo",
"d.e.f": "bar"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"a.b.c.custom": "foo.custom",
"d.e.f.custom": "bar.custom"
"messages": {
"a.b.c.custom": "foo.custom",
"d.e.f.custom": "bar.custom"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
test: 'test' // JSON5 test
messages: {
test: 'test' // JSON5 test
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"test": "test"
"messages": {
"test": "test"
}
}
4 changes: 2 additions & 2 deletions packages/kbn-i18n/src/angular/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import * as i18n from '../core';
export type I18nServiceType = ReturnType<I18nProvider['$get']>;

export class I18nProvider implements angular.IServiceProvider {
public addMessages = i18n.addMessages;
public getMessages = i18n.getMessages;
public addTranslation = i18n.addTranslation;
public getTranslation = i18n.getTranslation;
public setLocale = i18n.setLocale;
public getLocale = i18n.getLocale;
public setDefaultLocale = i18n.setDefaultLocale;
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-i18n/src/core/__snapshots__/i18n.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`I18n engine addMessages should throw error if locale is not specified o

exports[`I18n engine addMessages should throw error if locale is not specified or empty 2`] = `"[I18n] A \`locale\` must be a non-empty string to add messages."`;

exports[`I18n engine addMessages should throw error if locale specified in messages is different from one provided as second argument 1`] = `"[I18n] A \`locale\` in the messages object is different from the one provided as a second argument."`;
exports[`I18n engine addMessages should throw error if locale specified in messages is different from one provided as second argument 1`] = `"[I18n] A \`locale\` in the translation object is different from the one provided as a second argument."`;

exports[`I18n engine translate should throw error if id is not a non-empty string 1`] = `"[I18n] An \`id\` must be a non-empty string to translate a message."`;

Expand Down
Loading

0 comments on commit b3086f2

Please sign in to comment.