Language dropdown: Don't translate locales #712

This commit is contained in:
Michael Mayer
2020-12-16 13:27:44 +01:00
parent a5b9bc695e
commit 37f79324ce
10 changed files with 452 additions and 114 deletions

Binary file not shown.

View File

@@ -0,0 +1,286 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-10-26 21:44-0400\n"
"PO-Revision-Date: 2020-10-26 21:46-0400\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.1\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: messages.go:72
msgid "Unexpected error, please try again"
msgstr "未知错误, 请重试"
#: messages.go:73
msgid "Invalid request"
msgstr "无效请求"
#: messages.go:74
msgid "Changes could not be saved"
msgstr "无法保存更改"
#: messages.go:75
msgid "Could not be deleted"
msgstr "无法删除"
#: messages.go:76
#, c-format
msgid "%s already exists"
msgstr "%s 已存在"
#: messages.go:77 messages.go:80
msgid "Not found on server, deleted?"
msgstr "服务器上不存在此文件, 或已被删除?"
#: messages.go:78
msgid "File not found"
msgstr "未找到文件"
#: messages.go:79
msgid "Selection not found"
msgstr "未找到所选"
#: messages.go:81
msgid "Account not found"
msgstr "未找到账户"
#: messages.go:82
msgid "User not found"
msgstr "未找到用户"
#: messages.go:83
msgid "Label not found"
msgstr "未找到标签"
#: messages.go:84
msgid "Album not found"
msgstr "未找到相册"
#: messages.go:85
msgid "Not available in public mode"
msgstr "公开模式中不可用"
#: messages.go:86
msgid "not available in read-only mode"
msgstr "只读模式中不可用"
#: messages.go:87
msgid "Please log in and try again"
msgstr "请登陆后重试"
#: messages.go:88
msgid "Upload might be offensive"
msgstr "所上传文件可能会冒犯其他人"
#: messages.go:89
msgid "No items selected"
msgstr "未选择任何项目"
#: messages.go:90
msgid "Failed creating file, please check permissions"
msgstr "无法创建文件, 请检查权限"
#: messages.go:91
msgid "Failed creating folder, please check permissions"
msgstr "无法创建目录, 请检查权限"
#: messages.go:92
msgid "Could not connect, please try again"
msgstr "无法连接, 请重试"
#: messages.go:93
msgid "Invalid password, please try again"
msgstr "无效密码, 请重试"
#: messages.go:94
msgid "Feature disabled"
msgstr "特性已被禁用"
#: messages.go:95
msgid "No labels selected"
msgstr "未选择标签"
#: messages.go:96
msgid "No albums selected"
msgstr "未选择相册"
#: messages.go:97
msgid "No files available for download"
msgstr "没有可供下载的文件"
#: messages.go:98
msgid "Failed to create zip file"
msgstr "创建zip文件失败"
#: messages.go:99
#, fuzzy
#| msgid "Invalid request"
msgid "Invalid credentials"
msgstr "无效请求"
#: messages.go:100
msgid "Invalid link"
msgstr "无效链接"
#: messages.go:103
msgid "Changes successfully saved"
msgstr "更改已保存"
#: messages.go:104
msgid "Album created"
msgstr "相册已创建"
#: messages.go:105
msgid "Album saved"
msgstr "相册已保存"
#: messages.go:106
#, c-format
msgid "Album %s deleted"
msgstr "相册 %s 已被删除"
#: messages.go:107
msgid "Album contents cloned"
msgstr "相册内容已被复制"
#: messages.go:108
msgid "File removed from stack"
msgstr "文件已被移出"
#: messages.go:109
#, fuzzy
#| msgid "Labels deleted"
msgid "File deleted"
msgstr "已删除标签"
#: messages.go:110
#, c-format
msgid "Selection added to %s"
msgstr "所选项目已被加入 %s"
#: messages.go:111
#, c-format
msgid "One entry added to %s"
msgstr "已向 %s 添加一个条目"
#: messages.go:112
#, c-format
msgid "%d entries added to %s"
msgstr "%d个条目已被加入到%s"
#: messages.go:113
#, c-format
msgid "One entry removed from %s"
msgstr "已从 %s 移除一个条目"
#: messages.go:114
#, c-format
msgid "%d entries removed from %s"
msgstr "%d 个条目已被移除于 %s"
#: messages.go:115
msgid "Account created"
msgstr "已创建账户"
#: messages.go:116
msgid "Account saved"
msgstr "已保存账户"
#: messages.go:117
msgid "Account deleted"
msgstr "已删除账户"
#: messages.go:118
msgid "Settings saved"
msgstr "设置已保存"
#: messages.go:119
msgid "Password changed"
msgstr "密码已修改"
#: messages.go:120
#, c-format
msgid "Import completed in %d s"
msgstr "导入成功, 共花费 %d 秒"
#: messages.go:121
msgid "Import canceled"
msgstr "导入已被中止"
#: messages.go:122
#, c-format
msgid "Indexing completed in %d s"
msgstr "索引成功, 共花费 %d 秒"
#: messages.go:123
msgid "Indexing originals..."
msgstr "索引原始文件..."
#: messages.go:124
#, c-format
msgid "Indexing files in %s"
msgstr "为 %s 中的文件创建索引"
#: messages.go:125
msgid "Indexing canceled"
msgstr "索引已被中止"
#: messages.go:126
#, c-format
msgid "Removed %d files and %d photos"
msgstr "删除了 %d 个文件和 %d 张照片"
#: messages.go:127
#, c-format
msgid "Moving files from %s"
msgstr "正在从 %s 中移动文件"
#: messages.go:128
#, c-format
msgid "Copying files from %s"
msgstr "正在从 %s 中复制文件"
#: messages.go:129
msgid "Labels deleted"
msgstr "已删除标签"
#: messages.go:130
msgid "Label saved"
msgstr "已保存标签"
#: messages.go:131
#, c-format
msgid "%d files uploaded in %d s"
msgstr "已上传 %d 个文件, 耗时 %d 秒"
#: messages.go:132
msgid "Selection archived"
msgstr "所选项目已被归档"
#: messages.go:133
msgid "Selection restored"
msgstr "所选项目已被恢复"
#: messages.go:134
msgid "Selection marked as private"
msgstr "所选项目已被设为私有"
#: messages.go:135
msgid "Albums deleted"
msgstr "相册已被删除"
#: messages.go:136
#, c-format
msgid "Zip created in %d s"
msgstr "Zip文件创建成功, 耗时 %d 秒"

