diff --git a/web/firefoxcom.js b/web/firefoxcom.js index 99026e9fa..2aea61b0f 100644 --- a/web/firefoxcom.js +++ b/web/firefoxcom.js @@ -145,21 +145,20 @@ class MozL10n { this.mozL10n = mozL10n; } - getLanguage() { - return Promise.resolve(this.mozL10n.getLanguage()); + async getLanguage() { + return this.mozL10n.getLanguage(); } - getDirection() { - return Promise.resolve(this.mozL10n.getDirection()); + async getDirection() { + return this.mozL10n.getDirection(); } - get(property, args, fallback) { - return Promise.resolve(this.mozL10n.get(property, args, fallback)); + async get(property, args, fallback) { + return this.mozL10n.get(property, args, fallback); } - translate(element) { + async translate(element) { this.mozL10n.translate(element); - return Promise.resolve(); } } diff --git a/web/genericl10n.js b/web/genericl10n.js index e2da69a60..c722c289c 100644 --- a/web/genericl10n.js +++ b/web/genericl10n.js @@ -27,28 +27,24 @@ class GenericL10n { }); } - getLanguage() { - return this._ready.then((l10n) => { - return l10n.getLanguage(); - }); + async getLanguage() { + const l10n = await this._ready; + return l10n.getLanguage(); } - getDirection() { - return this._ready.then((l10n) => { - return l10n.getDirection(); - }); + async getDirection() { + const l10n = await this._ready; + return l10n.getDirection(); } - get(property, args, fallback) { - return this._ready.then((l10n) => { - return l10n.get(property, args, fallback); - }); + async get(property, args, fallback) { + const l10n = await this._ready; + return l10n.get(property, args, fallback); } - translate(element) { - return this._ready.then((l10n) => { - return l10n.translate(element); - }); + async translate(element) { + const l10n = await this._ready; + return l10n.translate(element); } } diff --git a/web/interfaces.js b/web/interfaces.js index 2e8b52d1d..62e4c2ce8 100644 --- a/web/interfaces.js +++ b/web/interfaces.js @@ -163,12 +163,12 @@ class IL10n { /** * @returns {Promise} - Resolves to the current locale. */ - getLanguage() {} + async getLanguage() {} /** * @returns {Promise} - Resolves to 'rtl' or 'ltr'. */ - getDirection() {} + async getDirection() {} /** * Translates text identified by the key and adds/formats data using the args @@ -179,12 +179,12 @@ class IL10n { * @param {string} fallback * @returns {Promise} */ - get(key, args, fallback) { } + async get(key, args, fallback) { } /** * Translates HTML element. * @param {HTMLElement} element * @returns {Promise} */ - translate(element) { } + async translate(element) { } } diff --git a/web/ui_utils.js b/web/ui_utils.js index d87b78c15..d0e59d58d 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -56,21 +56,19 @@ function formatL10nValue(text, args) { * @implements {IL10n} */ let NullL10n = { - getLanguage() { - return Promise.resolve('en-us'); + async getLanguage() { + return 'en-us'; }, - getDirection() { - return Promise.resolve('ltr'); + async getDirection() { + return 'ltr'; }, - get(property, args, fallback) { - return Promise.resolve(formatL10nValue(fallback, args)); + async get(property, args, fallback) { + return formatL10nValue(fallback, args); }, - translate(element) { - return Promise.resolve(); - }, + async translate(element) { }, }; /**