feat: 添加应用多语言国际化支持
- 新增英文、日文、粤语支持 - 添加本地化图片资源 - 更新 Xcode 项目配置支持多语言 - 重构代码使用本地化字符串 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c65fb02a94
commit
d8d2ad48e5
|
|
@ -86,11 +86,14 @@
|
|||
};
|
||||
};
|
||||
buildConfigurationList = 45F070D32E249A0700B1170B /* Build configuration list for PBXProject "ChromiumCertificate" */;
|
||||
developmentRegion = "zh-Hans";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
Base,
|
||||
"zh-Hans",
|
||||
en,
|
||||
ja,
|
||||
yue,
|
||||
);
|
||||
mainGroup = 45F070CF2E249A0700B1170B;
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
|
|
@ -184,6 +187,7 @@
|
|||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
|
|
@ -240,6 +244,7 @@
|
|||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
@ -248,6 +253,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = ChromiumCertificate/ChromiumCertificate.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
|
|
@ -257,6 +263,7 @@
|
|||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = "Chromium 喜报";
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
|
@ -276,6 +283,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = ChromiumCertificate/ChromiumCertificate.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
|
|
@ -285,6 +293,7 @@
|
|||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = "Chromium 喜报";
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
|
|
|||
BIN
ChromiumCertificate/Assets.xcassets/AnnouncementBg.imageset/29B43581-1218-4679-8429-81BB27CE30E4.png
vendored
Normal file
BIN
ChromiumCertificate/Assets.xcassets/AnnouncementBg.imageset/29B43581-1218-4679-8429-81BB27CE30E4.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
|
|
@ -3,10 +3,28 @@
|
|||
{
|
||||
"filename" : "bg.png",
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"filename" : "bg 1.png",
|
||||
"idiom" : "universal",
|
||||
"locale" : "zh-Hans"
|
||||
},
|
||||
{
|
||||
"filename" : "29B43581-1218-4679-8429-81BB27CE30E4.png",
|
||||
"idiom" : "universal",
|
||||
"locale" : "en"
|
||||
},
|
||||
{
|
||||
"filename" : "D585A608-918C-420B-9400-6A345F88184B.png",
|
||||
"idiom" : "universal",
|
||||
"locale" : "ja"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"localizable" : true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
ChromiumCertificate/Assets.xcassets/AnnouncementBg.imageset/D585A608-918C-420B-9400-6A345F88184B.png
vendored
Normal file
BIN
ChromiumCertificate/Assets.xcassets/AnnouncementBg.imageset/D585A608-918C-420B-9400-6A345F88184B.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
BIN
ChromiumCertificate/Assets.xcassets/AnnouncementBg.imageset/bg 1.png
vendored
Normal file
BIN
ChromiumCertificate/Assets.xcassets/AnnouncementBg.imageset/bg 1.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
|
|
@ -15,12 +15,12 @@ struct ChromiumBasedAppListView: View {
|
|||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
HStack {
|
||||
Text("所有带有 Chromium 的应用程序").font(.headline)
|
||||
Text("LISTVIEW_TITLE").font(.headline)
|
||||
Spacer()
|
||||
Button {
|
||||
self.isPresented.toggle()
|
||||
} label: {
|
||||
Text("关闭")
|
||||
Text("LISTVIEW_CLOSE")
|
||||
}
|
||||
}.padding()
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ struct ChromiumBasedAppListView: View {
|
|||
|
||||
ScrollView {
|
||||
if chromiumAppsList.isEmpty {
|
||||
Text("你的电脑没有遭受 Chromium 的荼毒!望君继续努力。").multilineTextAlignment(.center).padding()
|
||||
Text("LISTVIEW_NO_CHRIMIUM_APPS_FOUND").multilineTextAlignment(.center).padding()
|
||||
}
|
||||
VStack(spacing: 8) {
|
||||
ForEach(Array(chromiumAppsList.enumerated()), id: \.element.id) { index, chromiumApp in
|
||||
|
|
@ -51,6 +51,17 @@ struct ChromiumBasedAppListView: View {
|
|||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
#Preview("中文") {
|
||||
ChromiumBasedAppListView(isPresented: .constant(true))
|
||||
.environment(\.locale, Locale(identifier: "zh-Hans"))
|
||||
}
|
||||
|
||||
#Preview("English") {
|
||||
ChromiumBasedAppListView(isPresented: .constant(true))
|
||||
.environment(\.locale, Locale(identifier: "en"))
|
||||
}
|
||||
|
||||
#Preview("日本語") {
|
||||
ChromiumBasedAppListView(isPresented: .constant(true))
|
||||
.environment(\.locale, Locale(identifier: "ja"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,20 +32,23 @@ struct ContentView: View {
|
|||
let count = ChromiumDetector.getChromiumAppCount()
|
||||
|
||||
@State private var presentSheet: Bool = false
|
||||
@Environment(\.locale) private var locale
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Image("AnnouncementBg").resizable().frame(width: 640, height: 480)
|
||||
VStack {
|
||||
Text(count != 0 ? "这台 Mac 上一共有 \(count) 个 Chromium" : "这台 Mac 一个 Chromium 都没有!")
|
||||
Text("MAINVIEW_CHROMIUM_COUNTER \(count)")
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.system(size: 35, weight: .semibold))
|
||||
.foregroundColor(Color("TextColor"))
|
||||
.stroke(color: Color("TextBorderColor"), width: 5)
|
||||
.padding(.horizontal)
|
||||
|
||||
Button {
|
||||
self.presentSheet.toggle()
|
||||
} label: {
|
||||
Text("查看列表").font(.system(size: 20)).padding(.horizontal).padding(.vertical, 8)
|
||||
Text("MAINVIEW_SEE_LIST").font(.system(size: 20)).padding(.horizontal).padding(.vertical, 8)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.red)
|
||||
|
|
@ -58,6 +61,17 @@ struct ContentView: View {
|
|||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
#Preview("中文") {
|
||||
ContentView()
|
||||
.environment(\.locale, Locale(identifier: "zh-Hans"))
|
||||
}
|
||||
|
||||
#Preview("English") {
|
||||
ContentView()
|
||||
.environment(\.locale, Locale(identifier: "en"))
|
||||
}
|
||||
|
||||
#Preview("日本語") {
|
||||
ContentView()
|
||||
.environment(\.locale, Locale(identifier: "ja"))
|
||||
}
|
||||
|
|
|
|||
200
ChromiumCertificate/Localizable.xcstrings
Normal file
200
ChromiumCertificate/Localizable.xcstrings
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
{
|
||||
"sourceLanguage" : "en",
|
||||
"strings" : {
|
||||
"LISTVIEW_CLOSE" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Close"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "閉じる"
|
||||
}
|
||||
},
|
||||
"yue" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "閂"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "关闭"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"LISTVIEW_NO_CHRIMIUM_APPS_FOUND" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "No Chromium-based apps detected! Keep it up!"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Chromiumアプリは検出されませんでした!その調子で頑張ってください!"
|
||||
}
|
||||
},
|
||||
"yue" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "冇搵度Chromium嘅app,望君繼續努力!"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "你的电脑没有遭受 Chromium 的荼毒!望君继续努力。"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"LISTVIEW_TITLE" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "All Chromium-based Apps"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Chromiumベースのアプリ一覧"
|
||||
}
|
||||
},
|
||||
"yue" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "所有基於Chromium嘅app"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "所有带有 Chromium 的应用程序"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"MAINVIEW_CHROMIUM_COUNTER %lld" : {
|
||||
"comment" : "Showing below the “congratulations” (喜报) title",
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"variations" : {
|
||||
"plural" : {
|
||||
"one" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "%lld app with Chromium discovered in this Mac"
|
||||
}
|
||||
},
|
||||
"other" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "%lld apps with Chromium discovered in this Mac"
|
||||
}
|
||||
},
|
||||
"zero" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "No Chromium apps found on this Mac!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"variations" : {
|
||||
"plural" : {
|
||||
"other" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "このMacに%lld個のChromiumアプリが見つかりました"
|
||||
}
|
||||
},
|
||||
"zero" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "このMacにはChromiumアプリがありません!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"yue" : {
|
||||
"variations" : {
|
||||
"plural" : {
|
||||
"other" : {
|
||||
"stringUnit" : {
|
||||
"state" : "new",
|
||||
"value" : "%lld apps with Chromium discovered in this Mac"
|
||||
}
|
||||
},
|
||||
"zero" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "係呢台Mac上冇搵度任何Chromium app!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"variations" : {
|
||||
"plural" : {
|
||||
"other" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "这台 Mac 上一共有 %lld 个 Chromium"
|
||||
}
|
||||
},
|
||||
"zero" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "这台 Mac 一个 Chromium 都没有!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"MAINVIEW_SEE_LIST" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "View List"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "リストを見る"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "查看列表"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"version" : "1.0"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user