Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat Nav buttons text configurable + add tests #476

Merged
merged 21 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
99d2b44
feat: make the header nav buttons text configurable
Sep 19, 2024
996003e
fix: resolve errors in app.cy tests regarding the title bar
Sep 19, 2024
a0d9e93
fix: resolve errors regarding the content tests
Sep 19, 2024
46f977f
fix: rewrite the old tests content as it was and add a arabic karshun…
Sep 19, 2024
0bb79e4
refactor: add ahiqar and gfl selektors in globals file
Sep 19, 2024
383c931
test: add tests for the feat header nav buttons text configurable
Sep 19, 2024
8ccdfc8
chore: restore the previous content in index.html
Sep 20, 2024
ee74427
fix: add combined translation keys for the header nav buttons
Sep 20, 2024
bc803d9
test: adapt the header nav buttons text according to the new translat…
Sep 20, 2024
fddb30c
chore: remove the 'labels' object from the gfl local example file
Sep 20, 2024
044f32e
chore: restore the labels object in config of local files (arabic kar…
Sep 20, 2024
93b1840
fix: show specific header nav button labels for the ahiqar editions
Sep 20, 2024
7988fcb
feat: make header navigation buttons text configurable for each project
Sep 20, 2024
fc824c8
test: remove the tests for arabic karshuni 'de'
Sep 20, 2024
935c7a5
chore: add in the translations key of config the (key,value) of nav b…
Sep 20, 2024
5bb41a1
chore: remove the translations key values from i18n en for the ahiqa…
Sep 20, 2024
625f681
chore: set the 'item' label temporarily in Title bar
Sep 20, 2024
b6b196f
chore: use the general keys (item and manifest) in config for the loc…
Sep 23, 2024
c754f39
feat: add nav buttons text configurable
Sep 23, 2024
415b03f
fix: show the item name in the title of header based on nav buttons text
Sep 23, 2024
931b282
chore: remove ahiqar arabic karshuni local
Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions examples/ahiqar-arabic-karshuni-local-de.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<!DOCTYPE html>
paulpestov marked this conversation as resolved.
Show resolved Hide resolved
<html>
<head><title>TIDO</title>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="initial-scale=1,maximum-scale=5,minimum-scale=1,width=device-width">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="dist/tido.css">
<style>
html, body {
margin: 0;
}
#app {
height: 100vh;
}
</style>
</head>
<body>
<noscript><strong>We're sorry but TIDO doesn't work properly without JavaScript enabled. Please enable it to
continue.</strong></noscript>

<div id="app"></div>
<script src="dist/tido.js"></script>
<script>
window.addEventListener('load', function () {
window.tido = new window.Tido({
"collection": "http://localhost:8181/ahiqar/textapi/ahiqar/arabic-karshuni/collection.json",
"lang": "de",
"colors": {
"forceMode": "light"
},
"panels": [
{
"label": "contents_and_metadata",
"views": [
{
"id": "tree",
"label": "contents",
"connector": {
"id": 1
}
},
{
"id": "metadata",
"label": "metadata",
"connector": {
"id": 2,
"options": {
"collection": {
"all": true
},
"manifest": {
"all": true
},
"item": {
"all": true
}
}
}
}
]
},
{
"label": "image",
"views": [
{
"id": "image",
"label": "Image",
"connector": {
"id": 3
}
}]
},
{
"label": "text",
"views": [
{
"id": "text1",
"label": "Transcription",
"default": true,
"connector": {
"id": 4,
"options": {
"type": "transcription"
}
}
},
{
"id": "text2",
"label": "Transliteration",
"connector": {
"id": 4,
"options": {
"type": "transliteration"
}
}
}
]
},
{
"label": "annotations",
"views": [
{
"id": "annotations1",
"label": "Editorial",
"connector": {
"id": 5,
"options": {
"types": [
{
"name": "Person",
"icon": "biPersonFill"
},
{
"name": "Place",
"icon": "biGeoAltFill"
},
{
"name": "Editorial Comment",
"icon": "biChatFill"
},
{
"name": "Reference",
"icon": "biBoxArrowUpRight"
}
]
}
}
},
{
"id": "annotations2",
"label": "Motif",
"connector": {
"id": 5,
"options": {
"types": [
{
"name": "Motif",
"icon": "biPenFill"
}
]
}
}
}
]
}
],
"translations": {
"en": {
"contents_and_metadata": "Contents & Metadata"
}
}
});
});
</script>
</body>
</html>
10 changes: 8 additions & 2 deletions examples/ahiqar-arabic-karshuni-local.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"item": "Sheet",
"manifest": "Manuscript"
},
"lang": "en",
paulpestov marked this conversation as resolved.
Show resolved Hide resolved
"colors": {
"forceMode": "light"
},
Expand Down Expand Up @@ -152,8 +153,13 @@
],
"translations": {
"en": {
"contents_and_metadata": "Contents & Metadata"
}
"contents_and_metadata": "Contents & Metadata",
"next_page":"Next Sheet",
"previous_page": "Previous Sheet",
"next_document": "Next Manuscript",
"previous_document": "Previous Manuscript"
},

}
});
});
Expand Down
9 changes: 8 additions & 1 deletion examples/gfl-local.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@
}
],
translations: {
Edition_license: 'Editionslizenz'
de: {
Edition_license: 'Editionslizenz',
next_page : "Nächste Seite",
paulpestov marked this conversation as resolved.
Show resolved Hide resolved
previous_page: "Vorherige Seite",
next_document: "Nächstes Dokument",
previous_document: "Vorheriges Dokument"
}

}
});
});
Expand Down
36 changes: 27 additions & 9 deletions src/components/header/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useI18n } from 'vue-i18n';
import { useConfigStore } from '@/stores/config';
import { useContentsStore } from '@/stores/contents';
import BaseButton from '@/components/base/BaseButton.vue';
import { areNavButtonsLabelsInConfig } from '@/utils/translations'

