- {{ t('scenery.top-list.place', i + 1) }} -
+ {{ t('ordinal', { count: i + 1 }) }} {{ t('scenery.top-list.place') }} -
{{
value.dispatcherName
}}
+
{{
t('scenery.top-list.duty-count', value.value)
diff --git a/src/i18n.ts b/src/i18n.ts
index fa46716..a90be72 100644
--- a/src/i18n.ts
+++ b/src/i18n.ts
@@ -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 = {
+ 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 = {
+ 1: 'st',
+ 2: 'nd',
+ 3: 'rd'
+ };
+ const suffix = suffixes[number % 10] || 'th';
+
+ return `${number}${suffix}`;
+ }
+ },
+ pl: {
+ ...plLang,
+ ordinal: '{count}.'
+ }
},
enableLegacy: false
});
diff --git a/src/locales/en.json b/src/locales/en.json
index cbd635e..ac718ac 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -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:",
diff --git a/src/locales/pl.json b/src/locales/pl.json
index 19bff68..9a05ebd 100644
--- a/src/locales/pl.json
+++ b/src/locales/pl.json
@@ -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:",