From c94de1e1a3878d60bfd443b04c7ca608c8dd47b3 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 24 Oct 2023 17:19:32 +0100 Subject: [PATCH 1/1] 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 5bfe86b86..af67244bc 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -124,6 +124,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 e44db9fdf..59c3a8b49 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 28c97e485..2fc0d808d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,7 +48,8 @@ module ApplicationHelper 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 -- 2.39.5