const configStore = useConfigStore();
const contentStore = useContentsStore();
Expand All @@ -48,6 +49,20 @@ const hasPrev = computed<boolean>(() => {

return true;
});



function getNavButtonsLabels(config): string[] {
const lang = config['lang']
if (areNavButtonsLabelsInConfig(config)) {
const translations = config.translations[lang]
return [translations['next_page'], translations['previous_page'], translations['next_document'], translations['previous_document']]
}
else {
return [t('next_item'), t('previous_item'), t('next_manifest'), t('previous_manifest')]
}
}

const hasNext = computed<boolean>(() => {
const nextIndex = itemIndex.value + 1;
if (nextIndex > manifest.value.sequence.length - 1) {
Expand All @@ -57,16 +72,19 @@ const hasNext = computed<boolean>(() => {
}
return true;
});
const labels = computed<Labels>(() => configStore.config.labels || {
manifest: 'manifest',
item: 'item',
});
const nextButtonLabel = computed<string>(() => (itemIndex.value === manifest.value.sequence.length - 1
? `${t('next')} ${t(labels.value.manifest ? labels.value.manifest : 'Manuscript')}`
: `${t('next')} ${t(labels.value.item)}`));

// variables are named according to the general concept of ie (page = sheet, item); (document = manuscript)
paulpestov marked this conversation as resolved.
Show resolved Hide resolved
const [nextPageLabel, previousPageLabel, nextDocumentLabel, previousDocumentLabel]: string[] = getNavButtonsLabels(configStore.config)

const nextButtonLabel = computed<string>(() => (
itemIndex.value === manifest.value.sequence.length - 1
? `${nextDocumentLabel}`
: `${nextPageLabel}`));


const prevButtonLabel = computed<string>(() => (itemIndex.value === 0
? `${t('prev')} ${t(labels.value.manifest ? labels.value.manifest : 'Manuscript')}`
: `${t('prev')} ${t(labels.value.item)}`));
? `${previousDocumentLabel}`
: `${previousPageLabel}`));

