<p></p>
<p><b>@1ec5</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4042#discussion_r1947535076">app/assets/javascripts/leaflet.map.js</a>:</p>
<pre style='color:#555'>> @@ -9,6 +14,43 @@ 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",
</pre>
<p dir="auto">To avoid this external dependency on a Mapbox API, install the <code class="notranslate">@mapbox/mapbox-gl-rtl-text</code> package and have a build script copy node_modules/@mapbox/mapbox-gl-rtl-text/dist/mapbox-gl-rtl-text.js into app/assets/javascripts/. Then this becomes just <code class="notranslate">mapbox-gl-rtl-text.js</code>.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4042#discussion_r1947539667">app/assets/javascripts/leaflet.map.js</a>:</p>
<pre style='color:#555'>> + var mainLocale = I18n.locale.slice(0, 2);
+ var localeIndex = supportedLanguages.findIndex(function (locale) {
+ return locale === mainLocale;
+ });
</pre>
<p dir="auto">This website and maplibre-gl-omt-language both support some locales that have three-character-long language codes, such as <a href="https://github.com/openstreetmap/openstreetmap-website/blob/e206dd527ef7c6d1829f131533d722e536e4bfb5/config/locales/pnb.yml">Western Punjabi</a> (pnb). I don’t think this code will match such locales. If I’m not mistaken, the intention is to match on only the language code and ignore any script or country code. If so, this would be more robust:</p>
⬇️ Suggested change
<pre style="color: #555">- var mainLocale = I18n.locale.slice(0, 2);
- var localeIndex = supportedLanguages.findIndex(function (locale) {
- return locale === mainLocale;
- });
+ var mainLocale = I18n.locale.split('-')[0];
+ var localeIndex = supportedLanguages.findIndex(function (locale) {
+ return locale === mainLocale;
+ });
</pre>
<p dir="auto">Note that this is still quite a rudimentary locale matching heuristic. It won’t match <code class="notranslate">zh-Hans</code> or <code class="notranslate">zh-Hant</code>, which the plugin also supports.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4042#pullrequestreview-2603380276">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLNCMZVQ42SZJI2D6ND2OW4JRAVCNFSM6AAAAAAYLUCIYKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMMBTGM4DAMRXGY">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLLWLZTICQEABXSDFQL2OW4JRA5CNFSM6AAAAAAYLUCIYKWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTU3FRXDI.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/4042/review/2603380276</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/4042#pullrequestreview-2603380276",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4042#pullrequestreview-2603380276",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>