zh-TW templates, improve language matching, add issing languages to config

This commit is contained in:
or-else
2025-06-07 19:03:08 +03:00
parent 6b9f1da0f8
commit 48747eec9a
6 changed files with 148 additions and 4 deletions
+1 -1
View File
@@ -144,7 +144,7 @@ All client software has support for [internationalization](docs/translations.md)
| English | ✓ | ✓ | ✓ | ✓ |
| Arabic | | ✓ | | |
| Chinese simplified | ✓ | ✓ | ✓ | ✓ |
| Chinese traditional | | ✓ | ✓ | ✓ |
| Chinese traditional | ✓ | ✓ | ✓ | ✓ |
| French | ✓ | ✓ | ✓ | |
| German | | ✓ | ✓ | |
| Hindi | | | ✓ | |
@@ -0,0 +1,68 @@
{{/*
繁體中文
此模板定義密碼重設電子郵件的內容。
說明請參見 ./email-validation-en.templ
*/}}
{{define "subject" -}}
重設 Tinode 密碼
{{- end}}
{{define "body_html" -}}
<html>
<body>
<p>您好。</p>
<p>您最近請求重設您的 <a href="{{.HostUrl}}">Tinode</a> 帳戶密碼。
請使用以下連結或驗證碼進行重設。此連結和驗證碼僅在接下來的 24 小時內有效。</p>
<blockquote><a href="{{.HostUrl}}#reset?scheme={{.Scheme}}&code={{.Code}}&cred={{.Cred}}">點擊</a>重設您的密碼。</blockquote>
<p>如果您無法使用上方的連結,請複製以下網址並貼到您的網頁瀏覽器中:</p>
<blockquote>
<a href="{{.HostUrl}}#reset?scheme={{.Scheme}}&code={{.Code}}&cred={{.Cred}}">{{.HostUrl}}#reset?scheme={{.Scheme}}&code={{.Code}}&cred={{.Cred}}</a>
</blockquote>
<p>如有提示,請輸入以下驗證碼:</p>
<blockquote><big>{{.Code}}</big></blockquote>
{{with .Login}}
<p>如果您忘記了,您的登入名稱是:{{.}}。</p>
{{end}}
<p>如果您沒有請求密碼重設,請忽略此訊息。</p>
<p><a href="https://tinode.co/">Tinode 團隊</a></p>
</body>
</html>
{{- end}}
{{define "body_plain" -}}
您好。
您最近請求重設您的 Tinode 帳戶密碼 ({{.HostUrl}})。
請使用以下連結或驗證碼進行重設。此連結和驗證碼僅在接下來的 24 小時內有效。
{{.HostUrl}}#reset?scheme={{.Scheme}}&code={{.Code}}&cred={{.Cred}}
如果您無法點擊上方的連結,請複製並貼到您的網頁瀏覽器中。
如有提示,請輸入以下驗證碼:
{{.Code}}
{{- with .Login}}
如果您忘記了,您的登入名稱是:{{.}}。
{{end -}}
如果您沒有請求密碼重設,請忽略此訊息。
Tinode 團隊
https://tinode.co/
{{- end}}
+63
View File
@@ -0,0 +1,63 @@
{{/*
CHINESE Traditional (Taiwan)
繁體中文
此模板定義發送給用戶的電子郵件內容,用於請求確認註冊電子郵件地址。
語法請參見 https://golang.org/pkg/text/template/
模板必須包含以下部分:
- 'subject': 電子郵件的主題行
- 以下一個或兩個:
- 'body_html': 訊息的 HTML 內容。將添加標頭 "Content-type: text/html"。
- 'body_plain': 訊息的純文字內容。將添加標頭 "Content-type: text/plain"。
如果同時包含 body_html 和 body_plain,兩者都將作為 'multipart/alternative' 訊息的部分發送。
*/}}
{{define "subject" -}}
Tinode 註冊:確認電子郵件
{{- end}}
{{define "body_html" -}}
<html>
<body>
<p>您好。</p>
<p>您收到此訊息是因為有人使用您的電子郵件在
<a href="{{.HostUrl}}">Tinode</a> 註冊。</p>
<p><a href="{{.HostUrl}}#cred?method=email&code={{.Code}}&token={{.Token}}">點擊確認</a>
或前往
<a href="{{.HostUrl}}#cred?what=email">{{.HostUrl}}#cred?method=email</a>
並輸入以下驗證碼:</p>
<blockquote><big>{{.Code}}</big></blockquote>
<p>您可能需要輸入登入名稱和密碼。</p>
<p>如果您沒有在 Tinode 註冊,請忽略此訊息。</p>
<p><a href="https://tinode.co/">Tinode 團隊</a></p>
</body>
</html>
{{- end}}
{{define "body_plain" -}}
您好。
您收到此訊息是因為有人使用您的電子郵件在 Tinode ({{.HostUrl}}) 註冊。
點擊連結 {{.HostUrl}}#cred?method=email&code={{.Code}}&token={{.Token}} 進行確認,或前往 {{.HostUrl}}#cred?what=email
並輸入以下驗證碼:
{{.Code}}
您可能需要輸入登入名稱和密碼。
如果您沒有在 Tinode 註冊,請忽略此訊息。
Tinode 團隊
https://tinode.co/
{{- end}}
+8
View File
@@ -0,0 +1,8 @@
{{/*
繁體中文
通用確認和密碼重設簡訊模板。
*/}}
Tinode 確認驗證碼:{{.Code}}
{{.HostUrl}}
+2 -2
View File
@@ -421,7 +421,7 @@
// Optional list of human languages to try to load templates for. If you don't care about i18n,
// leave it blank or remove. The first language in the list is the default language.
"languages": ["en", "es", "fr", "ru", "vi", "zh"],
"languages": ["en", "es", "fr", "pt", "ru", "uk", "vi", "zh", "zh-TW"],
// Message template for credential validation.
// The file path itself is treated as a template. It's resolved by using the
@@ -462,7 +462,7 @@
// Optional list of locales to try to load templates for. If you don't care about i18n,
// leave it blank or remove. The first language in the list is the default language.
"languages": ["en", "es", "fr", "pt", "ru", "vi", "zh"],
"languages": ["en", "es", "fr", "pt", "ru", "uk", "vi", "zh", "zh-TW"],
// String to use in the From field of the SMS.
"sender": "Tinode",
+6 -1
View File
@@ -274,7 +274,12 @@ func (v *validator) Request(user t.Uid, email, lang, resp string, tmpToken []byt
var template *textt.Template
if v.langMatcher != nil {
_, idx := i18n.MatchStrings(v.langMatcher, lang)
// Find the template for the requested language.
// Make sure the language tag is standartized. Matcher is a bit dumber than Parse().
normalized, _ := i18n.Parse(lang)
// The matched tag is usualy not in the list of available languages (e.g. es_ES -> es-u-rg-eszzzz).
// Use index to find the template instead of tag.
_, idx := i18n.MatchStrings(v.langMatcher, normalized.String())
template = v.validationTempl[idx]
} else {
template = v.validationTempl[0]