
From: Archana Singh <archus@linux.vnet.ibm.com> This patch adds getter and setter methods to 1) get locale the locale from cookies (if present) otherwise get it from bowser lang(if present) otherwise return as en-US 2) set locale Signed-off-by: Archana Singh <archus@linux.vnet.ibm.com> co-authored by: Pooja Kulkarni <pkulkark@linux.vnet.ibm.com> --- ui/js/src/wok.lang.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ui/js/src/wok.lang.js b/ui/js/src/wok.lang.js index b3791e7..4e2065b 100644 --- a/ui/js/src/wok.lang.js +++ b/ui/js/src/wok.lang.js @@ -45,6 +45,22 @@ wok.lang = { $('html').prop('lang') || 'en_US'; }, + + /** + * Locale is determined by the following sequence: + * 1) Cookie setting; or if not set -> + * 2) HTML DOM lang attribute; or if not set -> + * 3) DEFAULT (en_US). + */ + get_locale: function() { + return wok.cookie.get('wokLocale') || + $('html').prop('lang') || + 'en-US'; + }, + + set_locale: function(selected_locale) { + wok.cookie.set('wokLocale', selected_locale, 365); + }, set: function(lang) { wok.cookie.set('wokLang', lang, 365); -- 1.8.3.1