diff --git a/examples/ahiqar-arabic-karshuni-local.html b/examples/ahiqar-arabic-karshuni-local.html index 396d19c6..ba872e96 100644 --- a/examples/ahiqar-arabic-karshuni-local.html +++ b/examples/ahiqar-arabic-karshuni-local.html @@ -159,11 +159,12 @@ "next_item": "Next Sheet", "previous_item": "Previous Sheet", "next_manifest": "Next Manuscript", - "previous_manifest": "Previous Manuscript" + "previous_manifest": "Previous Manuscript", + "item": "Sheet" }, } }); }); - + \ No newline at end of file diff --git a/src/components/header/TitleBar.vue b/src/components/header/TitleBar.vue index 8bdb5b88..ee7706c6 100644 --- a/src/components/header/TitleBar.vue +++ b/src/components/header/TitleBar.vue @@ -18,7 +18,7 @@ class="t-px-2 text-gray-500 dark:text-gray-300" name="chevronRight" /> - {{ getItemLabel() }} {{ item.n }} + {{ getItemLabel(configStore.config) }} {{ item.n }} @@ -50,7 +50,9 @@ import { computed } from 'vue'; import { useConfigStore } from '@/stores/config'; import { useContentsStore } from '@/stores/contents' import BaseIcon from '@/components/base/BaseIcon.vue'; -import { getNavButtonsLabels } from '@/utils/translations'; +import { useI18n } from 'vue-i18n'; + +const { t } = useI18n() export interface Props { item: Item @@ -63,13 +65,33 @@ withDefaults(defineProps(), { const configStore = useConfigStore() const contentStore = useContentsStore() +const itemLabelKey = 'item' + const collectionTitle = computed(() => contentStore.collectionTitle); -const manifestTitle = computed(() => contentStore.manifest?.label ); +const manifestTitle = computed(() => contentStore.manifest?.label); + + +function isItemLabelInConfig(config) { + const lang = config['lang'] + const translations = config.translations[lang] + const numberKeys = Object.keys(translations).length -function getItemLabel() { - const navButtonsLabels = getNavButtonsLabels(configStore.config) - return navButtonsLabels[0].split(' ')[1] + if(numberKeys > 0) { + for (const key in translations) { + if(key === itemLabelKey) return true + } + } + return false } - + +function getItemLabel(config) { + const lang = config['lang'] + if(isItemLabelInConfig(config)) { + return config['translations'][lang][itemLabelKey] + } + return t('item') +} + + \ No newline at end of file diff --git a/src/utils/translations.js b/src/utils/translations.js index dcc0ec05..7d671636 100644 --- a/src/utils/translations.js +++ b/src/utils/translations.js @@ -16,7 +16,7 @@ export function areNavButtonsLabelsInConfig(config) { } -export function getNavButtonsLabels(config, navButtonsDefaultTextArray) { +export function getNavButtonsLabels(config) { const lang = config['lang'] if (areNavButtonsLabelsInConfig(config)) { @@ -28,4 +28,4 @@ export function getNavButtonsLabels(config, navButtonsDefaultTextArray) { const t = i18n[lang] return [t['next_item'], t['previous_item'], t['next_manifest'], t['previous_manifest']] } -} +} \ No newline at end of file