Load pluralizers

This commit is contained in:
Anton Khorev 2025-02-11 18:25:16 +03:00
parent b8b9c3d1e9
commit 248b5fa1ae
4 changed files with 16 additions and 1 deletions

View file

@ -11,16 +11,24 @@
//= require leaflet.zoom
//= require leaflet.locationfilter
//= require i18n
//= require make-plural/cardinals
//= require matomo
//= require richtext
{
const application_data = $("head").data();
const locale = application_data.locale;
I18n.default_locale = OSM.DEFAULT_LOCALE;
I18n.locale = application_data.locale;
I18n.locale = locale;
I18n.fallbacks = true;
// '-' are replaced with '_' in https://github.com/eemeli/make-plural/tree/main/packages/plurals
const pluralizer = plurals[locale.replace(/\W+/g, "_")] || plurals[locale.split("-")[0]];
if (pluralizer) {
I18n.pluralization[locale] = (count) => [pluralizer(count), "other"];
}
OSM.preferred_editor = application_data.preferredEditor;
OSM.preferred_languages = application_data.preferredLanguages;

View file

@ -30,6 +30,7 @@ export default [
Matomo: "readonly",
OSM: "writable",
Turbo: "readonly",
plurals: "readonly",
updateLinks: "readonly"
}
},

View file

@ -6,6 +6,7 @@
"js-cookie": "^3.0.0",
"leaflet": "^1.8.0",
"leaflet.locatecontrol": "^0.83.0",
"make-plural": "^7.4.0",
"osm-community-index": "^5.2.0"
},
"devDependencies": {

View file

@ -509,6 +509,11 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
make-plural@^7.4.0:
version "7.4.0"
resolved "https://registry.yarnpkg.com/make-plural/-/make-plural-7.4.0.tgz#fa6990dd550dea4de6b20163f74e5ed83d8a8d6d"
integrity sha512-4/gC9KVNTV6pvYg2gFeQYTW3mWaoJt7WZE5vrp1KnQDgW92JtYZnzmZT81oj/dUTqAIu0ufI2x3dkgu3bB1tYg==
minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"