Skip to content

Commit

Permalink
Initialize I18n and OSM as soon as application.js loads
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Jan 23, 2025
1 parent e310767 commit d81243d
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@
//= require richtext
//= require qs/dist/qs

(() => {
const application_data = $("head").data();

I18n.default_locale = OSM.DEFAULT_LOCALE;
I18n.locale = application_data.locale;
I18n.fallbacks = true;

OSM.preferred_editor = application_data.preferredEditor;
OSM.preferred_languages = application_data.preferredLanguages;

if (application_data.user) {
OSM.user = application_data.user;

if (application_data.userHome) {
OSM.home = application_data.userHome;
}
}

if (application_data.location) {
OSM.location = application_data.location;
}
})();

/*
* Called as the user scrolls/zooms around to manipulate hrefs of the
* view tab and various other links
Expand Down Expand Up @@ -122,27 +145,6 @@ $(document).ready(function () {
$("header").toggleClass("closed");
});

var application_data = $("head").data();

I18n.default_locale = OSM.DEFAULT_LOCALE;
I18n.locale = application_data.locale;
I18n.fallbacks = true;

OSM.preferred_editor = application_data.preferredEditor;
OSM.preferred_languages = application_data.preferredLanguages;

if (application_data.user) {
OSM.user = application_data.user;

if (application_data.userHome) {
OSM.home = application_data.userHome;
}
}

if (application_data.location) {
OSM.location = application_data.location;
}

$("#edit_tab")
.attr("title", I18n.t("javascripts.site.edit_disabled_tooltip"));
});

0 comments on commit d81243d

Please sign in to comment.