Skip to content

Commit

Permalink
Improve name selection with the query tool
Browse files Browse the repository at this point in the history
Pass the full expanded list of preferred languages to the client
and use that when looking for the best name for an object.

Fixes openstreetmap#4310
  • Loading branch information
tomhughes committed Oct 24, 2023
1 parent 0de0317 commit 5067c08
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/index/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]]) {
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5067c08

Please sign in to comment.