Skip to content

Commit

Permalink
add support for RTL
Browse files Browse the repository at this point in the history
  • Loading branch information
zdila committed Feb 6, 2025
1 parent e90482f commit 4931b9c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion app/assets/javascripts/leaflet.map.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ L.extend(L.LatLngBounds.prototype, {
});

if (OSM.MAPTILER_KEY) {
maplibregl.setRTLTextPlugin(
"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js",
true
);

L.OpenMapTiles = L.MaplibreGL.extend({
options: {
maxZoom: 23,
Expand All @@ -30,7 +35,7 @@ if (OSM.MAPTILER_KEY) {
} else {
var mainLocale = I18n.locale.slice(0, 2);
var localeIndex = supportedLanguages.findIndex(function (locale) {
return locale.slice(0, 2) === mainLocale;
return locale === mainLocale;
});
if (localeIndex > -1) {
language = supportedLanguages[localeIndex];
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def map_layout
policy.connect_src(*policy.connect_src, "http://127.0.0.1:8111", Settings.maptiler_url, Settings.nominatim_url, Settings.overpass_url, Settings.fossgis_osrm_url, Settings.graphhopper_url, Settings.fossgis_valhalla_url)
policy.form_action(*policy.form_action, "render.openstreetmap.org")
policy.style_src(*policy.style_src, :unsafe_inline)
policy.script_src(*policy.script_src, "https://api.mapbox.com", :unsafe_eval)

request.content_security_policy = policy

Expand Down
3 changes: 2 additions & 1 deletion config/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = [
OSM: "writable",
Matomo: "readonly",
Turbo: "readonly",
updateLinks: "readonly"
updateLinks: "readonly",
maplibregl: "readonly"
}
},
linterOptions: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"dependencies": {
"@maplibre/maplibre-gl-leaflet": "^0.0.22",
"@maptiler/maplibre-gl-omt-language": "^0.0.2",
"@maptiler/maplibre-gl-omt-language": "^0.0.3",
"jquery-simulate": "^1.0.2",
"js-cookie": "^3.0.0",
"leaflet": "^1.8.0",
Expand Down

0 comments on commit 4931b9c

Please sign in to comment.