Sha256: 29f2d73a82a27ddcd735f03ca0ab424197aaec518e22652274ca07652380eb71

Contents?: true

Size: 670 Bytes

Versions: 5

Compression:

Stored size: 670 Bytes

Contents

{config} = LocalTime
{i18n} = config

LocalTime.getI18nValue = (keyPath = "", {locale} = locale: config.locale) ->
  value = getValue(i18n[locale], keyPath)
  if value?
    value
  else if locale isnt config.defaultLocale
    LocalTime.getI18nValue(keyPath, locale: config.defaultLocale)

LocalTime.translate = (keyPath, interpolations = {}, options) ->
  string = LocalTime.getI18nValue(keyPath, options)
  for key, replacement of interpolations
    string = string.replace("{#{key}}", replacement)
  string

getValue = (object, keyPath) ->
  value = object
  for key in keyPath.split(".")
    if value[key]?
      value = value[key]
    else
      return null
  value

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_auction-0.0.6 lib/assets/javascripts/src/local-time/helpers/i18n.coffee
solidus_auction-0.0.5 lib/assets/javascripts/src/local-time/helpers/i18n.coffee
solidus_auction-0.0.4 lib/assets/javascripts/src/local-time/helpers/i18n.coffee
solidus_auction-0.0.3 lib/assets/javascripts/src/local-time/helpers/i18n.coffee
solidus_auction-0.0.1 lib/assets/javascripts/src/local-time/helpers/i18n.coffee