function prev() {
const prevIndex = itemIndex.value - 1;
Expand Down
19 changes: 12 additions & 7 deletions src/components/header/TitleBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class="t-px-2 text-gray-500 dark:text-gray-300"
name="chevronRight"
/>
<span v-if="item">{{ labels.item }} {{ item.n }}</span>
<span v-if="item">{{ $t('item') }} {{ item.n }}</span>
</h2>
</template>
<template v-else>
Expand All @@ -32,7 +32,7 @@
<span
v-if="item"
class="t-align-middle"
>{{ labels.item }} {{ item.n }}</span>
>{{ $t('item') }} {{ item.n }}</span>
</h1>
</template>
</template>
Expand All @@ -50,7 +50,8 @@ import { computed } from 'vue';
import { useConfigStore } from '@/stores/config';
import { useContentsStore } from '@/stores/contents'
import BaseIcon from '@/components/base/BaseIcon.vue';

import { useI18n } from 'vue-i18n';
import { areNavButtonsLabelsInConfig } from '@/utils/translations';

export interface Props {
item: Item
Expand All @@ -62,11 +63,15 @@ withDefaults(defineProps<Props>(), {

const configStore = useConfigStore()
const contentStore = useContentsStore()
const { t } = useI18n();


const collectionTitle = computed<string | null>(() => contentStore.collectionTitle);
const manifestTitle = computed<string | undefined>(() => contentStore.manifest?.label );
const labels = computed<Labels>(() => configStore.config.labels || {
manifest: 'manifest',
item: 'item',
});

function getPageLabel(config): string {
return ''
//return areNavButtonsLabelsInConfig(config) ? t('sheet') : t('item')

}
</script>
14 changes: 9 additions & 5 deletions src/i18n/de/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ export default {
Letter: 'Brief',
License: 'Lizenz',
Location: 'Aktueller Aufbewahrungsort',
Manuscript: 'Manuskript',
metadata: 'Metadaten',
Motif: 'Motive',
search_hit_list: 'Trefferanzeige',
next: 'Nächste',
no_annotations_in_view: 'Die aktuelle Ansicht enthält keine Annotationen.',
no_comments_in_view: 'Die aktuelle Ansicht enthält keine Kommentare',
no_entrypoint_available: 'Keine URL zum Einstieg gefunden. Bitte überprüfen Sie Ihre Konfiguration.',
Expand All @@ -74,11 +72,18 @@ export default {
zoom_in: 'Vergrössern',
zoom_out: 'Verkleinern',
'Place of origin': 'Herkunftsort',
prev: 'Vorherige',
project_info: 'Projekt Informationen',
reset: 'Zurücksetzen',
search: 'Suche',
Sheet: 'Seite',
item: 'Seite',
next_item: 'Nächste Seite',
previous_item: 'Vorherige Seite',
next_manifest: 'Nächstes Dokument',
previous_manifest: 'Vorheriges Dokument',
next_sheet: 'Nächste Seite',
previous_sheet: 'Vorherige Seite',
next_manuscript: 'Nächstes Manuskript',
previous_manuscript: 'Vorheriges Manuskript',
show: 'Zeige',
show_hide_panels: 'Panels ein-/ausblenden',
tabs: 'Reiter',
Expand All @@ -104,7 +109,6 @@ export default {
server_error: 'Server Fehler',
other: 'Sonstiges',
subtitle: 'Untertitel',
manifest: 'Manifest',
more_annotations: 'Weitere',
undefined_role: 'Undefinierte Rolle',
not_found: 'Nicht gefunden',
Expand Down
10 changes: 6 additions & 4 deletions src/i18n/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export default {
metadata: 'Metadata',
Motif: 'Motifs',
search_hit_list: 'Search hit list',
next: 'Next',
next_item: 'Next Item',
previous_item: 'Previous Item',
next_manifest: 'Next Manifest',
previous_manifest: 'Previous Manifest',
no_annotations_in_view: 'The current view has no annotations to display.',
no_comments_in_view:
'The current view does not contain any comments to display',
Expand All @@ -78,11 +81,11 @@ export default {
zoom_in: 'Zoom in',
zoom_out: 'Zoom out',
'Place of origin': 'Place of origin',
prev: 'Previous',
project_info: 'Project Info',
reset: 'Reset',
search: 'Search',
Sheet: 'Sheet',
item: 'Item',
sheet: 'Sheet',
show: 'Show',
show_hide_panels: 'Show/Hide Panels',
tabs: 'Tabs',
Expand All @@ -108,7 +111,6 @@ export default {
server_error: 'Server error',
other: 'Other',
subtitle: 'Subtitle',
manifest: 'Manifest',
also_selected: 'Also selected',
undefined_role: 'Undefined role',
not_found: 'Not found',
Expand Down
13 changes: 13 additions & 0 deletions src/utils/translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

export function areNavButtonsLabelsInConfig(config) {
paulpestov marked this conversation as resolved.
Show resolved Hide resolved
paulpestov marked this conversation as resolved.
Show resolved Hide resolved

const lang = config['lang']
const translations = config.translations[lang]
// the first element is 'Contents and Metadata', while the other 4 should be for the header nav buttons text
if (Object.keys(translations).length < 5) return false
const customNavButtonsText = Object.keys(translations).slice(1,5) // the nav buttons text if given should be from 1-5 th keys
const navButtonsTextArray = ['next_page', 'previous_page', 'next_document', 'previous_document']

return JSON.stringify(customNavButtonsText) === JSON.stringify(navButtonsTextArray)
}

Loading
Loading