Skip to content

Commit

Permalink
Improve I18n for backup options
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahoo12138 committed Jun 4, 2024
1 parent 341b74b commit dba6a2d
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 57 deletions.
60 changes: 31 additions & 29 deletions src/app/components/Option/components/BackupOption/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ const _default = defineComponent((_props, ctx) => {
return (
<OptionItem
key={item.name}
label={(_) => item.label}
// v-slots={{
// info: () => (
// <OptionTooltip>
// {t(
// (msg) =>
// msg.option.backup.meta[
// backupType.value
// ]?.authInfo
// )}
// </OptionTooltip>
// ),
// }}
label={(msg) => msg.option.backup.meta[backupType.value]?.[item.label]}
v-slots={item.info ? {
info: () => (
<OptionTooltip>
{t(
(msg) =>
msg.option.backup.meta[
backupType.value
]?.[item.info]
)}
</OptionTooltip>
),
} : {}}
>
<ElInput
modelValue={ext.value[item.name]}
Expand All @@ -146,28 +146,29 @@ const _default = defineComponent((_props, ctx) => {
ext.value[item.name] = val?.trim?.() || ""
}}
/>
</OptionItem>
</OptionItem >
)
})}

{isNotNone.value &&
{
isNotNone.value &&
AUTH_LABELS[backupType.value].map((item, index) => {
return (
<OptionItem
key={item.name}
label={(_) => item.label}
// v-slots={{
// info: () => (
// <OptionTooltip>
// {t(
// (msg) =>
// msg.option.backup.meta[
// backupType.value
// ]?.authInfo
// )}
// </OptionTooltip>
// ),
// }}
label={(msg) => msg.option.backup.meta[backupType.value]?.[item.label]}
v-slots={item.info ? {
info: () => (
<OptionTooltip>
{t(
(msg) =>
msg.option.backup.meta[
backupType.value
]?.[item.info]
)}
</OptionTooltip>
),
} : {}}
>
<ElInput
modelValue={auth.value[item.name]}
Expand All @@ -182,7 +183,8 @@ const _default = defineComponent((_props, ctx) => {
/>
</OptionItem>
)
})}
})
}

<OptionItem v-show={isNotNone.value} label={msg => msg.option.backup.client}>
<ElInput
Expand Down
20 changes: 10 additions & 10 deletions src/app/components/Option/components/BackupOption/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ export const ALL_TYPES: timer.backup.Type[] = [
];

export const AUTH_LABELS: {
[t in timer.backup.Type]: { name: string; label: string }[];
[t in timer.backup.Type]: { name: string; label: string, info?: string }[];
} = {
none: [],
gist: [{ name: "token", label: "Personal Access Token {info} {input}" }],
gist: [{ name: "token", label: "label", info: "authInfo" }],
webdav: [
{ name: "username", label: "Username {input}" },
{ name: "password", label: "Password {input}" },
{ name: "username", label: "usernameLabel" },
{ name: "password", label: "passwordLabel" },
],
obsidian_local_rest_api: [
{ name: "token", label: "Authorization {input}" },
{ name: "token", label: "authLabel" },
],
};

export const EXT_LABELS: {
[t in timer.backup.Type]: { name: string; label: string }[];
[t in timer.backup.Type]: { name: string; label: string, info?: string }[];
} = {
none: [],
gist: [],
webdav: [
{ name: "endpoint", label: "服务地址 {input}" },
{ name: "dirPath", label: "文件夹路径 {input}" },
{ name: "endpoint", label: "endpointLabel", info: "endpointInfo" },
{ name: "dirPath", label: "pathLabel" },
],
obsidian_local_rest_api: [
{ name: "endpoint", label: "服务地址 {input}" },
{ name: "dirPath", label: "文件夹路径 {input}" },
{ name: "endpoint", label: "endpointLabel", info: "endpointInfo" },
{ name: "dirPath", label: "pathLabel" },
],
};

