Skip to content

Commit

Permalink
add fr translation & use the "week" to fit the weekstartOn
Browse files Browse the repository at this point in the history
  • Loading branch information
jycouet committed Jan 10, 2024
1 parent b115fa9 commit d888c21
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
9 changes: 4 additions & 5 deletions packages/svelte-ux/src/lib/components/DateRangeField.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import { getSettings } from './settings';
const dispatch = createEventDispatcher();
const settings = getSettings();
const { format } = settings;
const { format } = getSettings();
const _defaultValue: DateRangeType = {
from: null,
Expand All @@ -28,9 +27,9 @@
export let center: boolean = false;
export let periodTypes: PeriodType[] = [
PeriodType.Day,
PeriodType.WeekSun,
PeriodType.BiWeek1Sun,
// PeriodType.BiWeek2Sun,
PeriodType.Week,
PeriodType.BiWeek1,
// PeriodType.BiWeek2,
PeriodType.Month,
PeriodType.Quarter,
PeriodType.CalendarYear,
Expand Down
21 changes: 19 additions & 2 deletions packages/svelte-ux/src/lib/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ export function getPeriodTypeNameWithLocale(settings: LocaleSettings, periodType
} = settings;

switch (periodType) {
case PeriodType.Custom:
return 'Custom';

case PeriodType.Day:
return dico?.Day;
return dico.Day;
case PeriodType.DayTime:
return dico.DayTime;
case PeriodType.TimeOnly:
return dico.Time;

case PeriodType.WeekSun:
return `${dico.Week} (${getDayOfWeekName(DayOfWeek.Sunday, locale)})`;
Expand All @@ -81,6 +88,8 @@ export function getPeriodTypeNameWithLocale(settings: LocaleSettings, periodType
return `${dico.Week} (${getDayOfWeekName(5, locale)})`;
case PeriodType.WeekSat:
return `${dico.Week} (${getDayOfWeekName(6, locale)})`;
case PeriodType.Week:
return dico.Week;

case PeriodType.Month:
return dico.Month;
Expand All @@ -107,6 +116,8 @@ export function getPeriodTypeNameWithLocale(settings: LocaleSettings, periodType
return `${dico.BiWeek} (${getDayOfWeekName(5, locale)})`;
case PeriodType.BiWeek1Sat:
return `${dico.BiWeek} (${getDayOfWeekName(6, locale)})`;
case PeriodType.BiWeek1:
return dico.BiWeek;

case PeriodType.BiWeek2Sun:
return `${dico.BiWeek} 2 (${getDayOfWeekName(0, locale)})`;
Expand All @@ -122,12 +133,18 @@ export function getPeriodTypeNameWithLocale(settings: LocaleSettings, periodType
return `${dico.BiWeek} 2 (${getDayOfWeekName(5, locale)})`;
case PeriodType.BiWeek2Sat:
return `${dico.BiWeek} 2 (${getDayOfWeekName(6, locale)})`;
case PeriodType.BiWeek2:
return `${dico.BiWeek} 2`;

default:
return 'Unknown';
assertNever(periodType); // This will now report unhandled cases
}
}

function assertNever(x: never): never {
throw new Error(`Unhandled enum case: ${x}`);
}

export function getPeriodTypeCode(periodType: PeriodType) {
switch (periodType) {
case PeriodType.Day:
Expand Down
2 changes: 2 additions & 0 deletions packages/svelte-ux/src/lib/utils/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export type DictionaryMessagesOptions = {

Date?: {
Day?: string;
DayTime?: string;
Time?: string;
Week?: string;
BiWeek?: string;
Month?: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/svelte-ux/src/lib/utils/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const defaultLocaleSettings: LocaleSettings = {
Cancel: 'Cancel',
Date: {
Day: 'Day',
DayTime: 'Day Time',
Time: 'Time',
Week: 'Week',
BiWeek: 'Bi-Week',
Month: 'Month',
Expand Down
8 changes: 8 additions & 0 deletions packages/svelte-ux/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
Cancel: 'Annuler',
Date: {
Day: 'Jour',
DayTime: 'Jour & Heure',
Time: 'Heure',
Week: 'Semaine',
Month: 'Mois',
Quarter: 'Trimestre',
CalendarYear: 'Année',
FiscalYearOct: 'Année fiscale (octobre)',
BiWeek: 'Bi-hebdomadaire',
},
},
}),
Expand Down

0 comments on commit d888c21

Please sign in to comment.