mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-24 01:13:21 +00:00
13 lines
418 B
CoffeeScript
13 lines
418 B
CoffeeScript
# Declares the translation function t.
|
|
# You can use translate('login') or t('login') in Javascript.
|
|
window.translate = (key, options = {}) ->
|
|
unless 'I18n' of window
|
|
console.log 'The I18n object is undefined. Cannot translate text.'
|
|
return key
|
|
return key unless key of I18n
|
|
text = I18n[key]
|
|
for name, value of options
|
|
text = text.split("%{#{name}}").join(value)
|
|
text
|
|
window.t = window.translate
|