Add a new getLanguage method to the various IL10n implementations

This commit is contained in:
Jonas Jenwald 2018-03-20 13:42:45 +01:00
parent ab74b32054
commit 513412c92e
4 changed files with 19 additions and 0 deletions

View File

@ -145,6 +145,10 @@ class MozL10n {
this.mozL10n = mozL10n;
}
getLanguage() {
return Promise.resolve(this.mozL10n.getLanguage());
}
getDirection() {
return Promise.resolve(this.mozL10n.getDirection());
}

View File

@ -27,6 +27,12 @@ class GenericL10n {
});
}
getLanguage() {
return this._ready.then((l10n) => {
return l10n.getLanguage();
});
}
getDirection() {
return this._ready.then((l10n) => {
return l10n.getDirection();

View File

@ -160,6 +160,11 @@ class IPDFAnnotationLayerFactory {
* @interface
*/
class IL10n {
/**
* @returns {Promise<string>} - Resolves to the current locale.
*/
getLanguage() {}
/**
* @returns {Promise<string>} - Resolves to 'rtl' or 'ltr'.
*/

View File

@ -58,6 +58,10 @@ function formatL10nValue(text, args) {
* @implements {IL10n}
*/
let NullL10n = {
getLanguage() {
return Promise.resolve('en-us');
},
getDirection() {
return Promise.resolve('ltr');
},