View File

@@ -35,15 +35,15 @@ msgstr ""
msgid "%{n} results"
msgstr ""
#: src/options/options.js:215
#: src/options/options.js:231
msgid "1 hour"
msgstr ""
#: src/options/options.js:217
#: src/options/options.js:233
msgid "12 hours"
msgstr ""
#: src/options/options.js:216
#: src/options/options.js:232
msgid "4 hours"
msgstr ""
@@ -107,23 +107,23 @@ msgstr ""
msgid "Added"
msgstr ""
#: src/options/options.js:225
#: src/options/options.js:241
msgid "After 1 day"
msgstr ""
#: src/options/options.js:226
#: src/options/options.js:242
msgid "After 3 days"
msgstr ""
#: src/options/options.js:227
#: src/options/options.js:243
msgid "After 7 days"
msgstr ""
#: src/options/options.js:229
#: src/options/options.js:245
msgid "After one month"
msgstr ""
#: src/options/options.js:231
#: src/options/options.js:247
msgid "After one year"
msgstr ""
@@ -131,11 +131,11 @@ msgstr ""
msgid "After selecting photos or videos from search results, you can add them to existing or new albums using the context menu."
msgstr ""
#: src/options/options.js:230
#: src/options/options.js:246
msgid "After two months"
msgstr ""
#: src/options/options.js:228
#: src/options/options.js:244
msgid "After two weeks"
msgstr ""
@@ -308,15 +308,19 @@ msgstr ""
msgid "Backup"
msgstr ""
#: src/options/options.js:250
#: src/options/options.js:266
msgid "Black"
msgstr ""
#: src/options/options.js:246
#: src/options/options.js:262
msgid "Blue"
msgstr ""
#: src/options/options.js:247
#: src/options/options.js:98
msgid "Brazilian Portuguese"
msgstr ""
#: src/options/options.js:263
msgid "Brown"
msgstr ""
@@ -328,7 +332,7 @@ msgstr ""
msgid "Browse indexed files and folders in Library."
msgstr ""
#: src/options/options.js:257
#: src/options/options.js:273
msgid "Bug Report"
msgstr ""
@@ -417,11 +421,11 @@ msgstr ""
msgid "Checked"
msgstr ""
#: src/options/options.js:105
#: src/options/options.js:118
msgid "Chinese Simplified"
msgstr ""
#: src/options/options.js:109
#: src/options/options.js:123
msgid "Chinese Traditional"
msgstr ""
@@ -552,19 +556,19 @@ msgstr ""
msgid "Current Password"
msgstr ""
#: src/options/options.js:254
#: src/options/options.js:270
msgid "Customer Support"
msgstr ""
#: src/options/options.js:245
#: src/options/options.js:261
msgid "Cyan"
msgstr ""
#: src/options/options.js:128
#: src/options/options.js:144
msgid "Cyano"
msgstr ""
#: src/options/options.js:218
#: src/options/options.js:234
msgid "Daily"
msgstr ""
@@ -572,7 +576,7 @@ msgstr ""
msgid "Day"
msgstr ""
#: src/options/options.js:124
#: src/options/options.js:140
msgid "Default"
msgstr ""
@@ -620,7 +624,7 @@ msgstr ""
msgid "Discover"
msgstr ""
#: src/options/options.js:258
#: src/options/options.js:274
msgid "Donations"
msgstr ""
@@ -672,7 +676,7 @@ msgstr ""
msgid "Duplicates will be skipped and only appear once."
msgstr ""
#: src/options/options.js:93
#: src/options/options.js:103
msgid "Dutch"
msgstr ""
@@ -709,7 +713,7 @@ msgstr ""
msgid "Enabled"
msgstr ""
#: src/options/options.js:77
#: src/options/options.js:78
msgid "English"
msgstr ""
@@ -721,7 +725,7 @@ msgstr ""
msgid "Errors"
msgstr ""
#: src/options/options.js:219
#: src/options/options.js:235
msgid "Every two days"
msgstr ""
@@ -763,7 +767,7 @@ msgstr ""
msgid "Failure while importing uploaded files"
msgstr ""
#: src/options/options.js:158
#: src/options/options.js:174
msgid "Fast"
msgstr ""
@@ -777,7 +781,7 @@ msgstr ""
msgid "Favorites"
msgstr ""
#: src/options/options.js:256
#: src/options/options.js:272
msgid "Feature Request"
msgstr ""
@@ -830,7 +834,7 @@ msgstr ""
msgid "Folders"
msgstr ""
#: src/options/options.js:85
#: src/options/options.js:88
msgid "French"
msgstr ""
@@ -842,19 +846,19 @@ msgstr ""
msgid "General"
msgstr ""
#: src/options/options.js:81
#: src/options/options.js:83
msgid "German"
msgstr ""
#: src/options/options.js:240
#: src/options/options.js:256
msgid "Gold"
msgstr ""
#: src/options/options.js:243
#: src/options/options.js:259
msgid "Green"
msgstr ""
#: src/options/options.js:249
#: src/options/options.js:265
msgid "Grey"
msgstr ""
@@ -888,7 +892,7 @@ msgstr ""
msgid "Hide Private"
msgstr ""
#: src/options/options.js:113
#: src/options/options.js:128
msgid "Hindi"
msgstr ""
@@ -896,7 +900,7 @@ msgstr ""
msgid "How can we help?"
msgstr ""
#: src/options/options.js:181
#: src/options/options.js:197
msgid "Hybrid"
msgstr ""
@@ -911,7 +915,7 @@ msgstr ""
msgid "image"
msgstr ""
#: src/options/options.js:196
#: src/options/options.js:212
msgid "Image"
msgstr ""
@@ -1021,7 +1025,7 @@ msgstr ""
msgid "Latitude"
msgstr ""
#: src/options/options.js:132
#: src/options/options.js:148
msgid "Lavender"
msgstr ""
@@ -1055,7 +1059,7 @@ msgstr ""
msgid "Like"
msgstr ""
#: src/options/options.js:242
#: src/options/options.js:258
msgid "Lime"
msgstr ""
@@ -1072,7 +1076,7 @@ msgstr ""
msgid "List"
msgstr ""
#: src/options/options.js:204
#: src/options/options.js:220
msgid "Live"
msgstr ""
@@ -1114,7 +1118,7 @@ msgstr ""
msgid "Longitude"
msgstr ""
#: src/options/options.js:236
#: src/options/options.js:252
msgid "Magenta"
msgstr ""
@@ -1130,7 +1134,7 @@ msgstr ""
msgid "Manual Upload"
msgstr ""
#: src/options/options.js:162
#: src/options/options.js:178
msgid "Medium"
msgstr ""
@@ -1159,7 +1163,7 @@ msgstr ""
msgid "Month"
msgstr ""
#: src/options/options.js:136
#: src/options/options.js:152
msgid "Moonlight"
msgstr ""
@@ -1221,8 +1225,8 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: src/options/options.js:214
#: src/options/options.js:224
#: src/options/options.js:230
#: src/options/options.js:240
#: src/pages/settings/sync.vue:43
msgid "Never"
msgstr ""
@@ -1289,7 +1293,7 @@ msgstr ""
msgid "Non-photographic and low-quality images require a review before they appear in search results."
msgstr ""
#: src/options/options.js:154
#: src/options/options.js:170
msgid "None"
msgstr ""
@@ -1327,7 +1331,7 @@ msgstr ""
#: src/component/navigation.vue:400
#: src/component/navigation.vue:1404
#: src/options/options.js:173
#: src/options/options.js:189
msgid "Offline"
msgstr ""
@@ -1337,7 +1341,7 @@ msgstr ""
msgid "Oldest first"
msgstr ""
#: src/options/options.js:220
#: src/options/options.js:236
msgid "Once a week"
msgstr ""
@@ -1363,11 +1367,11 @@ msgstr ""
msgid "One result"
msgstr ""
#: src/options/options.js:140
#: src/options/options.js:156
msgid "Onyx"
msgstr ""
#: src/options/options.js:239
#: src/options/options.js:255
msgid "Orange"
msgstr ""
@@ -1390,11 +1394,11 @@ msgstr ""
msgid "Originals"
msgstr ""
#: src/options/options.js:259
#: src/options/options.js:275
msgid "Other"
msgstr ""
#: src/options/options.js:189
#: src/options/options.js:205
msgid "Outdoor"
msgstr ""
@@ -1447,7 +1451,7 @@ msgstr ""
msgid "Photos"
msgstr ""
#: src/options/options.js:237
#: src/options/options.js:253
msgid "Pink"
msgstr ""
@@ -1483,7 +1487,7 @@ msgstr ""
msgid "Please enter your name and password:"
msgstr ""
#: src/options/options.js:97
#: src/options/options.js:108
msgid "Polish"
msgstr ""
@@ -1525,7 +1529,7 @@ msgstr ""
msgid "Private"
msgstr ""
#: src/options/options.js:255
#: src/options/options.js:271
msgid "Product Feedback"
msgstr ""
@@ -1533,7 +1537,7 @@ msgstr ""
msgid "Projection"
msgstr ""
#: src/options/options.js:235
#: src/options/options.js:251
msgid "Purple"
msgstr ""
@@ -1549,11 +1553,11 @@ msgstr ""
msgid "Random"
msgstr ""
#: src/options/options.js:144
#: src/options/options.js:160
msgid "Raspberry"
msgstr ""
#: src/options/options.js:200
#: src/options/options.js:216
msgid "Raw"
msgstr ""
@@ -1573,7 +1577,7 @@ msgstr ""
msgid "Recently edited"
msgstr ""
#: src/options/options.js:238
#: src/options/options.js:254
msgid "Red"
msgstr ""
@@ -1639,7 +1643,7 @@ msgstr ""
msgid "Review"
msgstr ""
#: src/options/options.js:101
#: src/options/options.js:113
msgid "Russian"
msgstr ""
@@ -1686,7 +1690,7 @@ msgstr ""
msgid "Season"
msgstr ""
#: src/options/options.js:148
#: src/options/options.js:164
msgid "Seaweed"
msgstr ""
@@ -1800,11 +1804,11 @@ msgstr ""
msgid "Size"
msgstr ""
#: src/options/options.js:117
#: src/options/options.js:133
msgid "Slovak"
msgstr ""
#: src/options/options.js:166
#: src/options/options.js:182
msgid "Slow"
msgstr ""
@@ -1823,7 +1827,7 @@ msgstr ""
msgid "Source"
msgstr ""
#: src/options/options.js:89
#: src/options/options.js:93
msgid "Spanish"
msgstr ""
@@ -1864,7 +1868,7 @@ msgstr ""
msgid "Storage Folder"
msgstr ""
#: src/options/options.js:177
#: src/options/options.js:193
msgid "Streets"
msgstr ""
@@ -1894,7 +1898,7 @@ msgstr ""
msgid "Taken"
msgstr ""
#: src/options/options.js:244
#: src/options/options.js:260
msgid "Teal"
msgstr ""
@@ -1957,7 +1961,7 @@ msgstr ""
msgid "Token"
msgstr ""
#: src/options/options.js:185
#: src/options/options.js:201
msgid "Topographic"
msgstr ""
@@ -2109,7 +2113,7 @@ msgstr ""
#: src/model/file.js:172
#: src/model/photo.js:493
#: src/model/photo.js:507
#: src/options/options.js:208
#: src/options/options.js:224
msgid "Video"
msgstr ""
@@ -2136,7 +2140,7 @@ msgstr ""
msgid "WebDAV Upload"
msgstr ""
#: src/options/options.js:248
#: src/options/options.js:264
msgid "White"
msgstr ""
@@ -2145,7 +2149,7 @@ msgstr ""
msgid "Year"
msgstr ""
#: src/options/options.js:241
#: src/options/options.js:257
msgid "Yellow"
msgstr ""

