mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
I18n object file for karma
This commit is contained in:
3
app/assets/javascripts/darkswarm/i18n.js.erb
Normal file
3
app/assets/javascripts/darkswarm/i18n.js.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<%# Defines a global I18n object containing the language of the current locale %>
|
||||
<%- I18n.backend.send(:init_translations) unless I18n.backend.initialized? %>
|
||||
window.I18n = <%= I18n.backend.send(:translations)[I18n.locale].with_indifferent_access.to_json.html_safe %>
|
||||
@@ -1,7 +1,3 @@
|
||||
# Defines a global I18n object containing the language of the current locale
|
||||
<%- I18n.backend.send(:init_translations) unless I18n.backend.initialized? %>
|
||||
window.I18n = <%= I18n.backend.send(:translations)[I18n.locale].with_indifferent_access.to_json.html_safe %>
|
||||
|
||||
# Declares the translation function t.
|
||||
# You can use t('login') in Javascript.
|
||||
window.t = (key, options = {}) ->
|
||||
@@ -25,6 +25,7 @@ module.exports = function(config) {
|
||||
'**/.#*',
|
||||
'app/assets/javascripts/darkswarm/all.js.coffee',
|
||||
'app/assets/javascripts/darkswarm/overrides.js.coffee',
|
||||
'app/assets/javascripts/darkswarm/i18n.js.erb',
|
||||
'app/assets/javascripts/admin/util.js.erb'
|
||||
],
|
||||
|
||||
|
||||
@@ -10,8 +10,10 @@ namespace :karma do
|
||||
private
|
||||
|
||||
def with_tmp_config(command, args = nil)
|
||||
|
||||
I18n.backend.send(:init_translations) unless I18n.backend.initialized?
|
||||
Tempfile.open('karma_unit.js', Rails.root.join('tmp') ) do |f|
|
||||
f.write unit_js(application_spec_files)
|
||||
f.write unit_js(application_spec_files << i18n_file)
|
||||
f.flush
|
||||
trap('SIGINT') { puts "Killing Karma"; exit }
|
||||
exec "karma #{command} #{f.path} #{args}"
|
||||
@@ -29,4 +31,12 @@ namespace :karma do
|
||||
unit_js = File.open('config/ng-test.conf.js', 'r').read
|
||||
unit_js.gsub "APPLICATION_SPEC", "\"#{files.join("\",\n\"")}\""
|
||||
end
|
||||
|
||||
def i18n_file
|
||||
f = Tempfile.open('i18n.js', Rails.root.join('tmp') )
|
||||
f.write 'window.I18n = '
|
||||
f.write I18n.backend.send(:translations)[I18n.locale].with_indifferent_access.to_json.html_safe
|
||||
f.flush
|
||||
f.path
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user