Expand Down
56 changes: 42 additions & 14 deletions src/i18n/message/app/option-resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,21 @@
"label": "不开启备份"
},
"gist": {
"label": "Personal Access Token {info} {input}",
"authInfo": "需要创建一个至少包含 gist 权限的 token"
},
"obsidian_local_rest_api": {
"endpointLabel": "服务地址 {info} {input}",
"endpointInfo": "因为无法为浏览器插件配置跨域,所以只能使用 HTTP 协议",
"pathLabel": "文件夹路径 {input}"
"pathLabel": "文件夹路径 {input}",
"authLabel": "Authorization {input}"
},
"webdav": {
"endpointLabel": "服务地址 {info} {input}",
"endpointInfo": "因为无法为浏览器插件配置跨域,所以只能使用 HTTP 协议",
"pathLabel": "文件夹路径 {input}"
"pathLabel": "文件夹路径 {input}",
"usernameLabel": "用户名 {input}",
"passwordLabel": "密码 {input}"
}
},
"alert": "这是一项实验性功能,如果有任何问题请联系作者~ ({email})",
Expand Down Expand Up @@ -205,17 +209,21 @@
"label": "關閉備份"
},
"gist": {
"label": "Personal Access Token {info} {input}",
"authInfo": "需要創建一個至少包含 gist 權限的 token"
},
"obsidian_local_rest_api": {
"endpointLabel": "服務地址 {info} {input}",
"endpointInfo": "僅 HTTP 可用,因為無法為擴展頁面配置 CORS",
"pathLabel": "目錄的路徑 {input}"
"pathLabel": "目錄的路徑 {input}",
"authLabel": "Authorization {input}"
},
"webdav": {
"endpointLabel": "服務地址 {info} {input}",
"endpointInfo": "僅 HTTP 可用,因為無法為擴展頁面配置 CORS",
"pathLabel": "目錄的路徑 {input}"
"pathLabel": "目錄的路徑 {input}",
"usernameLabel": "用户名 {input}",
"passwordLabel": "密码 {input}"
}
},
"alert": "這是一項實驗性功能,如果有任何問題請聯繫作者 ({email}) ~",
Expand Down Expand Up @@ -329,17 +337,21 @@
"label": "Always off"
},
"gist": {
"label": "Personal Access Token {info} {input}",
"authInfo": "One token with at least gist permission is required"
},
"obsidian_local_rest_api": {
"endpointLabel": "Endpoint address {info} {input}",
"endpointInfo": "Only HTTP is available because it is not possible to configure CORS for extensions pages",
"pathLabel": "The path of directory {input}"
"pathLabel": "The path of directory {input}",
"authLabel": "Authorization {input}"
},
"webdav": {
"endpointLabel": "Endpoint address {info} {input}",
"endpointInfo": "Only HTTP is available because it is not possible to configure CORS for extensions pages",
"pathLabel": "The path of directory {input}"
"pathLabel": "The path of directory {input}",
"usernameLabel": "用户名 {input}",
"passwordLabel": "密码 {input}"
}
},
"alert": "This is an experimental feature, if you have any questions please contact the author via {email}~",
Expand Down Expand Up @@ -453,17 +465,21 @@
"label": "バックアップを有効にしない"
},
"gist": {
"label": "Personal Access Token {info} {input}",
"authInfo": "少なくとも gist 権限を持つトークンが 1 つ必要です"
},
"obsidian_local_rest_api": {
"endpointLabel": "エンドポイントアドレス {info} {input}",
"endpointInfo": "拡張機能のページに CORS を設定できないため、HTTP のみが利用できます。",
"pathLabel": "ディレクトリのパス {input}"
"pathLabel": "ディレクトリのパス {input}",
"authLabel": "Authorization {input}"
},
"webdav": {
"endpointLabel": "エンドポイントアドレス {info} {input}",
"endpointInfo": "拡張機能のページに CORS を設定できないため、HTTP のみが利用できます。",
"pathLabel": "ディレクトリのパス {input}"
"pathLabel": "ディレクトリのパス {input}",
"usernameLabel": "用户名 {input}",
"passwordLabel": "密码 {input}"
}
},
"alert": "これは実験的な機能です。質問がある場合は、作成者に連絡してください ({email})",
Expand Down Expand Up @@ -580,17 +596,21 @@
"label": "Sempre desativado"
},
"gist": {
"label": "Personal Access Token {info} {input}",
"authInfo": "É necessário um token com pelo menos gist permissão"
},
"obsidian_local_rest_api": {
"endpointLabel": "Endereço Intendente {info} {input}",
"endpointInfo": "Somente HTTP está disponível porque não é possível configurar CORS para páginas de extensões",
"pathLabel": "O caminho do diretório {input}"
"pathLabel": "O caminho do diretório {input}",
"authLabel": "Authorization {input}"
},
"webdav": {
"endpointLabel": "Endereço Intendente {info} {input}",
"endpointInfo": "Somente HTTP está disponível porque não é possível configurar CORS para páginas de extensões",
"pathLabel": "O caminho do diretório {input}"
"pathLabel": "O caminho do diretório {input}",
"usernameLabel": "用户名 {input}",
"passwordLabel": "密码 {input}"
}
},
"test": "Testar",
Expand Down Expand Up @@ -772,17 +792,21 @@
"label": "Siempre apagado"
},
"gist": {
"label": "Personal Access Token {info} {input}",
"authInfo": "Se requiere un token con al menos los permisos esenciales"
},
"obsidian_local_rest_api": {
"endpointLabel": "Dirección de punto final {info} {input}",
"endpointInfo": "Solo HTTP está disponible porque no es posible configurar CORS para las páginas de extensiones",
"pathLabel": "La ruta del directorio {input}"
"pathLabel": "La ruta del directorio {input}",
"authLabel": "Authorization {input}"
},
"webdav": {
"endpointLabel": "Dirección de punto final {info} {input}",
"endpointInfo": "Solo HTTP está disponible porque no es posible configurar CORS para las páginas de extensiones",
"pathLabel": "La ruta del directorio {input}"
"pathLabel": "La ruta del directorio {input}",
"usernameLabel": "用户名 {input}",
"passwordLabel": "密码 {input}"
}
},
"test": "Probar",
Expand Down Expand Up @@ -894,17 +918,21 @@
"label": "Immer aus"
},
"gist": {
"label": "Personal Access Token {info} {input}",
"authInfo": "Ein Token mit mindestens gist Berechtigung ist erforderlich"
},
"obsidian_local_rest_api": {
"endpointLabel": "Endpunkt Adresse {info} {input}",
"endpointInfo": "Es ist nur HTTP verfügbar, da CORS nicht für Erweiterungsseiten konfiguriert werden kann",
"pathLabel": "Der Pfad des Verzeichnisses {input}"
"pathLabel": "Der Pfad des Verzeichnisses {input}",
"authLabel": "Authorization {input}"
},
"webdav": {
"endpointLabel": "Endpunkt Adresse {info} {input}",
"endpointInfo": "Es ist nur HTTP verfügbar, da CORS nicht für Erweiterungsseiten konfiguriert werden kann",
"pathLabel": "Der Pfad des Verzeichnisses {input}"
"pathLabel": "Der Pfad des Verzeichnisses {input}",
"usernameLabel": "用户名 {input}",
"passwordLabel": "密码 {input}"
}
},
"test": "Testen",
Expand Down
14 changes: 10 additions & 4 deletions src/i18n/message/app/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,19 @@ export type OptionMessage = {
authInfo?: string
}
} & {
[type in Extract<
timer.backup.Type,
"obsidian_local_rest_api" | "webdav"
>]: {
[type in Extract<timer.backup.Type, "obsidian_local_rest_api">]: {
endpointLabel: string
endpointInfo: string
pathLabel: string
authLabel: string
}
} & {
[type in Extract<timer.backup.Type, "webdav">]: {
endpointLabel: string
endpointInfo: string
pathLabel: string
usernameLabel: string
passwordLabel: string
}
}
alert: string
Expand Down

0 comments on commit dba6a2d

Please sign in to comment.