Skip to content

Commit

Permalink
feat: add language toggle to all menus as requested in ContentSquare#61
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahhb committed Apr 18, 2024
1 parent 9ae6187 commit 6055369
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ onMounted(() => {
const { settings, changeLanguage, updateSettings } = useFormSettings(selectedProfiledId)
const close = async () => await useExtensionUtils().closeCurrentTab()
const { closeCurrentTab, saveLocale } = useExtensionUtils()
const { t } = useI18n()
const { locale, t } = useI18n()
const changeLocale = async (lang: 'en' | 'fr') => {
locale.value = lang
await saveLocale(lang)
}
</script>
<template>
<div class="m-auto max-w-screen-lg p-2 text-base">
Expand All @@ -43,6 +48,14 @@ const { t } = useI18n()
<TextProfileEditDropdown v-model="selectedProfiledId" class="w-60" :settings="settings" />
<TextProfileRenameButton class="ml-3" :profile-id="selectedProfiledId" />
<TextSettingsFileDownload class="ml-auto" :settings="settings" />
<div class="text-right">
{{ t('MAIN_MENU.MENU_LANGUAGE') }}
<span v-if="locale === 'fr'">FR</span>
<a v-if="locale !== 'fr'" href="#/options" @click="changeLocale('fr')">FR</a>
/
<span v-if="locale === 'en'">EN</span>
<a v-if="locale !== 'en'" href="#/options" @click="changeLocale('en')">EN</a>
</div>
</div>
<div class="flex">
<TextProfileForm class="w-2/3 min-w-[730px]" :settings="settings" @update-settings="updateSettings" @change-language="changeLanguage" />
Expand All @@ -53,7 +66,7 @@ const { t } = useI18n()
<TextProfileSaveButton v-model="selectedProfiledId" :settings="settings" />
<TextProfileDeleteButton v-model="selectedProfiledId" class="ml-3 mr-auto" />
<!-- TODO: add dirty settings calculation -->
<button class="btn-secondary btn-sm btn" @click="close">{{ t('SETTINGS.CLOSE') }}</button>
<button class="btn-secondary btn-sm btn" @click="closeCurrentTab()">{{ t('SETTINGS.CLOSE') }}</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,34 @@ import { useI18n } from 'vue-i18n'
const language = ref<Language>('en')
const templates = useTemplatesByLanguage(language)
const { closeCurrentTab } = useExtensionUtils()
const { closeCurrentTab, saveLocale } = useExtensionUtils()
const router = useRouter()
const openProfile = (newTextProfileId: TextProfileId) => {
router.push({ path: 'options', query: { profileId: newTextProfileId } })
}
const { t } = useI18n()
const { locale, t } = useI18n()
const changeLocale = async (lang: 'en' | 'fr') => {
locale.value = lang
await saveLocale(lang)
}
</script>

<template>
<div class="mx-auto max-w-screen-md p-2 text-base">
<div class="text-2xl font-semibold">{{ t('SELECT_TEMPLATE.PLEASE_SELECT_A_TEMPLATE') }}</div>
<div class="flex">
<div class="w-1/2 text-2xl font-semibold">{{ t('SELECT_TEMPLATE.PLEASE_SELECT_A_TEMPLATE') }}</div>
<div class="w-1/2 text-right">
{{ t('MAIN_MENU.MENU_LANGUAGE') }}
<span v-if="locale === 'fr'">FR</span>
<a v-if="locale !== 'fr'" href="#/templates" @click="changeLocale('fr')">FR</a>
/
<span v-if="locale === 'en'">EN</span>
<a v-if="locale !== 'en'" href="#/templates" @click="changeLocale('en')">EN</a>
</div>
</div>
<div class="mt-3">{{ t('SELECT_TEMPLATE.CLICK_TO_MODIFY_OR_SELECT_TEMPLATE') }}</div>
<div class="mt-3">
<div>{{ t('SELECT_TEMPLATE.PROFILE_LANGUAGE') }}</div>
Expand Down

0 comments on commit 6055369

Please sign in to comment.