Skip to content

Commit

Permalink
feat: allow changing the name of a language template
Browse files Browse the repository at this point in the history
  • Loading branch information
BrewingWeasel committed Jul 31, 2024
1 parent 31f4f3a commit 4774f67
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/pages/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ const props = defineProps<{
}>();
const languagesOpen: Ref<{ [key: string]: boolean }> = ref({});
const languageNameChanges: Ref<{ [key: string]: string }> = ref({});
for (const language in settings.languages) {
languageNameChanges.value[language] = language;
if (props.currentLanguage === language) {
languagesOpen.value[language] = true;
} else {
Expand Down Expand Up @@ -108,6 +110,7 @@ async function newLanguage(language: string) {
await invoke("new_language_from_template", { language });
const updated: Settings = await invoke("get_settings");
settings.languages = updated.languages;
languageNameChanges.value[language] = language;
}
</script>

Expand Down Expand Up @@ -166,6 +169,11 @@ async function newLanguage(language: string) {
}
"
>
<SettingsMenu
v-model="section"
:rightLanguage="selectedLang === language"
section="General"
/>
<SettingsMenu
v-model="section"
:rightLanguage="selectedLang === language"
Expand Down Expand Up @@ -243,6 +251,29 @@ async function newLanguage(language: string) {
</Alert>
</template>

<template v-else-if="section == 'General' && selectedLang != null">
<Heading
title_id="general"
title="General"
description="Configure the general settings for the language"
/>
<Label for="language-name">Language name</Label>
<Input
v-model="languageNameChanges[selectedLang]"
class="w-64"
id="language-name"
@change="
() => {
if (selectedLang === null) return;
const newName = languageNameChanges[selectedLang];
settings.languages[newName] = settings.languages[selectedLang];
delete settings.languages[selectedLang];
languageNameChanges[newName] = newName;
}
"
/>
</template>

<template v-else-if="section == 'Exporting' && selectedLang != null">
<Heading
title_id="exporting"
Expand Down
1 change: 1 addition & 0 deletions src/pages/settings/components/SettingsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { cn } from "@/lib/utils";
export type SettingsSection =
| "Appearance"
| "Exporting"
| "General"
| "Word Knowledge"
| "Dictionaries"
| "Input"
Expand Down

0 comments on commit 4774f67

Please sign in to comment.