-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
17,228 additions
and
14 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import lang_en from '../assets/en_us.json' | ||
|
||
|
||
export type Language = 'en' | 'de' | ||
|
||
interface Translations { | ||
[translationKey: string]: { | ||
lang: string | ||
} | ||
} | ||
|
||
let selectedLanguage: Language = 'en' | ||
|
||
export function useTranslation() { | ||
|
||
function translate(translationKey: string): string { | ||
try { | ||
if(selectedLanguage === 'en') { | ||
return lang_en[translationKey as keyof typeof lang_en] | ||
} | ||
else if(selectedLanguage === 'de') { | ||
return 'TODO German language' | ||
} | ||
} catch(error) { | ||
throw new Error(`Failed to get translation key '${translationKey}' for language '${selectedLanguage}'. This is a bug!`) | ||
} | ||
return 'LANGAUGE UNKNOWN' | ||
} | ||
|
||
return { translate } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
import { ref } from "vue" | ||
import type { BaseGoalConfig, GoalsConfig } from "./model/goals" | ||
import type { GoalsView } from "./view/goals" | ||
import { useConfigStore } from "@/main" | ||
|
||
export interface Searchable { | ||
label: string, | ||
} | ||
|
||
export function useSearchable(options: Searchable[]) { | ||
const model = useConfigStore().model | ||
|
||
const searchFieldValue = ref<string>('') | ||
|
||
function getPartialMatches(): Searchable[] { | ||
|
||
if(!searchFieldValue.value.trim()) { | ||
return options | ||
} | ||
else { | ||
return options.filter((searchable) => searchable.label.toLowerCase().includes(searchFieldValue.value.toLowerCase())) | ||
return options.filter((searchable) => | ||
searchable.label.toLowerCase().includes(searchFieldValue.value.toLowerCase()) | ||
) | ||
} | ||
} | ||
return { searchFieldValue, getPartialMatches } | ||
|
||
function allActiveGoalsAsLabels(goalsView: GoalsView): string[] { | ||
const allGoalsView = Object.values(goalsView.allgoals) | ||
const activeGoals = Object.keys(model.goals!) | ||
|
||
return allGoalsView.filter(goalView => activeGoals.includes(goalView.id)).map(goalView => goalView.label) | ||
} | ||
|
||
return { searchFieldValue, getPartialMatches, allActiveGoalsAsLabels } | ||
} |