chore(locale): added custom messages rule for English ordinal numbers

This commit is contained in:
2026-04-22 01:57:31 +02:00
parent 104a094fd8
commit cda1516424
4 changed files with 37 additions and 25 deletions
@@ -31,11 +31,12 @@
<ul v-else-if="bestScoreList.length > 0"> <ul v-else-if="bestScoreList.length > 0">
<li v-for="(value, i) in bestScoreList"> <li v-for="(value, i) in bestScoreList">
<div> <div>
{{ t('scenery.top-list.place', i + 1) }} - {{ t('ordinal', { count: i + 1 }) }} {{ t('scenery.top-list.place') }} -
<router-link :to="`/profile?playerId=${value.dispatcherId}`">{{ <router-link :to="`/profile?playerId=${value.dispatcherId}`">{{
value.dispatcherName value.dispatcherName
}}</router-link> }}</router-link>
</div> </div>
<div> <div>
<b class="text--primary" v-if="currentListMode == 'dutyCount'">{{ <b class="text--primary" v-if="currentListMode == 'dutyCount'">{{
t('scenery.top-list.duty-count', value.value) t('scenery.top-list.duty-count', value.value)
+33 -22
View File
@@ -3,25 +3,6 @@ import plLang from './locales/pl.json';
import { createI18n } from 'vue-i18n'; import { createI18n } from 'vue-i18n';
function customRule(choice: number, choicesLength: number) {
if (choice === 0) {
return 0;
}
const teen = choice > 10 && choice < 20;
const endsWithOne = choice % 10 === 1;
if (!teen && endsWithOne) {
return 1;
}
if (!teen && choice % 10 >= 2 && choice % 10 <= 4) {
return 2;
}
return choicesLength < 4 ? 2 : 3;
}
const i18n = createI18n({ const i18n = createI18n({
locale: 'pl', locale: 'pl',
legacy: false, legacy: false,
@@ -29,12 +10,42 @@ const i18n = createI18n({
fallbackLocale: 'pl', fallbackLocale: 'pl',
pluralizationRules: { pluralizationRules: {
pl: customRule en: {
ordinal: (ctx: { named: (arg0: string) => number }) => {
const number = ctx.named('count');
const suffixes: Record<number, string> = {
1: 'st',
2: 'nd',
3: 'rd'
};
const suffix = suffixes[number % 10] || 'th';
return `${number}${suffix}`;
}
}
}, },
messages: { messages: {
en: enLang, en: {
pl: plLang ...enLang,
ordinal: (ctx: { named: (arg0: string) => number }) => {
const number = ctx.named('count');
const suffixes: Record<number, string> = {
1: 'st',
2: 'nd',
3: 'rd'
};
const suffix = suffixes[number % 10] || 'th';
return `${number}${suffix}`;
}
},
pl: {
...plLang,
ordinal: '{count}.'
}
}, },
enableLegacy: false enableLegacy: false
}); });
+1 -1
View File
@@ -603,7 +603,7 @@
"scope-name": "GENERAL", "scope-name": "GENERAL",
"scope-hash": "CURRENT HASH", "scope-hash": "CURRENT HASH",
"place": "{n}. place", "place": "place",
"dispatcher-rating": "Rating: {n}", "dispatcher-rating": "Rating: {n}",
"duty-count": "No duties | 1 duty | Duties: {n}", "duty-count": "No duties | 1 duty | Duties: {n}",
"duration": "Duration:", "duration": "Duration:",
+1 -1
View File
@@ -589,7 +589,7 @@
"scope-name": "OGÓLNIE", "scope-name": "OGÓLNIE",
"scope-hash": "OBECNY HASH", "scope-hash": "OBECNY HASH",
"place": "{n}. miejsce", "place": "miejsce",
"dispatcher-rating": "Ocena: {n}", "dispatcher-rating": "Ocena: {n}",
"duty-count": "Brak dyżurów | 1 dyżur | Dyżury: {n}", "duty-count": "Brak dyżurów | 1 dyżur | Dyżury: {n}",
"duration": "Czas:", "duration": "Czas:",