From 5067c08b82b46909173a92a680e774fdb03eb204 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 24 Oct 2023 17:19:32 +0100 Subject: [PATCH] Improve name selection with the query tool Pass the full expanded list of preferred languages to the client and use that when looking for the best name for an object. Fixes #4310 --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/index/query.js | 2 +- app/helpers/application_helper.rb | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f3ca5f37f46..d6e3708e7fa 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -132,6 +132,7 @@ $(document).ready(function () { I18n.fallbacks = true; OSM.preferred_editor = application_data.preferredEditor; + OSM.preferred_languages = application_data.preferredLanguages; if (application_data.user) { OSM.user = application_data.user; diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index e44db9fdf0d..59c3a8b495c 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -125,7 +125,7 @@ OSM.Query = function (map) { function featureName(feature) { var tags = feature.tags, - locales = I18n.locales.get(); + locales = OSM.preferred_languages; for (var i = 0; i < locales.length; i++) { if (tags["name:" + locales[i]]) { diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 28c97e485f3..2fc0d808d53 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,7 +48,8 @@ def current_page_class(path) def application_data data = { :locale => I18n.locale, - :preferred_editor => preferred_editor + :preferred_editor => preferred_editor, + :preferred_languages => preferred_languages.expand.map(&:to_s) } if current_user