Sha256: 317df6b5be6e0404ce05ba3eecf30e6d3f087ce0c88adcb7e30c5d27b42592e2

Contents?: true

Size: 783 Bytes

Versions: 6

Compression:

Stored size: 783 Bytes

Contents

#= require alchemy/alchemy.translations

window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'

Alchemy.I18n =

  # Translates given string
  #
  translate: (key, replacement) ->
    if !Alchemy.locale?
      throw 'Alchemy.locale is not set! Please set Alchemy.locale to a locale string in order to translate something.'
    translations = Alchemy.translations[Alchemy.locale]
    if translations
      translation = translations[key] || key
      if replacement
        translation.replace(/%\{.+\}/, replacement)
      else
        translation
    else
      Alchemy.debug "Translations for locale #{Alchemy.locale} not found!"
      key

# Global utility method for translating a given string
#
Alchemy.t = (key, replacement) ->
  Alchemy.I18n.translate(key, replacement)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alchemy_cms-3.3.3 app/assets/javascripts/alchemy/alchemy.i18n.js.coffee
alchemy_cms-3.3.2 app/assets/javascripts/alchemy/alchemy.i18n.js.coffee
alchemy_cms-3.3.1 app/assets/javascripts/alchemy/alchemy.i18n.js.coffee
alchemy_cms-3.3.0 app/assets/javascripts/alchemy/alchemy.i18n.js.coffee
alchemy_cms-3.3.0.rc2 app/assets/javascripts/alchemy/alchemy.i18n.js.coffee
alchemy_cms-3.3.0.rc1 app/assets/javascripts/alchemy/alchemy.i18n.js.coffee