@riducms/translations 0.1.5 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/languages/ar.ts +33 -2
- package/src/languages/en.ts +34 -2
- package/src/languages/fr.ts +35 -2
- package/src/runtime.ts +18 -4
- package/src/types.ts +3 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/languages/ar.ts
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
import type { CoreTranslationCatalog, TranslationLanguage } from "../types";
|
|
2
2
|
|
|
3
3
|
export const arMessages = {
|
|
4
|
+
"fields:liveValidationPending": "جارٍ التحقق…",
|
|
5
|
+
"fields:liveValidationFailed": "تعذّر إكمال هذا التحقق.",
|
|
6
|
+
"fields:liveValidationRetry": "إعادة التحقق",
|
|
7
|
+
"fields:liveValidationSkipped": "لا يمكن التحقق من هذه القيمة بعد.",
|
|
8
|
+
"collections:operatorIncludesItem": "يتضمن عنصرًا",
|
|
9
|
+
"fields:listAdd": "إضافة عنصر",
|
|
10
|
+
"fields:listEmpty": "لا توجد عناصر بعد.",
|
|
11
|
+
"fields:listItem": "{label}، العنصر {number}",
|
|
12
|
+
"fields:listMoveUp": "نقل العنصر {number} لأعلى",
|
|
13
|
+
"fields:listMoveDown": "نقل العنصر {number} لأسفل",
|
|
14
|
+
"fields:listRemove": "حذف العنصر {number}",
|
|
15
|
+
"fields:listAdded": "تمت إضافة العنصر {number}.",
|
|
16
|
+
"fields:listRemoved": "تم حذف العنصر {number}.",
|
|
17
|
+
"fields:listMoved": "تم نقل العنصر من {from} إلى {to}.",
|
|
18
|
+
"errors:listMinItems": "يجب أن يحتوي {label} على {count} عناصر على الأقل",
|
|
19
|
+
"errors:listMaxItems": "يجب ألا يحتوي {label} على أكثر من {count} عناصر",
|
|
20
|
+
"errors:listItemString": "{label}، العنصر {number}: أدخل نصًا",
|
|
21
|
+
"errors:listItemNumber": "{label}، العنصر {number}: أدخل عددًا منتهيًا",
|
|
22
|
+
"errors:listItemMinLength": "{label}، العنصر {number}: استخدم {count} أحرف على الأقل",
|
|
23
|
+
"errors:listItemMaxLength": "{label}، العنصر {number}: استخدم {count} أحرف كحد أقصى",
|
|
24
|
+
"errors:listItemMin": "{label}، العنصر {number}: أدخل عددًا لا يقل عن {min}",
|
|
25
|
+
"errors:listItemMax": "{label}، العنصر {number}: أدخل عددًا لا يزيد عن {max}",
|
|
26
|
+
|
|
27
|
+
"fields:embeddedEditTitle": "تعديل الكتلة",
|
|
28
|
+
"fields:embeddedEditDescription": "طبّق التغييرات على المستند أو ألغِ هذا التعديل.",
|
|
29
|
+
"errors:pendingEmbeddedEdit": "طبّق تعديل الكتلة المفتوحة أو ألغِه قبل حفظ هذا المستند.",
|
|
30
|
+
"errors:staleEmbeddedEdit":
|
|
31
|
+
"تغيّرت هذه الكتلة أو المستند أثناء التعديل. ألغِ التعديل وأعد فتح المحرر قبل تطبيق التغييرات.",
|
|
32
|
+
"errors:unknownBlockRecovery":
|
|
33
|
+
"يحتوي هذا المستند على نوع كتلة لم يعد مُعدًّا. تم الاحتفاظ بالمحتوى. استعد مخطط الكتلة أو رحّل المستند قبل الحفظ.",
|
|
34
|
+
"fields:rowErrors": "{count} أخطاء تحقق",
|
|
4
35
|
"account:account": "الحساب",
|
|
5
36
|
"account:accountMenu": "إعدادات الحساب",
|
|
6
37
|
"account:accountMenuLabel": "فتح قائمة الحساب لـ {name}",
|
|
@@ -613,7 +644,7 @@ export const arMessages = {
|
|
|
613
644
|
"errors:required": "هذا الحقل مطلوب.",
|
|
614
645
|
"errors:save": "تعذر حفظ التغييرات.",
|
|
615
646
|
"errors:unknown": "حدث خطأ ما.",
|
|
616
|
-
"errors:
|
|
647
|
+
"errors:allowedOption": "{label} ليس خيارًا مسموحًا به",
|
|
617
648
|
"errors:array": "يجب أن يكون {label} مصفوفة",
|
|
618
649
|
"errors:blockObject": "يجب أن تكون الكتلة كائنًا",
|
|
619
650
|
"errors:blockType": "نوع الكتلة غير مسموح به",
|
|
@@ -640,7 +671,7 @@ export const arMessages = {
|
|
|
640
671
|
"errors:clipboardRow": "بيانات الحافظة غير متوافقة مع هذا الصف",
|
|
641
672
|
"errors:clipboardRows": "بيانات الحافظة ليست مجموعة صفوف",
|
|
642
673
|
"errors:correctInvalidFields": "الرجاء تصحيح الحقول غير الصالحة.",
|
|
643
|
-
"errors:
|
|
674
|
+
"errors:duplicateOption": "يجب ألا يحتوي {label} على خيارات مكررة",
|
|
644
675
|
"errors:fieldRequired": "{label} مطلوبة",
|
|
645
676
|
"errors:finiteNumber": "يجب أن يكون {label} عددًا محدودًا",
|
|
646
677
|
"errors:maxRows": {
|
package/src/languages/en.ts
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import type { TranslationMessage } from "../types";
|
|
2
2
|
|
|
3
3
|
export const enMessages = {
|
|
4
|
+
"fields:liveValidationPending": "Checking…",
|
|
5
|
+
"fields:liveValidationFailed": "This check could not be completed.",
|
|
6
|
+
"fields:liveValidationRetry": "Retry check",
|
|
7
|
+
"fields:liveValidationSkipped": "This input could not be checked yet.",
|
|
8
|
+
"collections:operatorIncludesItem": "Includes item",
|
|
9
|
+
"fields:listAdd": "Add item",
|
|
10
|
+
"fields:listEmpty": "No items yet.",
|
|
11
|
+
"fields:listItem": "{label}, item {number}",
|
|
12
|
+
"fields:listMoveUp": "Move item {number} up",
|
|
13
|
+
"fields:listMoveDown": "Move item {number} down",
|
|
14
|
+
"fields:listRemove": "Remove item {number}",
|
|
15
|
+
"fields:listAdded": "Added item {number}.",
|
|
16
|
+
"fields:listRemoved": "Removed item {number}.",
|
|
17
|
+
"fields:listMoved": "Moved item {from} to {to}.",
|
|
18
|
+
"errors:listMinItems": "{label} must contain at least {count} items",
|
|
19
|
+
"errors:listMaxItems": "{label} must contain no more than {count} items",
|
|
20
|
+
"errors:listItemString": "{label}, item {number}: enter a string",
|
|
21
|
+
"errors:listItemNumber": "{label}, item {number}: enter a finite number",
|
|
22
|
+
"errors:listItemMinLength": "{label}, item {number}: use at least {count} characters",
|
|
23
|
+
"errors:listItemMaxLength": "{label}, item {number}: use no more than {count} characters",
|
|
24
|
+
"errors:listItemMin": "{label}, item {number}: enter a number at least {min}",
|
|
25
|
+
"errors:listItemMax": "{label}, item {number}: enter a number no greater than {max}",
|
|
26
|
+
|
|
27
|
+
"errors:unknownBlockRecovery":
|
|
28
|
+
"This document contains a block type that is no longer configured. Its content is preserved. Restore the block schema or migrate the document before saving.",
|
|
29
|
+
"fields:rowErrors": "{count} validation errors",
|
|
4
30
|
"account:account": "Account",
|
|
5
31
|
"account:accountMenu": "Account settings",
|
|
6
32
|
"account:accountMenuLabel": "Open account menu for {name}",
|
|
@@ -556,7 +582,7 @@ export const enMessages = {
|
|
|
556
582
|
"errors:required": "This field is required.",
|
|
557
583
|
"errors:save": "The changes could not be saved.",
|
|
558
584
|
"errors:unknown": "Something went wrong.",
|
|
559
|
-
"errors:
|
|
585
|
+
"errors:allowedOption": "{label} is not an allowed option",
|
|
560
586
|
"errors:array": "{label} must be an array",
|
|
561
587
|
"errors:blockObject": "Block must be an object",
|
|
562
588
|
"errors:blockType": "Block type is not allowed",
|
|
@@ -575,7 +601,7 @@ export const enMessages = {
|
|
|
575
601
|
"errors:clipboardRow": "Clipboard data is not compatible with this row",
|
|
576
602
|
"errors:clipboardRows": "Clipboard data is not a row collection",
|
|
577
603
|
"errors:correctInvalidFields": "Please correct the invalid fields.",
|
|
578
|
-
"errors:
|
|
604
|
+
"errors:duplicateOption": "{label} must not contain duplicate options",
|
|
579
605
|
"errors:fieldRequired": "{label} is required",
|
|
580
606
|
"errors:finiteNumber": "{label} must be a finite number",
|
|
581
607
|
"errors:maxRows": {
|
|
@@ -695,6 +721,12 @@ export const enMessages = {
|
|
|
695
721
|
"fields:upload": "upload",
|
|
696
722
|
"general:add": "Add",
|
|
697
723
|
"general:apply": "Apply",
|
|
724
|
+
"fields:embeddedEditTitle": "Edit block",
|
|
725
|
+
"fields:embeddedEditDescription": "Apply changes to the document or cancel this edit.",
|
|
726
|
+
"errors:pendingEmbeddedEdit":
|
|
727
|
+
"Apply or cancel the open block editor before saving this document.",
|
|
728
|
+
"errors:staleEmbeddedEdit":
|
|
729
|
+
"This block or document changed while its editor was open. Cancel and reopen it before applying changes.",
|
|
698
730
|
"general:back": "Back",
|
|
699
731
|
"general:bulkActions": "Bulk actions",
|
|
700
732
|
"general:cancel": "Cancel",
|
package/src/languages/fr.ts
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
import type { CoreTranslationCatalog } from "../types";
|
|
2
2
|
|
|
3
3
|
export const frMessages = {
|
|
4
|
+
"fields:liveValidationPending": "Vérification…",
|
|
5
|
+
"fields:liveValidationFailed": "Cette vérification n’a pas pu aboutir.",
|
|
6
|
+
"fields:liveValidationRetry": "Réessayer",
|
|
7
|
+
"fields:liveValidationSkipped": "Cette valeur ne peut pas encore être vérifiée.",
|
|
8
|
+
"collections:operatorIncludesItem": "Contient un élément",
|
|
9
|
+
"fields:listAdd": "Ajouter un élément",
|
|
10
|
+
"fields:listEmpty": "Aucun élément.",
|
|
11
|
+
"fields:listItem": "{label}, élément {number}",
|
|
12
|
+
"fields:listMoveUp": "Monter l’élément {number}",
|
|
13
|
+
"fields:listMoveDown": "Descendre l’élément {number}",
|
|
14
|
+
"fields:listRemove": "Supprimer l’élément {number}",
|
|
15
|
+
"fields:listAdded": "Élément {number} ajouté.",
|
|
16
|
+
"fields:listRemoved": "Élément {number} supprimé.",
|
|
17
|
+
"fields:listMoved": "Élément déplacé de {from} à {to}.",
|
|
18
|
+
"errors:listMinItems": "{label} doit contenir au moins {count} éléments",
|
|
19
|
+
"errors:listMaxItems": "{label} doit contenir au maximum {count} éléments",
|
|
20
|
+
"errors:listItemString": "{label}, élément {number} : saisissez du texte",
|
|
21
|
+
"errors:listItemNumber": "{label}, élément {number} : saisissez un nombre fini",
|
|
22
|
+
"errors:listItemMinLength": "{label}, élément {number} : utilisez au moins {count} caractères",
|
|
23
|
+
"errors:listItemMaxLength": "{label}, élément {number} : utilisez au maximum {count} caractères",
|
|
24
|
+
"errors:listItemMin": "{label}, élément {number} : saisissez un nombre supérieur ou égal à {min}",
|
|
25
|
+
"errors:listItemMax": "{label}, élément {number} : saisissez un nombre inférieur ou égal à {max}",
|
|
26
|
+
|
|
27
|
+
"fields:embeddedEditTitle": "Modifier le bloc",
|
|
28
|
+
"fields:embeddedEditDescription":
|
|
29
|
+
"Appliquez les modifications au document ou annulez cette modification.",
|
|
30
|
+
"errors:pendingEmbeddedEdit":
|
|
31
|
+
"Appliquez ou annulez la modification du bloc ouvert avant d’enregistrer ce document.",
|
|
32
|
+
"errors:staleEmbeddedEdit":
|
|
33
|
+
"Ce bloc ou document a changé pendant la modification. Annulez et rouvrez-le avant d’appliquer les modifications.",
|
|
34
|
+
"errors:unknownBlockRecovery":
|
|
35
|
+
"Ce document contient un type de bloc qui n’est plus configuré. Son contenu est conservé. Restaurez le schéma du bloc ou migrez le document avant de l’enregistrer.",
|
|
36
|
+
"fields:rowErrors": "{count} erreurs de validation",
|
|
4
37
|
"account:account": "Compte",
|
|
5
38
|
"account:accountMenu": "Paramètres du compte",
|
|
6
39
|
"account:accountMenuLabel": "Ouvrir le menu du compte de {name}",
|
|
@@ -574,7 +607,7 @@ export const frMessages = {
|
|
|
574
607
|
"errors:required": "Ce champ est obligatoire.",
|
|
575
608
|
"errors:save": "Impossible d’enregistrer les modifications.",
|
|
576
609
|
"errors:unknown": "Une erreur est survenue.",
|
|
577
|
-
"errors:
|
|
610
|
+
"errors:allowedOption": "{label} ne fait pas partie des choix autorisés",
|
|
578
611
|
"errors:array": "{label} doit être un tableau",
|
|
579
612
|
"errors:blockObject": "Le bloc doit être un objet",
|
|
580
613
|
"errors:blockType": "Ce type de bloc n’est pas autorisé",
|
|
@@ -594,7 +627,7 @@ export const frMessages = {
|
|
|
594
627
|
"errors:clipboardRow": "Les données du presse-papiers ne sont pas compatibles avec cette ligne",
|
|
595
628
|
"errors:clipboardRows": "Les données du presse-papiers ne constituent pas un ensemble de lignes",
|
|
596
629
|
"errors:correctInvalidFields": "Corrigez les champs non valides.",
|
|
597
|
-
"errors:
|
|
630
|
+
"errors:duplicateOption": "{label} ne doit pas contenir de choix en double",
|
|
598
631
|
"errors:fieldRequired": "{label} est obligatoire",
|
|
599
632
|
"errors:finiteNumber": "{label} doit être un nombre fini",
|
|
600
633
|
"errors:maxRows": {
|
package/src/runtime.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface CreateAdminI18nOptions {
|
|
|
14
14
|
language?: string;
|
|
15
15
|
fallbackLanguage?: string;
|
|
16
16
|
timeZone?: string;
|
|
17
|
+
applicationMessages?: PluginMessageCatalog;
|
|
17
18
|
pluginMessages?: Readonly<Record<string, PluginMessageCatalog>>;
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -56,6 +57,8 @@ export function createAdminI18n(options: CreateAdminI18nOptions = {}): AdminI18n
|
|
|
56
57
|
const pluralRules = new Intl.PluralRules(active.code);
|
|
57
58
|
const numberFormat = new Intl.NumberFormat(active.code);
|
|
58
59
|
const plugins = options.pluginMessages ?? {};
|
|
60
|
+
if (options.applicationMessages !== undefined)
|
|
61
|
+
validatePluginMessageCatalog("application", options.applicationMessages);
|
|
59
62
|
for (const [pluginKey, catalog] of Object.entries(plugins)) {
|
|
60
63
|
validatePluginMessageCatalog(pluginKey, catalog);
|
|
61
64
|
}
|
|
@@ -66,10 +69,12 @@ export function createAdminI18n(options: CreateAdminI18nOptions = {}): AdminI18n
|
|
|
66
69
|
text: (canonical, translations) =>
|
|
67
70
|
translations?.[active.code] ?? translations?.[fallback.code] ?? canonical,
|
|
68
71
|
t: (key, variables) => {
|
|
69
|
-
const message = key.startsWith("
|
|
70
|
-
?
|
|
71
|
-
: (
|
|
72
|
-
|
|
72
|
+
const message = key.startsWith("app:")
|
|
73
|
+
? catalogMessage(options.applicationMessages, key.slice(4), active.code, fallback.code)
|
|
74
|
+
: key.startsWith("plugin.")
|
|
75
|
+
? pluginMessage(plugins, key, active.code, fallback.code)
|
|
76
|
+
: (active.messages[key as keyof CoreTranslationCatalog] ??
|
|
77
|
+
fallback.messages[key as keyof CoreTranslationCatalog]);
|
|
73
78
|
if (message === undefined) throw new Error(`Missing admin translation ${key}.`);
|
|
74
79
|
return interpolate(
|
|
75
80
|
selectMessage(message, variables, pluralRules),
|
|
@@ -372,6 +377,15 @@ function pluginMessage(
|
|
|
372
377
|
const namespace = key.slice("plugin.".length, separator);
|
|
373
378
|
const localKey = key.slice(separator + 1);
|
|
374
379
|
const catalog = plugins[namespace];
|
|
380
|
+
return catalogMessage(catalog, localKey, language, fallbackLanguage);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function catalogMessage(
|
|
384
|
+
catalog: PluginMessageCatalog | undefined,
|
|
385
|
+
localKey: string,
|
|
386
|
+
language: string,
|
|
387
|
+
fallbackLanguage: string
|
|
388
|
+
): TranslationMessage | undefined {
|
|
375
389
|
return (
|
|
376
390
|
catalog?.translations?.[language]?.[localKey] ??
|
|
377
391
|
catalog?.translations?.[fallbackLanguage]?.[localKey] ??
|
package/src/types.ts
CHANGED
|
@@ -7,7 +7,9 @@ export type CoreTranslationKey = keyof typeof enMessages;
|
|
|
7
7
|
export type CoreTranslationCatalog = Readonly<Record<CoreTranslationKey, TranslationMessage>>;
|
|
8
8
|
export type TranslationVariables = Readonly<Record<string, string | number>>;
|
|
9
9
|
export type PluginTranslationKey = `plugin.${string}:${string}`;
|
|
10
|
-
export type
|
|
10
|
+
export type ApplicationTranslationKey = `app:${string}`;
|
|
11
|
+
export type ExtensionTranslationKey = PluginTranslationKey | ApplicationTranslationKey;
|
|
12
|
+
export type AdminTranslationKey = CoreTranslationKey | ExtensionTranslationKey;
|
|
11
13
|
|
|
12
14
|
export interface TranslationLanguage {
|
|
13
15
|
code: string;
|