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" */;
|
buildConfigurationList = 45F070D32E249A0700B1170B /* Build configuration list for PBXProject "ChromiumCertificate" */;
|
||||||
developmentRegion = "zh-Hans";
|
developmentRegion = en;
|
||||||
hasScannedForEncodings = 0;
|
hasScannedForEncodings = 0;
|
||||||
knownRegions = (
|
knownRegions = (
|
||||||
Base,
|
Base,
|
||||||
"zh-Hans",
|
"zh-Hans",
|
||||||
|
en,
|
||||||
|
ja,
|
||||||
|
yue,
|
||||||
);
|
);
|
||||||
mainGroup = 45F070CF2E249A0700B1170B;
|
mainGroup = 45F070CF2E249A0700B1170B;
|
||||||
minimizedProjectReferenceProxies = 1;
|
minimizedProjectReferenceProxies = 1;
|
||||||
|
|
@ -184,6 +187,7 @@
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
|
|
@ -240,6 +244,7 @@
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
|
@ -248,6 +253,7 @@
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = ChromiumCertificate/ChromiumCertificate.entitlements;
|
CODE_SIGN_ENTITLEMENTS = ChromiumCertificate/ChromiumCertificate.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
|
@ -257,6 +263,7 @@
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = "Chromium 喜报";
|
INFOPLIST_KEY_CFBundleDisplayName = "Chromium 喜报";
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
|
||||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
|
@ -276,6 +283,7 @@
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = ChromiumCertificate/ChromiumCertificate.entitlements;
|
CODE_SIGN_ENTITLEMENTS = ChromiumCertificate/ChromiumCertificate.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
|
@ -285,6 +293,7 @@
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = "Chromium 喜报";
|
INFOPLIST_KEY_CFBundleDisplayName = "Chromium 喜报";
|
||||||
|
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
|
||||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(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",
|
"filename" : "bg.png",
|
||||||
"idiom" : "universal"
|
"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" : {
|
"info" : {
|
||||||
"author" : "xcode",
|
"author" : "xcode",
|
||||||
"version" : 1
|
"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 {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
HStack {
|
HStack {
|
||||||
Text("所有带有 Chromium 的应用程序").font(.headline)
|
Text("LISTVIEW_TITLE").font(.headline)
|
||||||
Spacer()
|
Spacer()
|
||||||
Button {
|
Button {
|
||||||
self.isPresented.toggle()
|
self.isPresented.toggle()
|
||||||
} label: {
|
} label: {
|
||||||
Text("关闭")
|
Text("LISTVIEW_CLOSE")
|
||||||
}
|
}
|
||||||
}.padding()
|
}.padding()
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ struct ChromiumBasedAppListView: View {
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
if chromiumAppsList.isEmpty {
|
if chromiumAppsList.isEmpty {
|
||||||
Text("你的电脑没有遭受 Chromium 的荼毒!望君继续努力。").multilineTextAlignment(.center).padding()
|
Text("LISTVIEW_NO_CHRIMIUM_APPS_FOUND").multilineTextAlignment(.center).padding()
|
||||||
}
|
}
|
||||||
VStack(spacing: 8) {
|
VStack(spacing: 8) {
|
||||||
ForEach(Array(chromiumAppsList.enumerated()), id: \.element.id) { index, chromiumApp in
|
ForEach(Array(chromiumAppsList.enumerated()), id: \.element.id) { index, chromiumApp in
|
||||||
|
|
@ -51,6 +51,17 @@ struct ChromiumBasedAppListView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview("中文") {
|
||||||
ChromiumBasedAppListView(isPresented: .constant(true))
|
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()
|
let count = ChromiumDetector.getChromiumAppCount()
|
||||||
|
|
||||||
@State private var presentSheet: Bool = false
|
@State private var presentSheet: Bool = false
|
||||||
|
@Environment(\.locale) private var locale
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Image("AnnouncementBg").resizable().frame(width: 640, height: 480)
|
Image("AnnouncementBg").resizable().frame(width: 640, height: 480)
|
||||||
VStack {
|
VStack {
|
||||||
Text(count != 0 ? "这台 Mac 上一共有 \(count) 个 Chromium" : "这台 Mac 一个 Chromium 都没有!")
|
Text("MAINVIEW_CHROMIUM_COUNTER \(count)")
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
.font(.system(size: 35, weight: .semibold))
|
.font(.system(size: 35, weight: .semibold))
|
||||||
.foregroundColor(Color("TextColor"))
|
.foregroundColor(Color("TextColor"))
|
||||||
.stroke(color: Color("TextBorderColor"), width: 5)
|
.stroke(color: Color("TextBorderColor"), width: 5)
|
||||||
|
.padding(.horizontal)
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
self.presentSheet.toggle()
|
self.presentSheet.toggle()
|
||||||
} label: {
|
} 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)
|
.buttonStyle(.borderedProminent)
|
||||||
.tint(.red)
|
.tint(.red)
|
||||||
|
|
@ -58,6 +61,17 @@ struct ContentView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview("中文") {
|
||||||
ContentView()
|
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