View File

@@ -74,49 +74,65 @@ export const MonthsShort = () => {
export const Languages = () => [
{
"text": $gettext("English"),
"text": "English",
"translated": $gettext("English"),
"value": "en",
},
{
"text": $gettext("German"),
"text": "Deutsch",
"translated": $gettext("German"),
"value": "de",
},
{
"text": $gettext("French"),
"value": "fr",
},
{
"text": $gettext("Spanish"),
"text": "Español",
"translated": $gettext("Spanish"),
"value": "es",
},
{
"text": $gettext("Dutch"),
"value": "nl",
"text": "Français",
"translated": $gettext("French"),
"value": "fr",
},
{
"text": $gettext("Polish"),
"value": "pl",
},
{
"text": $gettext("Russian"),
"value": "ru",
},
{
"text": $gettext("Chinese Simplified"),
"value": "zh",
},
{
"text": $gettext("Chinese Traditional"),
"value": "zh_tw",
},
{
"text": $gettext("Hindi"),
"text": "हिन्दी",
"translated": $gettext("Hindi"),
"value": "hi",
},
{
"text": $gettext("Slovak"),
"text": "Nederlands",
"translated": $gettext("Dutch"),
"value": "nl",
},
{
"text": "Polski",
"translated": $gettext("Polish"),
"value": "pl",
},
{
"text": "Português do Brasil",
"translated": $gettext("Brazilian Portuguese"),
"value": "pt_BR",
},
{
"text": "Русский",
"translated": $gettext("Russian"),
"value": "ru",
},
{
"text": "Slovenčina",
"translated": $gettext("Slovak"),
"value": "sk",
},
{
"text": "简体中文",
"translated": $gettext("Chinese Simplified"),
"value": "zh",
},
{
"text": "繁体中文",
"translated": $gettext("Chinese Traditional"),
"value": "zh_TW",
},
];
export const Themes = () => [

View File

@@ -2,9 +2,10 @@ package api
import (
"fmt"
"github.com/photoprism/photoprism/internal/entity"
"net/http"
"github.com/photoprism/photoprism/internal/entity"
"github.com/photoprism/photoprism/internal/service"
"github.com/photoprism/photoprism/internal/photoprism"

View File

@@ -29,8 +29,8 @@ func TestMsg(t *testing.T) {
t.Run("already exists german", func(t *testing.T) {
SetLocale("de")
msgDE := Msg(ErrAlreadyExists, "Eine Katze")
assert.Equal(t, "Eine Katze existiert bereits", msgDE)
msgTrans := Msg(ErrAlreadyExists, "Eine Katze")
assert.Equal(t, "Eine Katze existiert bereits", msgTrans)
SetLocale("")
msgDefault := Msg(ErrAlreadyExists, "A cat")
assert.Equal(t, "A cat already exists", msgDefault)
@@ -38,8 +38,17 @@ func TestMsg(t *testing.T) {
t.Run("already exists polish", func(t *testing.T) {
SetLocale("pl")
msgPL := Msg(ErrAlreadyExists, "Kot")
assert.Equal(t, "Kot już istnieje", msgPL)
msgTrans := Msg(ErrAlreadyExists, "Kot")
assert.Equal(t, "Kot już istnieje", msgTrans)
SetLocale("")
msgDefault := Msg(ErrAlreadyExists, "A cat")
assert.Equal(t, "A cat already exists", msgDefault)
})
t.Run("Brazilian Portuguese", func(t *testing.T) {
SetLocale("pt_BR")
msgTrans := Msg(ErrAlreadyExists, "Gata")
assert.Equal(t, "Gata já existe", msgTrans)
SetLocale("")
msgDefault := Msg(ErrAlreadyExists, "A cat")
assert.Equal(t, "A cat already exists", msgDefault)

View File

@@ -9,16 +9,18 @@ import (
type Locale string
const (
German Locale = "de"
English Locale = "en"
Spanish Locale = "es"
French Locale = "fr"
Dutch Locale = "nl"
Polish Locale = "pl"
Portuguese Locale = "pt"
Russian Locale = "ru"
Chinese Locale = "zh"
Default = English
German Locale = "de"
English Locale = "en"
Spanish Locale = "es"
French Locale = "fr"
Dutch Locale = "nl"
Polish Locale = "pl"
Portuguese Locale = "pt"
BrazilianPortuguese Locale = "pt_BR"
Russian Locale = "ru"
ChineseSimplified Locale = "zh"
ChineseTraditional Locale = "zh_TW"
Default = English
)
var localeDir = "../../assets/locales"
@@ -29,11 +31,15 @@ func SetDir(dir string) {
}
func SetLocale(loc string) {
if len(loc) < 2 {
locale = Default
} else {
switch len(loc) {
case 2:
loc = strings.ToLower(loc[:2])
locale = Locale(loc)
case 5:
loc = strings.ToLower(loc[:2]) + "_" + strings.ToUpper(loc[3:5])
locale = Locale(loc)
default:
locale = Default
}
gotext.Configure(localeDir, string(locale), "default")

View File

@@ -13,7 +13,23 @@ func TestSetLocale(t *testing.T) {
SetLocale("De")
assert.Equal(t, German, locale)
SetLocale("de_AT")
assert.Equal(t, German, locale)
assert.Equal(t, Locale("de_AT"), locale)
SetLocale("pt")
assert.Equal(t, Portuguese, locale)
SetLocale("pt_br")
assert.Equal(t, BrazilianPortuguese, locale)
SetLocale("zh")
assert.Equal(t, ChineseSimplified, locale)
SetLocale("zh_TW")
assert.Equal(t, ChineseTraditional, locale)
SetLocale("ru")
assert.Equal(t, Russian, locale)
SetLocale("fr")
assert.Equal(t, French, locale)
SetLocale("nl")
assert.Equal(t, Dutch, locale)
SetLocale("es")
assert.Equal(t, Spanish, locale)
SetLocale("PL")
assert.Equal(t, Polish, locale)
SetLocale("")