39 lines
1.8 KiB
Swift
39 lines
1.8 KiB
Swift
import Testing
|
|
@testable import Localization
|
|
|
|
// 不切换全局语言:其他测试套件并行运行,依赖中文原文
|
|
@Suite struct LocalizationTests {
|
|
@Test func translatesExactAndTemplates() {
|
|
let table = Translations.shared
|
|
#expect(table.translate("内存") == "Memory")
|
|
#expect(table.translate("AI 用量") == "AI Usage")
|
|
#expect(table.translate("每日") == "Daily")
|
|
#expect(table.translate("每周") == "Weekly")
|
|
#expect(table.translate("累计") == "Cumulative")
|
|
#expect(table.translate("上次额度") == "Previous quota")
|
|
#expect(table.translate("上次成功:20:45") == "Last successful: 20:45")
|
|
#expect(table.translate("最近刷新:20:53") == "Last refresh: 20:53")
|
|
#expect(table.translate("12 个进程") == "12 processes")
|
|
#expect(table.translate("1 个进程") == "1 process")
|
|
#expect(table.translate("节气与时令") == "Solar terms and seasons")
|
|
#expect(table.translate("一九第2天") == "Nine 1, day 2")
|
|
#expect(table.translate("不存在的文案") == nil)
|
|
}
|
|
|
|
@Test func translatesCapturedChinese() {
|
|
// 插进来的中文也会再翻一次
|
|
#expect(Translations.shared.translate("设置 · 关于") == "Settings · About")
|
|
}
|
|
|
|
@Test func defaultsToChinese() {
|
|
#expect(tr("内存") == "内存")
|
|
#expect(AppLanguage.english.resolved == .english)
|
|
}
|
|
|
|
@Test func translatesWebDAVControlsAndErrors() {
|
|
#expect(Translations.shared.translate("设置同步") == "Settings Sync")
|
|
#expect(Translations.shared.translate("下载并应用") == "Download and Apply")
|
|
#expect(Translations.shared.translate("WebDAV 返回错误:503") == "WebDAV returned an error: 503")
|
|
}
|
|
}
|