From: Tom Hughes Date: Tue, 24 Oct 2023 16:19:32 +0000 (+0100) Subject: Improve name selection with the query tool X-Git-Tag: live~1048^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/c94de1e1a3878d60bfd443b04c7ca608c8dd47b3?ds=inline;hp=--cc 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 --- c94de1e1a3878d60bfd443b04c7ca608c8dd47b3 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