diff --git a/app/assets/javascripts/app/lib/app_post/i18n.coffee b/app/assets/javascripts/app/lib/app_post/i18n.coffee index 3dd198b70..560562269 100644 --- a/app/assets/javascripts/app/lib/app_post/i18n.coffee +++ b/app/assets/javascripts/app/lib/app_post/i18n.coffee @@ -30,6 +30,11 @@ class App.i18n _instance ?= new _i18nSingleton() _instance.date(args, offset) + @dir: -> + if _instance == undefined + _instance ?= new _i18nSingleton() + _instance.dir() + @get: -> if _instance == undefined _instance ?= new _i18nSingleton() @@ -88,6 +93,10 @@ class _i18nSingleton extends Spine.Module @_notTranslated = {} @dateFormat = 'yyyy-mm-dd' @timestampFormat = 'yyyy-mm-dd HH:MM' + @dirToSet = 'ltr' + + dir: -> + @dirToSet get: -> @locale @@ -96,7 +105,7 @@ class _i18nSingleton extends Spine.Module # prepare locale localeToSet = localeToSet.toLowerCase() - dirToSet = 'ltr' + @dirToSet = 'ltr' # check if locale exists localeFound = false @@ -104,7 +113,7 @@ class _i18nSingleton extends Spine.Module for locale in locales if locale.locale is localeToSet localeToSet = locale.locale - dirToSet = locale.dir + @dirToSet = locale.dir localeFound = true # try aliases @@ -112,7 +121,7 @@ class _i18nSingleton extends Spine.Module for locale in locales if locale.alias is localeToSet localeToSet = locale.locale - dirToSet = locale.dir + @dirToSet = locale.dir localeFound = true # if no locale and no alias was found, try to find correct one @@ -123,7 +132,7 @@ class _i18nSingleton extends Spine.Module for locale in locales if locale.alias is localeToSet localeToSet = locale.locale - dirToSet = locale.dir + @dirToSet = locale.dir localeFound = true # check if locale need to be changed @@ -137,7 +146,7 @@ class _i18nSingleton extends Spine.Module # set lang and dir attribute of html tag $('html').prop('lang', localeToSet.substr(0, 2)) - $('html').prop('dir', dirToSet) + $('html').prop('dir', @dirToSet) @mapString = {} App.Ajax.request(