Generate i18n export as TypeScript and move locale logic there

This commit is contained in:
Andreas Nedbal 2022-01-13 23:24:44 +01:00 committed by Andreas Nedbal
parent 1a408e1bc6
commit 8247c8864f
3 changed files with 4 additions and 11 deletions

3
.gitignore vendored
View File

@ -24,8 +24,7 @@ coverage/
*~ *~
# dont push generated js translations to repository # dont push generated js translations to repository
/app/assets/javascripts/i18n/*.js /app/javascript/retrospring/i18n.ts
/app/javascript/legacy/i18n.js
# every fucking time, dolphin # every fucking time, dolphin
.directory .directory

View File

@ -5,17 +5,11 @@ import '../legacy/jquery'
import 'popper.js' import 'popper.js'
import 'bootstrap' import 'bootstrap'
import 'particleground/jquery.particleground.min' import 'particleground/jquery.particleground.min'
import Cookies from 'js-cookie'
# this file is generated by Rails
import I18n from '../legacy/i18n'
import '../legacy/pagination' import '../legacy/pagination'
import '../legacy/locale-box' import '../legacy/locale-box'
import '../legacy/util' import '../legacy/util'
I18n.defaultLocale = 'en';
I18n.locale = Cookies.get('hl') || 'en';
_ready = -> _ready = ->
$('[data-toggle="tooltip"]').tooltip() $('[data-toggle="tooltip"]').tooltip()
$('.dropdown-toggle').dropdown() $('.dropdown-toggle').dropdown()

View File

@ -26,7 +26,7 @@ fallbacks: :default_locale
export_i18n_js: false export_i18n_js: false
translations: translations:
- file: 'app/javascript/legacy/i18n.js' - file: 'app/javascript/retrospring/i18n.ts'
only: ['*.frontend.*', '*.views.actions.*'] only: ['*.frontend.*', '*.views.actions.*']
prefix: "import I18n from 'i18n-js'\n" prefix: "import I18n from 'i18n-js'\nimport Cookies from 'js-cookie'\n"
suffix: "\nexport default I18n" suffix: "I18n.defaultLocale = 'en';\nI18n.locale = Cookies.get('hl') || 'en';\nexport default I18n"