Skip to content

Commit

Permalink
Implement select to changue language
Browse files Browse the repository at this point in the history
  • Loading branch information
Jpabon committed Nov 12, 2023
1 parent cc7ba5d commit 5cdfdd9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
2 changes: 1 addition & 1 deletion electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const indexHtml = join(ROOT_PATH.dist, "index.html");

async function createWindow() {
win = new BrowserWindow({
width: 900,
width: 1200,
minWidth: 900,
minHeight: 650,
height: 650,
Expand Down
10 changes: 5 additions & 5 deletions src/assets/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const messages = {
retryInterval: 'Retry Interval (s)',
speechKey: 'SpeechKey',
serviceRegion: 'ServiceRegion',
autoplay: 'Autoplay',
autoplay: 'Autoplay',
language: 'Language',
updateNotification: 'Update Notification',
titleStyle: 'Title Bar Style',
auditionText: 'Audition Text',
Expand All @@ -46,7 +47,6 @@ const messages = {
no: 'No',
serviceRegionPlaceHolder: "Fill in the service region, such as: westus",
confirm: 'OK',
language: 'Language',
voice: 'Voice',
style: 'Style',
role: 'Role',
Expand Down Expand Up @@ -373,6 +373,7 @@ const messages = {
retryInterval: 'Intervalo de Reintentos (s)',
speechKey: 'Clave de Voz',
serviceRegion: 'Región del Servicio',
language: 'Idioma',
autoplay: 'Reproducción Automática',
updateNotification: 'Notificación de Actualización',
titleStyle: 'Estilo de la Barra de Título',
Expand All @@ -389,7 +390,6 @@ const messages = {
no: 'No',
serviceRegionPlaceHolder: "Complete la región de servicio, como por ejemplo: westus",
confirm: 'OK',
language: 'Idioma',
voice: 'Voz',
style: 'Estilo',
role: 'Rol',
Expand Down Expand Up @@ -689,7 +689,8 @@ const messages = {
retryInterval: '重试间隔(s)',
speechKey: 'SpeechKey',
serviceRegion: 'ServiceRegion',
autoplay: '自动播放',
autoplay: '自动播放',
language: '语言',
updateNotification: '新版本提醒',
titleStyle: '标题栏样式',
auditionText: '试听文本',
Expand All @@ -705,7 +706,6 @@ const messages = {
no: '否',
serviceRegionPlaceHolder: "请填写ServiceRegion,如:westus",
confirm: '确认',
language: '语言',
voice: '语音',
style: '风格',
role: '角色',
Expand Down
33 changes: 33 additions & 0 deletions src/components/configpage/ConfigPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
<div class="config-page">
<div class="config-side" label-position="right">
<el-form :model="config" >
<el-form-item :label="t('configPage.language')">
<el-select
v-model="config.language"
size="small"
class="input-path"
@change="saveLanguageConfig"
>
<el-option
v-for="lang in languages"
:key="lang.value"
:label="lang.label"
:value="lang.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item :label="t('configPage.downloadPath')">
<el-input
v-model="config.savePath"
Expand Down Expand Up @@ -163,6 +178,7 @@ import { useTtsStore } from "@/store/store";
import { storeToRefs } from "pinia";
import Donate from "./Donate.vue";
import { useI18n } from 'vue-i18n';
import i18n from "@/assets/i18n/i18n";
const { t } = useI18n();
const { ipcRenderer, shell } = require("electron");
Expand All @@ -173,6 +189,23 @@ const store = new Store();
const ttsStore = useTtsStore();
const { config } = storeToRefs(ttsStore);
const languages = [
// Agrega más idiomas según sea necesario
{ label: 'English', value: 'en' },
{ label: 'Español', value: 'es' },
{ label: '中文', value: 'zh' },
];
const saveLanguageConfig = () => {
// Actualiza el idioma en i18n y guarda la configuración
i18n.global.locale.value = config.value.language;
// Llama a cualquier método necesario para guardar la configuración
// Por ejemplo, puedes llamar a 'savePathConfig' si también guarda el idioma, o crear un nuevo método.
savePathConfig(); // o tu método personalizado para guardar la configuración del idioma
};
const openFolderSelector = async () => {
const path = await ipcRenderer.invoke("openFolderSelector");
if (path) {
Expand Down
3 changes: 3 additions & 0 deletions src/global/initLocalStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default async function initStore() {
t("initialLocalStore.audition")
);
}
if (!store.has("language")) {
store.set("language", "en");
}
if (!store.has("autoplay")) {
store.set("autoplay", true);
}
Expand Down
1 change: 1 addition & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const useTtsStore = defineStore("ttsStore", {
tableData: <any>[], // 文件列表的数据
currConfigName: "默认", // 当前配置的名字
config: {
language: store.get("language"),
formConfigJson: store.get("FormConfig"),
formConfigList: <any>[],
configLabel: <any>[],
Expand Down

0 comments on commit 5cdfdd9

Please sign in to comment.