From cb47a9c92eb3bf65fcf86f377ebd4044232a1f98 Mon Sep 17 00:00:00 2001 From: David Wheatley Date: Mon, 20 Jun 2022 03:51:26 +0100 Subject: [PATCH] feat(translator): add locale getter (#3451) --- framework/core/js/src/common/Translator.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/framework/core/js/src/common/Translator.tsx b/framework/core/js/src/common/Translator.tsx index 3f211bf63..3ac1896de 100644 --- a/framework/core/js/src/common/Translator.tsx +++ b/framework/core/js/src/common/Translator.tsx @@ -18,10 +18,20 @@ export default class Translator { */ protected formatter = new RichMessageFormatter(null, this.formatterTypeHandlers(), mithrilRichHandler); + /** + * Sets the formatter's locale to the provided value. + */ setLocale(locale: string) { this.formatter.locale = locale; } + /** + * Returns the formatter's current locale. + */ + getLocale() { + return this.formatter.locale; + } + addTranslations(translations: Translations) { Object.assign(this.translations, translations); }