Skip to content

Commit

Permalink
Change translation generalization
Browse files Browse the repository at this point in the history
  • Loading branch information
anwolosz committed Aug 24, 2024
1 parent fbb61f9 commit 86f97e1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/assets/synopsis_esv.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"translation": "ESV",
"language": "en",
"chapters": [
{
"chapter_name": "I. Preface",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/synopsis_szit.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"translation": "SZIT",
"language": "hu",
"chapters": [
{
"chapter_name": "I. Bevezetés",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ export default {
<i class="bi bi-book fs-5 align-middle"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li> <a @click="synopsisStore.translation === 'SZIT' ? synopsisStore.changeTranslation() : null"
<li> <a @click="synopsisStore.translation === 'SZIT' ? synopsisStore.changeTranslation('ESV') : null"
class="dropdown-item hoverable text-black"
:class="synopsisStore.translation !== 'SZIT' ? 'bg-dark-subtle' : ''">
ESV (en)</a></li>
<li><a @click="synopsisStore.translation !== 'SZIT' ? synopsisStore.changeTranslation() : null"
<li><a @click="synopsisStore.translation !== 'SZIT' ? synopsisStore.changeTranslation('SZIT') : null"
class="dropdown-item hoverable text-black"
:class="synopsisStore.translation === 'SZIT' ? 'bg-dark-subtle' : ''">
SZIT (hu)</a></li>
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/synopsisInterface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface SynopsisScheme {
language: string,
translation: string,
chapters: ChapterScheme[]
}

Expand Down
22 changes: 12 additions & 10 deletions src/stores/SynopsisStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const synopsisESV: SynopsisScheme = synopsis_esv
//TODO: proper typing
const dictionaryEn: any = dictionary_en
const dictionaryHu: any = dictionary_hu
const synopses = [synopsisSZIT, synopsisESV]


export const useSynopsisStore = defineStore('synopsis', {
state: () => {
Expand All @@ -36,17 +38,17 @@ export const useSynopsisStore = defineStore('synopsis', {
}
router.push({ name: router.currentRoute.value.name as string, params: { lang: this.language, translation: this.translation } });
},
changeTranslation() {
console.log("HELLO")
if (this.translation === "SZIT") {
this.synopsis = synopsisESV
this.translation = "ESV"
}
else {
this.synopsis = synopsisSZIT
this.translation = "SZIT"
changeTranslation(translation: string) {
for (let synopsisIndex = 0; synopsisIndex<synopses.length; synopsisIndex++)
{
if (synopses[synopsisIndex].translation == translation)
{
this.synopsis = synopses[synopsisIndex]
this.translation = translation
router.push({ name: router.currentRoute.value.name as string, params: { lang: this.language, translation: this.translation } });
break
}
}
router.push({ name: router.currentRoute.value.name as string, params: { lang: this.language, translation: this.translation } });
},
//TODO: proper typing
get(location: any) {
Expand Down

0 comments on commit 86f97e1

Please sign in to comment.