diff options
| author | Zog | 2018-02-07 09:23:20 +0100 |
|---|---|---|
| committer | Luc Donnet | 2018-02-09 13:56:54 +0100 |
| commit | ae36ee8a9270540cea2b0bea70b0f7c46a1818ef (patch) | |
| tree | 9be9b7d1f50fa5cd3c70772a4f1e3ae71daddbb3 /app/assets/javascripts | |
| parent | c608e69bb3908de4c319689fa8232cff4a046b86 (diff) | |
| download | chouette-core-ae36ee8a9270540cea2b0bea70b0f7c46a1818ef.tar.bz2 | |
Refs #4126 @6h; Add i18n to JS
Diffstat (limited to 'app/assets/javascripts')
| -rw-r--r-- | app/assets/javascripts/application.js | 3 | ||||
| -rw-r--r-- | app/assets/javascripts/i18n/extended.coffee | 24 |
2 files changed, 27 insertions, 0 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4c5aff22f..6a79f7e8e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -22,3 +22,6 @@ //= require_directory . // require('whatwg-fetch') // require('babel-polyfill') +//= require "i18n" +//= require "i18n/extended" +//= require "i18n/translations" diff --git a/app/assets/javascripts/i18n/extended.coffee b/app/assets/javascripts/i18n/extended.coffee new file mode 100644 index 000000000..aeb67bd09 --- /dev/null +++ b/app/assets/javascripts/i18n/extended.coffee @@ -0,0 +1,24 @@ +#= require i18n + +decorateI18n = (_i18n)-> + _i18n.tc = (key, opts={}) -> + out = _i18n.t(key, opts) + out += " " if _i18n.locale == "fr" + out + ":" + + _i18n.model_name = (model, opts={}) -> + last_key = if opts.plural then "other" else "one" + _i18n.t("activerecord.models.#{model}.#{last_key}") + + _i18n.attribute_name = (model, attribute, opts={}) -> + _i18n.t("activerecord.attributes.#{model}.#{attribute}") + + _i18n.enumerize = (enumerize, key, opts={}) -> + I18n.t("enumerize.#{enumerize}.#{key}") + + _i18n + +module?.exports = decorateI18n + +if I18n? + decorateI18n(I18n) |
