For rtl support in js we need to know what direction it is.
This commit is contained in:
parent
a222a0878f
commit
d1b50e0ed2
1 changed files with 14 additions and 5 deletions
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue