From: Anton Khorev Date: Sun, 30 Jun 2024 01:51:43 +0000 (+0300) Subject: Set i18n locale before writing "report a problem" on embed page X-Git-Tag: live~328^2 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/adabf84fe6e43af7905dfa2f6148390438d11ed8 Set i18n locale before writing "report a problem" on embed page --- diff --git a/app/assets/javascripts/embed.js.erb b/app/assets/javascripts/embed.js.erb index 4ebb89da9..9a0ec07d3 100644 --- a/app/assets/javascripts/embed.js.erb +++ b/app/assets/javascripts/embed.js.erb @@ -5,13 +5,13 @@ //= require i18n //= require i18n/embed -window.onload = function () { - if (navigator.languages) { - I18n.locale = navigator.languages[0]; - } else if (navigator.language) { - I18n.locale = navigator.language; - } +if (navigator.languages) { + I18n.locale = navigator.languages[0]; +} else if (navigator.language) { + I18n.locale = navigator.language; +} +window.onload = function () { var query = (window.location.search || '?').slice(1), args = {}; diff --git a/test/system/embed_test.rb b/test/system/embed_test.rb new file mode 100644 index 000000000..6003c6f4a --- /dev/null +++ b/test/system/embed_test.rb @@ -0,0 +1,19 @@ +require "application_system_test_case" + +class EmbedTest < ApplicationSystemTestCase + test "shows localized report link" do + visit export_embed_path + assert_link "Report a problem" + end +end + +class GermanEmbedTest < ApplicationSystemTestCase + driven_by :selenium, :using => :headless_firefox, :options => { :name => :selenium_de } do |options| + options.add_preference("intl.accept_languages", "de") + end + + test "shows localized report link" do + visit export_embed_path + assert_link "Ein Problem melden" + end +end