mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
chore(locale): added custom messages rule for English ordinal numbers
This commit is contained in:
@@ -31,11 +31,12 @@
|
||||
<ul v-else-if="bestScoreList.length > 0">
|
||||
<li v-for="(value, i) in bestScoreList">
|
||||
<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}`">{{
|
||||
value.dispatcherName
|
||||
}}</router-link>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<b class="text--primary" v-if="currentListMode == 'dutyCount'">{{
|
||||
t('scenery.top-list.duty-count', value.value)
|
||||
|
||||
+33
-22
@@ -3,25 +3,6 @@ import plLang from './locales/pl.json';
|
||||
|
||||
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({
|
||||
locale: 'pl',
|
||||
legacy: false,
|
||||
@@ -29,12 +10,42 @@ const i18n = createI18n({
|
||||
fallbackLocale: 'pl',
|
||||
|
||||
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: {
|
||||
en: enLang,
|
||||
pl: plLang
|
||||
en: {
|
||||
...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
|
||||
});
|
||||
|
||||
+1
-1
@@ -603,7 +603,7 @@
|
||||
"scope-name": "GENERAL",
|
||||
"scope-hash": "CURRENT HASH",
|
||||
|
||||
"place": "{n}. place",
|
||||
"place": "place",
|
||||
"dispatcher-rating": "Rating: {n}",
|
||||
"duty-count": "No duties | 1 duty | Duties: {n}",
|
||||
"duration": "Duration:",
|
||||
|
||||
+1
-1
@@ -589,7 +589,7 @@
|
||||
"scope-name": "OGÓLNIE",
|
||||
"scope-hash": "OBECNY HASH",
|
||||
|
||||
"place": "{n}. miejsce",
|
||||
"place": "miejsce",
|
||||
"dispatcher-rating": "Ocena: {n}",
|
||||
"duty-count": "Brak dyżurów | 1 dyżur | Dyżury: {n}",
|
||||
"duration": "Czas:",
|
||||
|
||||
Reference in New Issue
Block a user