diff --git a/packages/common-types/access-ref/schema.ts b/packages/common-types/access-ref/schema.ts
index d37c913b..f4a60f7d 100644
--- a/packages/common-types/access-ref/schema.ts
+++ b/packages/common-types/access-ref/schema.ts
@@ -20,7 +20,7 @@ export default {
},
oneOf: [
{
- title: "Un membre de l'organisation",
+ title: 'An organization member',
'x-i18n-title': {
fr: "Un membre de l'organisation",
en: 'An organization member',
@@ -37,7 +37,7 @@ export default {
type: { type: 'string', const: 'user' },
id: {
type: 'string',
- title: 'Membre',
+ title: 'Member',
'x-i18n-title': {
fr: 'Membre',
en: 'Member',
@@ -59,7 +59,7 @@ export default {
}
},
{
- title: 'Un email',
+ title: 'An email',
'x-i18n-title': {
fr: 'Un email',
en: 'An email',
@@ -76,7 +76,7 @@ export default {
email: {
type: 'string',
format: 'email',
- title: 'Adresse mail',
+ title: 'Email address',
'x-i18n-title': {
fr: 'Adresse mail',
en: 'Email address',
@@ -89,7 +89,7 @@ export default {
}
},
{
- title: 'Une organisation partenaire',
+ title: 'A partner organization',
'x-i18n-title': {
fr: 'Une organisation partenaire',
en: 'A partner organization',
@@ -108,7 +108,7 @@ export default {
roles: { type: 'array', const: [], items: { type: 'string' } },
id: {
type: 'string',
- title: 'Partenaire',
+ title: 'Partner',
'x-i18n-title': {
fr: 'Partenaire',
en: 'Partner',
@@ -130,7 +130,7 @@ export default {
}
},
{
- title: 'Un role ou département de mon organisation',
+ title: 'A role or department of my organization',
'x-i18n-title': {
fr: 'Un rôle ou département de mon organisation',
en: 'A role or department of my organization',
@@ -154,7 +154,7 @@ export default {
},
department: {
type: 'string',
- title: 'Département',
+ title: 'Department',
'x-i18n-title': {
fr: 'Département',
en: 'Department',
@@ -174,7 +174,7 @@ export default {
},
roles: {
type: 'array',
- title: 'Rôles',
+ title: 'Roles',
'x-i18n-title': {
fr: 'Rôles',
en: 'Roles',
diff --git a/packages/common-types/notification/schema.ts b/packages/common-types/notification/schema.ts
index 61ffb7da..d756f15c 100644
--- a/packages/common-types/notification/schema.ts
+++ b/packages/common-types/notification/schema.ts
@@ -16,29 +16,30 @@ export default {
},
origin: {
type: 'string',
- title: 'Site d\'origine de la souscription',
+ title: 'Origin site of the subscription',
readOnly: true
},
title: {
type: 'string',
- title: 'Titre'
+ title: 'Title'
},
body: {
type: 'string',
- title: 'Contenu'
+ title: 'Content'
},
htmlBody: {
type: 'string',
- title: 'Contenu HTML'
+ title: 'HTML content'
},
locale: {
type: 'string',
- title: 'Langue de la notification',
- enum: ['fr', 'en']
+ title: 'Language of the notification',
+ description: 'Two letters code: the language of the subscription, any language offered by simple-directory',
+ pattern: '^[a-z]{2}$'
},
icon: {
type: 'string',
- title: 'URL de l\'icone de la notification'
+ title: 'URL of the notification icon'
},
// sender is the owner of the topic, topic is global if no sender is given
sender: { $ref: 'https://github.com/data-fair/lib/event#/$defs/sender' },
@@ -59,21 +60,21 @@ export default {
},
outputs: {
type: 'array',
- title: 'Sorties',
+ title: 'Outputs',
items: {
type: 'string',
oneOf: [{
const: 'devices',
- title: 'recevoir la notification sur vos appareils configurés'
+ title: 'Receive the notification on your configured devices'
}, {
const: 'email',
- title: 'recevoir la notification par email'
+ title: 'Receive the notification by email'
}]
}
},
url: {
type: 'string',
- title: 'défini explicitement ou calculé à partir de subscription.urlTemplate et event.urlParams',
+ title: 'Explicitly defined, or computed from subscription.urlTemplate and event.urlParams',
},
date: {
type: 'string',
@@ -86,7 +87,7 @@ export default {
},
extra: {
type: 'object',
- description: 'propriétés libres qui varient en fonction du type de notification'
+ description: 'Free properties that vary depending on the type of notification'
}
}
}
diff --git a/packages/common-types/theme/schema.ts b/packages/common-types/theme/schema.ts
index 0124d923..4ae6ea24 100644
--- a/packages/common-types/theme/schema.ts
+++ b/packages/common-types/theme/schema.ts
@@ -2,7 +2,7 @@ export default {
$id: 'https://github.com/data-fair/lib/theme',
'x-exports': ['types'],
type: 'object',
- title: 'Thème',
+ title: 'Theme',
'x-i18n-title': {
fr: 'Thème',
en: 'Theme',
@@ -25,7 +25,7 @@ export default {
comp: 'tabs',
if: 'data.assistedMode',
children: [{
- title: 'Thème par défaut',
+ title: 'Default theme',
'x-i18n-title': {
fr: 'Thème par défaut',
en: 'Default theme',
@@ -39,7 +39,7 @@ export default {
{ name: 'colors-preview', cols: { sm: 5, lg: 3 }, props: { colorsKey: 'colors', dark: false } }
]
}, {
- title: 'Thème sombre',
+ title: 'Dark theme',
'x-i18n-title': {
fr: 'Thème sombre',
en: 'Dark theme',
@@ -53,7 +53,7 @@ export default {
{ name: 'colors-preview', cols: { sm: 5, lg: 3 }, props: { colorsKey: 'darkColors', dark: true } }
]
}, {
- title: 'Thème à fort contraste',
+ title: 'High contrast theme',
'x-i18n-title': {
fr: 'Thème à fort contraste',
en: 'High contrast theme',
@@ -67,7 +67,7 @@ export default {
{ name: 'colors-preview', cols: { sm: 5, lg: 3 }, props: { colorsKey: 'hcColors', dark: false } }
]
}, {
- title: 'Thème sombre à fort contraste',
+ title: 'Dark high contrast theme',
'x-i18n-title': {
fr: 'Thème sombre à fort contraste',
en: 'Dark high contrast theme',
@@ -86,7 +86,7 @@ export default {
comp: 'tabs',
if: '!data.assistedMode',
children: [{
- title: 'Thème par défaut',
+ title: 'Default theme',
'x-i18n-title': {
fr: 'Thème par défaut',
en: 'Default theme',
@@ -100,7 +100,7 @@ export default {
{ name: 'colors-preview', cols: { sm: 5, lg: 3 }, props: { colorsKey: 'colors', dark: false } }
]
}, {
- title: 'Thème sombre',
+ title: 'Dark theme',
'x-i18n-title': {
fr: 'Thème sombre',
en: 'Dark theme',
@@ -114,7 +114,7 @@ export default {
{ name: 'colors-preview', cols: { sm: 5, lg: 3 }, props: { colorsKey: 'darkColors', dark: true } }
]
}, {
- title: 'Thème à fort contraste',
+ title: 'High contrast theme',
'x-i18n-title': {
fr: 'Thème à fort contraste',
en: 'High contrast theme',
@@ -128,7 +128,7 @@ export default {
{ name: 'colors-preview', cols: { sm: 5, lg: 3 }, props: { colorsKey: 'hcColors', dark: false } }
]
}, {
- title: 'Thème sombre à fort contraste',
+ title: 'Dark high contrast theme',
'x-i18n-title': {
fr: 'Thème sombre à fort contraste',
en: 'Dark high contrast theme',
@@ -147,7 +147,7 @@ export default {
},
properties: {
logo: {
- title: "URL d'un logo",
+ title: 'Logo URL',
'x-i18n-title': {
fr: "URL d'un logo",
en: 'Logo URL',
@@ -159,7 +159,7 @@ export default {
type: 'string'
},
bodyFontFamily: {
- title: 'Nom de police de caractères pour le corps du texte',
+ title: 'Font name for body text',
'x-i18n-title': {
fr: 'Nom de police de caractères pour le corps du texte',
en: 'Font name for body text',
@@ -168,7 +168,7 @@ export default {
pt: 'Nome da fonte para o texto do corpo',
de: 'Schriftartname für den Fließtext'
},
- description: 'Par défaut une police Nunito auto-hébergée est utilisée',
+ description: 'By default, a self-hosted Nunito font is used',
'x-i18n-description': {
fr: 'Par défaut une police Nunito auto-hébergée est utilisée',
en: 'By default, a self-hosted Nunito font is used',
@@ -180,7 +180,7 @@ export default {
type: 'string'
},
bodyFontFamilyCss: {
- title: 'CSS police de caractères pour le corps du texte',
+ title: 'CSS font for body text',
'x-i18n-title': {
fr: 'CSS police de caractères pour le corps du texte',
en: 'CSS font for body text',
@@ -193,7 +193,7 @@ export default {
comp: 'textarea',
rows: 3
},
- description: 'Vous pouvez copier le CSS proposé par une plateforme comme Google Fonts.',
+ description: 'You can copy the CSS proposed by a platform like Google Fonts.',
'x-i18n-description': {
fr: 'Vous pouvez copier le CSS proposé par une plateforme comme Google Fonts.',
en: 'You can copy the CSS proposed by a platform like Google Fonts.',
@@ -205,7 +205,7 @@ export default {
type: 'string'
},
headingFontFamily: {
- title: 'Nom de police de caractères pour les titres',
+ title: 'Font name for headings',
'x-i18n-title': {
fr: 'Nom de police de caractères pour les titres',
en: 'Font name for headings',
@@ -214,7 +214,7 @@ export default {
pt: 'Nome da fonte para títulos',
de: 'Schriftartname für Überschriften'
},
- description: 'Renseignez de la même manière que pour le corps de texte, ou laissez vide pour utiliser la police du corps du texte',
+ description: 'Fill in the same way as for the body text, or leave blank to use the body text font',
'x-i18n-description': {
fr: 'Renseignez de la même manière que pour le corps de texte, ou laissez vide pour utiliser la police du corps du texte',
en: 'Fill in the same way as for the body text, or leave blank to use the body text font',
@@ -226,7 +226,7 @@ export default {
type: 'string'
},
headingFontFamilyCss: {
- title: 'CSS police de caractères pour les titres',
+ title: 'CSS font for headings',
'x-i18n-title': {
fr: 'CSS police de caractères pour les titres',
en: 'CSS font for headings',
@@ -242,7 +242,7 @@ export default {
type: 'string'
},
preloadLinks: {
- title: 'Liens de préchargement',
+ title: 'Preload links',
'x-i18n-title': {
fr: 'Liens de préchargement',
en: 'Preload links',
@@ -251,7 +251,7 @@ export default {
pt: 'Links de pré-carregamento',
de: 'Vorlade-Links'
},
- description: 'Liste des ressources (polices, etc.) à précharger via des balises . Généralement renseignée automatiquement.',
+ description: 'Resources (fonts, etc.) preloaded through tags. Usually filled automatically.',
type: 'array',
items: {
type: 'object',
@@ -259,16 +259,16 @@ export default {
required: ['href'],
properties: {
href: { type: 'string', title: 'URL' },
- as: { type: 'string', title: 'Type de ressource (attribut as)' },
- type: { type: 'string', title: 'Type MIME' },
- crossorigin: { type: 'boolean', title: 'Requête CORS (crossorigin)' }
+ as: { type: 'string', title: 'Resource type (as attribute)' },
+ type: { type: 'string', title: 'MIME type' },
+ crossorigin: { type: 'boolean', title: 'CORS request (crossorigin)' }
}
},
layout: 'none'
},
assistedMode: {
type: 'boolean',
- title: 'Mode de gestion des couleurs simplifié',
+ title: 'Simplified color management mode',
'x-i18n-title': {
fr: 'Mode de gestion des couleurs simplifié',
en: 'Simplified color management mode',
@@ -277,7 +277,7 @@ export default {
pt: 'Modo de gerenciamento simplificado de cores',
de: 'Vereinfachter Farbverwaltungsmodus'
},
- description: 'Ce mode permet de simplifier la gestion des couleurs. Avec, vous ne renseignez que les couleurs principales (primaire, secondaire, accentuée).\n\nLes autres couleurs sont calculées automatiquement en suivant des règles de contraste pour rester lisibles sur les fonds.\n\n**Attention** : activer ce mode réinitialise les couleurs avancées définies manuellement.',
+ description: 'This mode simplifies color management: you only provide the main colors (primary, secondary, accent).\n\nThe other colors are computed automatically using contrast rules so they remain legible on backgrounds.\n\n**Warning**: enabling this mode resets the advanced colors set manually.',
'x-i18n-description': {
fr: 'Ce mode permet de simplifier la gestion des couleurs. Avec, vous ne renseignez que les couleurs principales (primaire, secondaire, accentuée).\n\nLes autres couleurs sont calculées automatiquement en suivant des règles de contraste pour rester lisibles sur les fonds.\n\n**Attention** : activer ce mode réinitialise les couleurs avancées définies manuellement.',
en: 'This mode simplifies color management: you only provide the main colors (primary, secondary, accent).\n\nThe other colors are computed automatically using contrast rules so they remain legible on backgrounds.\n\n**Warning**: enabling this mode resets the advanced colors set manually.',
@@ -293,7 +293,7 @@ export default {
properties: {
primary: {
type: 'string',
- title: 'Couleur principale',
+ title: 'Primary color',
'x-i18n-title': {
fr: 'Couleur principale',
en: 'Primary color',
@@ -309,7 +309,7 @@ export default {
},
secondary: {
type: 'string',
- title: 'Couleur secondaire',
+ title: 'Secondary color',
'x-i18n-title': {
fr: 'Couleur secondaire',
en: 'Secondary color',
@@ -325,7 +325,7 @@ export default {
},
accent: {
type: 'string',
- title: 'Couleur accentuée',
+ title: 'Accent color',
'x-i18n-title': {
fr: 'Couleur accentuée',
en: 'Accent color',
@@ -344,7 +344,7 @@ export default {
colors: { $ref: '#/$defs/colors' },
dark: {
type: 'boolean',
- title: 'Proposer ce thème aux utilisateurs',
+ title: 'Offer this theme to users',
'x-i18n-title': {
fr: 'Proposer ce thème aux utilisateurs',
en: 'Offer this theme to users',
@@ -357,7 +357,7 @@ export default {
darkColors: { $ref: '#/$defs/colors' },
hc: {
type: 'boolean',
- title: 'Proposer ce thème aux utilisateurs',
+ title: 'Offer this theme to users',
'x-i18n-title': {
fr: 'Proposer ce thème aux utilisateurs',
en: 'Offer this theme to users',
@@ -370,7 +370,7 @@ export default {
hcColors: { $ref: '#/$defs/colors' },
hcDark: {
type: 'boolean',
- title: 'Proposer ce thème aux utilisateurs',
+ title: 'Offer this theme to users',
'x-i18n-title': {
fr: 'Proposer ce thème aux utilisateurs',
en: 'Offer this theme to users',
@@ -411,7 +411,7 @@ export default {
properties: {
background: {
type: 'string',
- title: 'Couleur de fond',
+ title: 'Background color',
'x-i18n-title': {
fr: 'Couleur de fond',
en: 'Background color',
@@ -427,7 +427,7 @@ export default {
},
'on-background': {
type: 'string',
- title: 'Couleur de texte sur couleur de fond',
+ title: 'Text color on background color',
'x-i18n-title': {
fr: 'Couleur de texte sur couleur de fond',
en: 'Text color on background color',
@@ -443,7 +443,7 @@ export default {
},
surface: {
type: 'string',
- title: 'Couleur des surfaces (vignettes, listes, etc)',
+ title: 'Surface color (tiles, lists, etc)',
'x-i18n-title': {
fr: 'Couleur des surfaces (vignettes, listes, etc)',
en: 'Surface color (tiles, lists, etc)',
@@ -459,7 +459,7 @@ export default {
},
'on-surface': {
type: 'string',
- title: 'Couleur de texte sur couleur des surfaces',
+ title: 'Text color on surface color',
'x-i18n-title': {
fr: 'Couleur de texte sur couleur des surfaces',
en: 'Text color on surface color',
@@ -475,7 +475,7 @@ export default {
},
'surface-inverse': {
type: 'string',
- title: 'Couleur des surfaces avec contraste inversé',
+ title: 'Surface color with inverted contrast',
'x-i18n-title': {
fr: 'Couleur des surfaces avec contraste inversé',
en: 'Surface color with inverted contrast',
@@ -491,7 +491,7 @@ export default {
},
'on-surface-inverse': {
type: 'string',
- title: 'Couleur de texte sur couleur des surfaces avec contraste inversé',
+ title: 'Text color on surface color with inverted contrast',
'x-i18n-title': {
fr: 'Couleur de texte sur couleur des surfaces avec contraste inversé',
en: 'Text color on surface color with inverted contrast',
@@ -507,7 +507,7 @@ export default {
},
primary: {
type: 'string',
- title: 'Couleur principale',
+ title: 'Primary color',
'x-i18n-title': {
fr: 'Couleur principale',
en: 'Primary color',
@@ -523,7 +523,7 @@ export default {
},
'on-primary': {
type: 'string',
- title: 'Couleur de texte sur couleur principale',
+ title: 'Text color on primary color',
'x-i18n-title': {
fr: 'Couleur de texte sur couleur principale',
en: 'Text color on primary color',
@@ -539,7 +539,7 @@ export default {
},
'text-primary': {
type: 'string',
- title: 'Couleur de texte principal',
+ title: 'Primary text color',
'x-i18n-title': {
fr: 'Couleur de texte principal',
en: 'Primary text color',
@@ -564,7 +564,7 @@ export default {
},
secondary: {
type: 'string',
- title: 'Couleur secondaire',
+ title: 'Secondary color',
'x-i18n-title': {
fr: 'Couleur secondaire',
en: 'Secondary color',
@@ -580,7 +580,7 @@ export default {
},
'on-secondary': {
type: 'string',
- title: 'Couleur de texte sur couleur secondaire',
+ title: 'Text color on secondary color',
'x-i18n-title': {
fr: 'Couleur de texte sur couleur secondaire',
en: 'Text color on secondary color',
@@ -596,7 +596,7 @@ export default {
},
'text-secondary': {
type: 'string',
- title: 'Couleur de texte secondaire',
+ title: 'Secondary text color',
'x-i18n-title': {
fr: 'Couleur de texte secondaire',
en: 'Secondary text color',
@@ -621,7 +621,7 @@ export default {
},
accent: {
type: 'string',
- title: 'Couleur accentuée',
+ title: 'Accent color',
'x-i18n-title': {
fr: 'Couleur accentuée',
en: 'Accent color',
@@ -637,7 +637,7 @@ export default {
},
'on-accent': {
type: 'string',
- title: 'Couleur de texte sur couleur accentuée',
+ title: 'Text color on accent color',
'x-i18n-title': {
fr: 'Couleur de texte sur couleur accentuée',
en: 'Text color on accent color',
@@ -653,7 +653,7 @@ export default {
},
'text-accent': {
type: 'string',
- title: 'Couleur de texte accentué',
+ title: 'Accent text color',
'x-i18n-title': {
fr: 'Couleur de texte accentué',
en: 'Accent text color',
@@ -678,7 +678,7 @@ export default {
},
info: {
type: 'string',
- title: 'Couleur info',
+ title: 'Info color',
'x-i18n-title': {
fr: 'Couleur info',
en: 'Info color',
@@ -694,7 +694,7 @@ export default {
},
'on-info': {
type: 'string',
- title: 'Couleur de texte sur couleur info',
+ title: 'Text color on info color',
'x-i18n-title': {
fr: 'Couleur de texte sur couleur info',
en: 'Text color on info color',
@@ -710,7 +710,7 @@ export default {
},
'text-info': {
type: 'string',
- title: 'Couleur de texte info',
+ title: 'Info text color',
'x-i18n-title': {
fr: 'Couleur de texte info',
en: 'Info text color',
@@ -735,7 +735,7 @@ export default {
},
error: {
type: 'string',
- title: 'Couleur erreur',
+ title: 'Error color',
'x-i18n-title': {
fr: 'Couleur erreur',
en: 'Error color',
@@ -751,7 +751,7 @@ export default {
},
'on-error': {
type: 'string',
- title: 'Couleur de texte sur couleur erreur',
+ title: 'Text color on error color',
'x-i18n-title': {
fr: 'Couleur de texte sur couleur erreur',
en: 'Text color on error color',
@@ -767,7 +767,7 @@ export default {
},
'text-error': {
type: 'string',
- title: 'Couleur de texte erreur',
+ title: 'Error text color',
'x-i18n-title': {
fr: 'Couleur de texte erreur',
en: 'Error text color',
@@ -792,7 +792,7 @@ export default {
},
warning: {
type: 'string',
- title: 'Couleur avertissement',
+ title: 'Warning color',
'x-i18n-title': {
fr: 'Couleur avertissement',
en: 'Warning color',
@@ -808,7 +808,7 @@ export default {
},
'on-warning': {
type: 'string',
- title: 'Couleur de texte sur avertissement',
+ title: 'Text color on warning color',
'x-i18n-title': {
fr: 'Couleur de texte sur avertissement',
en: 'Text color on warning color',
@@ -824,7 +824,7 @@ export default {
},
'text-warning': {
type: 'string',
- title: 'Couleur de texte avertissement',
+ title: 'Warning text color',
'x-i18n-title': {
fr: 'Couleur de texte avertissement',
en: 'Warning text color',
@@ -849,7 +849,7 @@ export default {
},
success: {
type: 'string',
- title: 'Couleur succès',
+ title: 'Success color',
'x-i18n-title': {
fr: 'Couleur succès',
en: 'Success color',
@@ -865,7 +865,7 @@ export default {
},
'on-success': {
type: 'string',
- title: 'Couleur succès',
+ title: 'Success color',
'x-i18n-title': {
fr: 'Couleur succès',
en: 'Success color',
@@ -881,7 +881,7 @@ export default {
},
'text-success': {
type: 'string',
- title: 'Couleur de texte succès',
+ title: 'Success text color',
'x-i18n-title': {
fr: 'Couleur de texte succès',
en: 'Success text color',
diff --git a/packages/utils/format/bytes.test.ts b/packages/utils/format/bytes.test.ts
new file mode 100644
index 00000000..f428b450
--- /dev/null
+++ b/packages/utils/format/bytes.test.ts
@@ -0,0 +1,13 @@
+import { describe, it } from 'node:test'
+import { strict as assert } from 'assert'
+import { formatBytes } from '@data-fair/lib-utils/format/bytes.js'
+
+describe('formatBytes', () => {
+ it('writes French units by default', () => {
+ assert.equal(formatBytes(1500), (1.5).toLocaleString('fr') + ' ko')
+ })
+ it('writes SI units in English', () => {
+ assert.equal(formatBytes(1500, 'en'), '1.5 kB')
+ assert.equal(formatBytes(25 * 1000 * 1000, 'en'), '25 MB')
+ })
+})
diff --git a/packages/utils/format/bytes.ts b/packages/utils/format/bytes.ts
index 26b228b5..9850f360 100644
--- a/packages/utils/format/bytes.ts
+++ b/packages/utils/format/bytes.ts
@@ -1,6 +1,6 @@
const locales: { fr: [number, string][], en: [number, string][] } = {
fr: [[0, 'octet'], [1, 'octets'], [1000, 'ko'], [1000 * 1000, 'Mo'], [1000 * 1000 * 1000, 'Go'], [1000 * 1000 * 1000 * 1000, 'To'], [1000 * 1000 * 1000 * 1000 * 1000, 'Po']],
- en: [[0, 'byte'], [1, 'bytes'], [1000, 'kb'], [1000 * 1000, 'Mb'], [1000 * 1000 * 1000, 'Gb'], [1000 * 1000 * 1000 * 1000, 'Tb'], [1000 * 1000 * 1000 * 1000 * 1000, 'Pb']]
+ en: [[0, 'byte'], [1, 'bytes'], [1000, 'kB'], [1000 * 1000, 'MB'], [1000 * 1000 * 1000, 'GB'], [1000 * 1000 * 1000 * 1000, 'TB'], [1000 * 1000 * 1000 * 1000 * 1000, 'PB']]
}
export function formatBytes (bytes: number | string, locale = 'fr'): string {
diff --git a/packages/utils/format/field.test.ts b/packages/utils/format/field.test.ts
index 40360bff..b873135c 100644
--- a/packages/utils/format/field.test.ts
+++ b/packages/utils/format/field.test.ts
@@ -55,6 +55,9 @@ describe('formatFieldValue — booleans', () => {
it('leaves a string that is neither true nor false alone', () => {
assert.equal(formatFieldValue(field, 'oui'), 'oui')
})
+ it('falls back on English for a language without labels', () => {
+ assert.equal(formatFieldValue(field, true, { locale: 'de' }), 'Yes')
+ })
})
describe('formatFieldValue — numbers', () => {
@@ -85,6 +88,25 @@ describe('formatFieldValue — dates', () => {
it('falls back to the raw value when the date cannot be parsed', () => {
assert.equal(formatFieldValue(f({ format: 'date' }), 'n/a'), 'n/a')
})
+ it('keeps the French patterns in French, the default', () => {
+ assert.equal(formatFieldValue(f({ format: 'date' }), '2024-01-15', { locale: 'fr' }), '15/01/2024')
+ assert.equal(formatFieldValue(f({ format: 'date-time' }), '2024-01-15T10:00:00+01:00', { locale: 'fr-FR' }), '15/01/2024, 10h00')
+ })
+ it('uses the English localized formats in English', () => {
+ assert.equal(formatFieldValue(f({ format: 'date' }), '2024-01-15', { locale: 'en' }), '01/15/2024')
+ assert.equal(formatFieldValue(f({ format: 'date-time' }), '2024-01-15T10:00:00+01:00', { locale: 'en' }), '01/15/2024 10:00 AM')
+ })
+ it('falls back on the English formats for a language whose dayjs locale is not loaded', () => {
+ assert.equal(formatFieldValue(f({ format: 'date' }), '2024-01-15', { locale: 'de' }), '01/15/2024')
+ })
+ it('uses the formats of a language once its dayjs locale is loaded', async () => {
+ await import('dayjs/locale/es.js')
+ assert.equal(formatFieldValue(f({ format: 'date' }), '2024-01-15', { locale: 'es' }), '15/01/2024')
+ assert.equal(formatFieldValue(f({ format: 'date-time' }), '2024-01-15T10:00:00+01:00', { locale: 'es-ES' }), '15/01/2024 10:00')
+ })
+ it('falls back to the raw value in English too', () => {
+ assert.equal(formatFieldValue(f({ format: 'date' }), 'n/a', { locale: 'en' }), 'n/a')
+ })
})
describe('formatField — backward compatibility', () => {
diff --git a/packages/utils/format/field.ts b/packages/utils/format/field.ts
index 1091da7c..ad5a90ba 100644
--- a/packages/utils/format/field.ts
+++ b/packages/utils/format/field.ts
@@ -1,5 +1,9 @@
import type { Field } from '@data-fair/lib-common-types/application/index.js'
+import dayjs from 'dayjs'
+import localizedFormat from 'dayjs/plugin/localizedFormat.js'
import { dateTimeInOwnTimeZone } from './date-tz.js'
+
+dayjs.extend(localizedFormat)
import { attachmentFilename, webPageLabel } from './attachment.js'
export interface FormatFieldOptions {
@@ -54,19 +58,18 @@ const formatSingleValue = (field: Field, value: unknown, opts: FormatFieldOption
if (concept === 'attachment') return attachmentFilename('' + coerced)
if (concept === 'webPage') return webPageLabel('' + coerced)
- // trigger on `format`, like data-fair's own table does
- // TODO: localize the date patterns. data-fair does not hardcode them either: its
- // ui/src/composables/dataset/format-date-logic.ts takes the dayjs factory as an argument and the
- // caller passes @data-fair/lib-vue's `localeDayjs.dayjs`, so `.format('lll'|'L')` resolves through
- // the localizedFormat plugin. Same move here (an injected factory) rather than a locale table.
+ // trigger on `format`, like data-fair's own table does. French (the default) keeps its historical
+ // patterns; another language reads its dayjs localized formats (L, L LT) when that dayjs locale is loaded
+ // (import 'dayjs/locale/xx.js' to support one), dayjs itself falls back on English otherwise
if (field.format === 'date-time' || field.format === 'date') {
const d = dateTimeInOwnTimeZone(coerced)
if (!d.isValid()) return '' + coerced
- return d.format(field.format === 'date-time' ? 'DD/MM/YYYY, HH[h]mm' : 'DD/MM/YYYY')
+ if (locale.startsWith('fr')) return d.format(field.format === 'date-time' ? 'DD/MM/YYYY, HH[h]mm' : 'DD/MM/YYYY')
+ return d.locale(locale.split('-')[0]).format(field.format === 'date-time' ? 'L LT' : 'L')
}
if (typeof coerced === 'boolean') {
- const [yes, no] = booleanLabels.get(locale.split('-')[0]) ?? booleanLabels.get('fr')!
+ const [yes, no] = booleanLabels.get(locale.split('-')[0]) ?? booleanLabels.get('en')!
return coerced ? yes : no
}
if (typeof coerced === 'number') return coerced.toLocaleString(locale)
diff --git a/packages/vuetify/date-match-filter.vue b/packages/vuetify/date-match-filter.vue
index c9792e73..7a83639b 100644
--- a/packages/vuetify/date-match-filter.vue
+++ b/packages/vuetify/date-match-filter.vue
@@ -13,6 +13,8 @@
color="white"
density="comfortable"
class="mx-1 mt-1"
+ :title="rangeMode ? t('pickRange') : t('pickDate')"
+ :aria-label="rangeMode ? t('pickRange') : t('pickDate')"
v-bind="props"
>
@@ -25,13 +27,13 @@
v-if="rangeMode"
class="text-h6 px-2"
>
- Sélectionnez un interval entre 2 dates
+ {{ t('pickRange') }}
- Sélectionnez une date
+ {{ t('pickDate') }}
+
+ en:
+ pickRange: Select a range between 2 dates
+ pickDate: Select a date
+ fr:
+ pickRange: Sélectionnez un intervalle entre 2 dates
+ pickDate: Sélectionnez une date
+
+