Skip to content

Commit

Permalink
fix: support danish locale (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
imprashast authored Jul 4, 2024
1 parent 18b3223 commit e1e3589
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 16 deletions.
1 change: 1 addition & 0 deletions components/attention/locales/da/messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"attention.aria.callout\":\"En grøn taleboble der introducerer noget nyt\",\"attention.aria.close\":\"Luk\",\"attention.aria.highlight\":\"En opmærksomhedsskabende taleboble med vigtig information\",\"attention.aria.pointingDown\":\"peger nedad\",\"attention.aria.pointingLeft\":\"peger til venstre\",\"attention.aria.pointingRight\":\"peger til højre\",\"attention.aria.pointingUp\":\"peger opad\",\"attention.aria.popover\":\"En hvid taleboble med mere information\",\"attention.aria.tooltip\":\"En sort taleboble med flere oplysninger\"}");
2 changes: 1 addition & 1 deletion components/attention/locales/en/messages.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"attention.aria.callout\":\"callout speech bubble\",\"attention.aria.close\":\"Close\",\"attention.aria.highlight\":\"highlighted speech bubble\",\"attention.aria.pointingDown\":\"pointing down\",\"attention.aria.pointingLeft\":\"pointing left\",\"attention.aria.pointingRight\":\"pointing right\",\"attention.aria.pointingUp\":\"pointing up\",\"attention.aria.popover\":\"popover speech bubble\",\"attention.aria.tooltip\":\"tooltip\"}");
/*eslint-disable*/export const messages=JSON.parse("{\"attention.aria.callout\":\"A green speech bubble introducing something new\",\"attention.aria.close\":\"Close\",\"attention.aria.highlight\":\"An attention speech bubble with important information\",\"attention.aria.pointingDown\":\"pointing down\",\"attention.aria.pointingLeft\":\"pointing left\",\"attention.aria.pointingRight\":\"pointing right\",\"attention.aria.pointingUp\":\"pointing up\",\"attention.aria.popover\":\"A white speech bubble providing additional information\",\"attention.aria.tooltip\":\"A black speech bubble providing complementary information\"}");
2 changes: 1 addition & 1 deletion components/attention/locales/fi/messages.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"attention.aria.callout\":\"callout speech bubble\",\"attention.aria.close\":\"Sulje\",\"attention.aria.highlight\":\"highlighted speech bubble\",\"attention.aria.pointingDown\":\"pointing down\",\"attention.aria.pointingLeft\":\"pointing left\",\"attention.aria.pointingRight\":\"pointing right\",\"attention.aria.pointingUp\":\"pointing up\",\"attention.aria.popover\":\"popover speech bubble\",\"attention.aria.tooltip\":\"tooltip\"}");
/*eslint-disable*/export const messages=JSON.parse("{\"attention.aria.callout\":\"Vihreä puhekupla, joka esittelee jotain uutta\",\"attention.aria.close\":\"Sulje\",\"attention.aria.highlight\":\"Puhekupla, joka sisältää tärkeää tietoa\",\"attention.aria.pointingDown\":\"osoittaa alas\",\"attention.aria.pointingLeft\":\"osoittaa vasemmalle\",\"attention.aria.pointingRight\":\"osoittaa oikealle\",\"attention.aria.pointingUp\":\"osoittaa ylös\",\"attention.aria.popover\":\"Valkoinen puhekupla, joka tarjoaa lisätietoa\",\"attention.aria.tooltip\":\"Musta puhekupla, joka tarjoaa täydentävää tietoa\"}");
2 changes: 1 addition & 1 deletion components/attention/locales/nb/messages.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"attention.aria.callout\":\"callout speech bubble\",\"attention.aria.close\":\"Lukk\",\"attention.aria.highlight\":\"highlighted speech bubble\",\"attention.aria.pointingDown\":\"pointing down\",\"attention.aria.pointingLeft\":\"pointing left\",\"attention.aria.pointingRight\":\"pointing right\",\"attention.aria.pointingUp\":\"pointing up\",\"attention.aria.popover\":\"popover speech bubble\",\"attention.aria.tooltip\":\"tooltip\"}");
/*eslint-disable*/export const messages=JSON.parse("{\"attention.aria.callout\":\"Grønn taleboble som introduserer noe nytt\",\"attention.aria.close\":\"Lukk\",\"attention.aria.highlight\":\"En uthevet taleboble med viktig informasjon\",\"attention.aria.pointingDown\":\"peker ned\",\"attention.aria.pointingLeft\":\"peker til venstre\",\"attention.aria.pointingRight\":\"peker til høyre\",\"attention.aria.pointingUp\":\"peker opp\",\"attention.aria.popover\":\"En hvit taleboble som gir tilleggsinformasjon\",\"attention.aria.tooltip\":\"En svart taleboble som forklarer konteksten\"}");
3 changes: 2 additions & 1 deletion components/attention/w-attention.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import { createModel, modelProps } from 'create-v-model';
import { activateI18n } from '../util/i18n';
import { props as attentionProps, getVariantClasses } from './attentionUtil.js';
import { messages as daMessages } from './locales/da/messages.mjs';
import { messages as enMessages } from './locales/en/messages.mjs';
import { messages as fiMessages } from './locales/fi/messages.mjs';
import { messages as nbMessages } from './locales/nb/messages.mjs';
import wAttentionArrow from './w-attention-arrow.vue';
import { absentProp } from '#util';
activateI18n(enMessages, nbMessages, fiMessages);
activateI18n(enMessages, nbMessages, fiMessages, daMessages);
const props = defineProps({
...attentionProps,
Expand Down
1 change: 1 addition & 0 deletions components/breadcrumbs/locales/da/messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"breadcrumbs.ariaLabel\":\"Du er her\"}");
3 changes: 2 additions & 1 deletion components/breadcrumbs/w-breadcrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { breadcrumbs as ccBreadcrumbs } from '@warp-ds/css/component-classes';
import { activateI18n } from '../util/i18n';
import { messages as daMessages } from './locales/da/messages.mjs';
import { messages as enMessages } from './locales/en/messages.mjs';
import { messages as fiMessages } from './locales/fi/messages.mjs';
import { messages as nbMessages } from './locales/nb/messages.mjs';
activateI18n(enMessages, nbMessages, fiMessages);
activateI18n(enMessages, nbMessages, fiMessages, daMessages);
const ariaLabel = i18n._({
id: 'breadcrumbs.ariaLabel',
Expand Down
1 change: 1 addition & 0 deletions components/button/locales/da/messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"button.aria.loading\":\"Indlæser...\"}");
3 changes: 2 additions & 1 deletion components/button/w-button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { button as ccButton } from '@warp-ds/css/component-classes';
import { activateI18n } from '../util/i18n';
import { messages as daMessages } from './locales/da/messages.mjs';
import { messages as enMessages } from './locales/en/messages.mjs';
import { messages as fiMessages } from './locales/fi/messages.mjs';
import { messages as nbMessages } from './locales/nb/messages.mjs';
activateI18n(enMessages, nbMessages, fiMessages);
activateI18n(enMessages, nbMessages, fiMessages, daMessages);
const ariaValueText = i18n._({
id: 'button.aria.loading',
Expand Down
1 change: 1 addition & 0 deletions components/forms/locales/da/messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"forms.field.label.optional\":\"(valgfrit)\",\"forms.validation.mandatoryField\":\"Skal udfyldes\"}");
3 changes: 2 additions & 1 deletion components/forms/w-field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import { modelProps } from 'create-v-model';
import { activateI18n } from '../util/i18n';
import { messages as daMessages } from './locales/da/messages.mjs';
import { messages as enMessages } from './locales/en/messages.mjs';
import { messages as fiMessages } from './locales/fi/messages.mjs';
import { messages as nbMessages } from './locales/nb/messages.mjs';
import { createValidation } from './validation';
import { id } from '#util';
activateI18n(enMessages, nbMessages, fiMessages);
activateI18n(enMessages, nbMessages, fiMessages, daMessages);
export const fieldProps = {
id,
Expand Down
1 change: 1 addition & 0 deletions components/modal/locales/da/messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"modal.aria.back\":\"Tilbage\",\"modal.aria.close\":\"Luk\"}");
3 changes: 2 additions & 1 deletion components/modal/w-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import { setup as setupScrollLock, teardown as teardownScrollLock } from 'scroll
import { activateI18n } from '../util/i18n';
import { messages as daMessages } from './locales/da/messages.mjs';
import { messages as enMessages } from './locales/en/messages.mjs';
import { messages as fiMessages } from './locales/fi/messages.mjs';
import { messages as nbMessages } from './locales/nb/messages.mjs';
import { id } from '#util';
activateI18n(enMessages, nbMessages, fiMessages);
activateI18n(enMessages, nbMessages, fiMessages, daMessages);
const ariaBack = i18n._({
id: 'modal.aria.back',
Expand Down
1 change: 1 addition & 0 deletions components/pill/locales/da/messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"pill.aria.openFilter\":\"Åbn filter\",\"pill.aria.removeFilter\":[\"Fjern filter \",[\"label\"]]}");
3 changes: 2 additions & 1 deletion components/pill/w-pill.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import IconClose16 from '@warp-ds/icons/vue/close-16';
import { activateI18n } from '../util/i18n';
import { messages as daMessages } from './locales/da/messages.mjs';
import { messages as enMessages } from './locales/en/messages.mjs';
import { messages as fiMessages } from './locales/fi/messages.mjs';
import { messages as nbMessages } from './locales/nb/messages.mjs';
activateI18n(enMessages, nbMessages, fiMessages);
activateI18n(enMessages, nbMessages, fiMessages, daMessages);
const p = defineProps({
label: String,
Expand Down
1 change: 1 addition & 0 deletions components/steps/locales/da/messages.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"steps.aria.emptyCircle\":\"Tom cirkel\",\"steps.aria.active\":\"Trinindikator aktiv cirkel\",\"steps.aria.completed\":\"Trinindikator fuldført cirkel\"}");
2 changes: 1 addition & 1 deletion components/steps/locales/fi/messages.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"steps.aria.emptyCircle\":\"Empty circle\",\"steps.aria.active\":\"Step indicator active circle\",\"steps.aria.completed\":\"Step indicator completed circle\"}");
/*eslint-disable*/export const messages=JSON.parse("{\"steps.aria.emptyCircle\":\"Tyhjä ympyrä\",\"steps.aria.active\":\"Vaiheilmaisin aktiivinen ympyrä\",\"steps.aria.completed\":\"Vaiheilmaisin valmis ympyrä\"}");
2 changes: 1 addition & 1 deletion components/steps/locales/nb/messages.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/*eslint-disable*/export const messages=JSON.parse("{\"steps.aria.emptyCircle\":\"Empty circle\",\"steps.aria.active\":\"Step indicator active circle\",\"steps.aria.completed\":\"Step indicator completed circle\"}");
/*eslint-disable*/export const messages=JSON.parse("{\"steps.aria.emptyCircle\":\"Tom sirkel\",\"steps.aria.active\":\"Stegindikator aktiv sirkel\",\"steps.aria.completed\":\"Stegindikator hel sirkel\"}");
3 changes: 2 additions & 1 deletion components/steps/w-step.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import IconCheck16 from '@warp-ds/icons/vue/check-16';
import { activateI18n } from '../util/i18n';
import { messages as daMessages } from './locales/da/messages.mjs';
import { messages as enMessages } from './locales/en/messages.mjs';
import { messages as fiMessages } from './locales/fi/messages.mjs';
import { messages as nbMessages } from './locales/nb/messages.mjs';
activateI18n(enMessages, nbMessages, fiMessages);
activateI18n(enMessages, nbMessages, fiMessages, daMessages);
const vertical = inject('steps-vertical', true);
const left = inject('steps-left', true);
Expand Down
11 changes: 7 additions & 4 deletions components/util/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Messages, i18n } from '@lingui/core';

export const supportedLocales = ['en', 'nb', 'fi'] as const;
export const supportedLocales = ['en', 'nb', 'fi', 'da'] as const;
type SupportedLocale = (typeof supportedLocales)[number];

export const defaultLocale = 'en';
Expand Down Expand Up @@ -38,21 +38,24 @@ export const getMessages = (
locale: SupportedLocale,
enMsg: Messages,
nbMsg: Messages,
fiMsg: Messages
fiMsg: Messages,
daMsg: Messages
) => {
if (locale === 'nb') return nbMsg;
if (locale === 'fi') return fiMsg;
if (locale === 'da') return daMsg;
// Default to English
return enMsg;
};

export const activateI18n = (
enMessages: Messages,
nbMessages: Messages,
fiMessages: Messages
fiMessages: Messages,
daMessages: Messages
) => {
const locale = detectLocale();
const messages = getMessages(locale, enMessages, nbMessages, fiMessages);
const messages = getMessages(locale, enMessages, nbMessages, fiMessages, daMessages);
i18n.load(locale, messages);
i18n.activate(locale);
};

0 comments on commit e1e3589

Please sign in to comment.