Skip to content

Commit

Permalink
fix: add mapping for translation keys for mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tomosterlund committed Dec 9, 2023
1 parent 89ce08c commit f958962
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/header/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
:class="'is-' + calendarMode + '-mode'"
@click="$emit('change-mode', calendarMode)"
>
{{ getLanguage(languageKeys[calendarMode], time.CALENDAR_LOCALE) }}
{{ getTranslationForMode(calendarMode) }}
</div>
</template>
</div>
Expand All @@ -79,7 +79,7 @@ import { type configInterface } from '../../typings/config.interface';
import Time from '../../helpers/Time';
import { type periodInterface } from '../../typings/interfaces/period.interface';
import getLanguage from '../../language';
import { type modeType } from '../../typings/types';
import {ModeTranslationMapping, type modeType} from '../../typings/types';
export default defineComponent({
name: 'AppHeader',
Expand Down Expand Up @@ -157,10 +157,7 @@ export default defineComponent({
},
modeName() {
return this.getLanguage(
this.languageKeys[this.mode],
this.time?.CALENDAR_LOCALE
);
return this.getTranslationForMode(this.mode)
},
onlyDayModeIsEnabled() {
Expand Down Expand Up @@ -191,6 +188,12 @@ export default defineComponent({
goToPeriod(direction: 'previous' | 'next') {
(this.$refs.periodSelect as typeof DatePicker).goToPeriod(direction);
},
getTranslationForMode(mode: modeType) {
const modeTranslationKey = ModeTranslationMapping[mode as keyof typeof ModeTranslationMapping]
return this.getLanguage(this.languageKeys[modeTranslationKey], this.time?.CALENDAR_LOCALE)
}
}
});
</script>
Expand Down
8 changes: 8 additions & 0 deletions src/typings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ export type DayInfo = {
thisDayIndex: number,
dateTimeString: string
}

// Since the agenda doesn't need its own translations, we map it to the month mode
export enum ModeTranslationMapping {
month = "month",
agenda = "month",
week = "week",
day = "day",
}

0 comments on commit f958962

Please sign in to comment.