From: Tom Hughes Date: Tue, 28 Aug 2018 16:59:46 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/1950' X-Git-Tag: live~2941 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/1dfbd9282c3b863ab2bf5b6a68f68195ba377851?hp=08f0621d6f9342ab473cd1fdc262a5b6e9a368c3 Merge remote-tracking branch 'upstream/pull/1950' --- diff --git a/.gitignore b/.gitignore index 920ca1120..1a2d35c6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ log config/piwik.yml +app/assets/javascripts/i18n public/assets public/attachments public/export diff --git a/.travis.yml b/.travis.yml index 48ddb4a1d..8ce7f5f30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ before_script: - psql -U postgres -c "CREATE FUNCTION xid_to_int4(xid) RETURNS int4 AS '/tmp/libpgosm', 'xid_to_int4' LANGUAGE C STRICT" openstreetmap - cp config/travis.database.yml config/database.yml - bundle exec rake db:migrate + - bundle exec rake i18n:js:export script: - bundle exec rubocop -f fuubar - bundle exec rake jshint diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4461c5ab7..654b01680 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,7 +12,7 @@ //= require leaflet.map //= require leaflet.zoom //= require leaflet.locationfilter -//= require i18n/translations +//= require i18n //= require oauth //= require piwik //= require richtext diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index 1d294dc82..56c3051b2 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -3,6 +3,7 @@ <%= javascript_include_tag "application" %> + <%= javascript_include_tag "i18n/" + I18n.locale.to_s %> <%= stylesheet_link_tag "screen-#{dir}", :media => "screen" %> <%= stylesheet_link_tag "print-#{dir}", :media => "print" %> <%= stylesheet_link_tag "leaflet-all", :media => "screen, print" %> diff --git a/config/environments/development.rb b/config/environments/development.rb index 9065ed8e3..b7e60eb4f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -52,6 +52,9 @@ Rails.application.configure do # Suppress logger output for asset requests. config.assets.quiet = true + # Export translations automatically + config.middleware.use I18n::JS::Middleware + # Raises error for missing translations # config.action_view.raise_on_missing_translations = true diff --git a/config/i18n-js.yml b/config/i18n-js.yml index 144954538..0697bfe2e 100644 --- a/config/i18n-js.yml +++ b/config/i18n-js.yml @@ -1,27 +1,8 @@ -# Split context in several files. -# By default only one file with all translations is exported and -# no configuration is required. Your settings for asset pipeline -# are automatically recognized. -# -# If you want to split translations into several files or specify -# locale contexts that will be exported, just use this file to do -# so. -# -# If you're going to use the Rails 3.1 asset pipeline, change -# the following configuration to something like this: -# -# translations: -# - file: "app/assets/javascripts/i18n/translations.js" -# -# If you're running an old version, you can use something -# like this: -# -# translations: -# - file: "public/javascripts/translations.js" -# only: "*" -# +export_i18n_js: false + translations: - - file: "app/assets/javascripts/i18n/translations.js" + - file: "app/assets/javascripts/i18n/%{locale}.js" + pretty_print: true only: - "*.date" - "*.time" diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 5f8a4de5f..7bd35daf6 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -13,7 +13,7 @@ Rails.application.config.assets.paths << Rails.root.join("config") # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. Rails.application.config.assets.precompile += %w[index.js browse.js welcome.js fixthemap.js] -Rails.application.config.assets.precompile += %w[user.js login.js diary_entry.js messages.js edit/*.js] +Rails.application.config.assets.precompile += %w[user.js login.js diary_entry.js messages.js edit/*.js i18n/*.js] Rails.application.config.assets.precompile += %w[screen-ltr.css print-ltr.css] Rails.application.config.assets.precompile += %w[screen-rtl.css print-rtl.css] Rails.application.config.assets.precompile += %w[leaflet-all.css leaflet.ie.css] diff --git a/config/jshint.yml b/config/jshint.yml index 65996983f..a7e22486b 100644 --- a/config/jshint.yml +++ b/config/jshint.yml @@ -1,6 +1,7 @@ files: - "**/*.js" exclude_paths: + - "app/assets/javascripts/i18n" - "vendor/assets/javascripts" options: eqeqeq: true