Skip to content

Commit

Permalink
Localization support & Simplified Chinese translation
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeBlack committed Sep 18, 2024
1 parent 345097c commit 20ba18f
Show file tree
Hide file tree
Showing 56 changed files with 2,486 additions and 214 deletions.
22 changes: 22 additions & 0 deletions LiveContainerSwiftUI/Assets.xcassets/GitHub.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
File renamed without changes
File renamed without changes
48 changes: 24 additions & 24 deletions LiveContainerSwiftUI/LCAppBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct LCAppBanner : View, LCAppSettingDelegate {
HStack {
Text(appInfo.displayName()).font(.system(size: 16)).bold()
if model.uiIsShared {
Text("SHARED").font(.system(size: 8)).bold().padding(2)
Text("lc.appBanner.shared".loc).font(.system(size: 8)).bold().padding(2)
.frame(width: 50, height:16)
.background(
Capsule().fill(Color("BadgeColor"))
Expand All @@ -89,15 +89,15 @@ struct LCAppBanner : View, LCAppSettingDelegate {
}

Text("\(appInfo.version()) - \(appInfo.bundleIdentifier())").font(.system(size: 12)).foregroundColor(Color("FontColor"))
Text(model.uiDataFolder == nil ? "Data folder not created yet" : model.uiDataFolder!).font(.system(size: 8)).foregroundColor(Color("FontColor"))
Text(LocalizedStringKey(model.uiDataFolder == nil ? "lc.appBanner.noDataFolder".loc : model.uiDataFolder!)).font(.system(size: 8)).foregroundColor(Color("FontColor"))
})
}
Spacer()
Button {
Task{ await runApp() }
} label: {
if !isSingingInProgress {
Text("Run").bold().foregroundColor(.white)
Text("lc.appBanner.run".loc).bold().foregroundColor(.white)
} else {
ProgressView().progressViewStyle(.circular)
}
Expand Down Expand Up @@ -150,7 +150,7 @@ struct LCAppBanner : View, LCAppSettingDelegate {
Button {
openDataFolder()
} label: {
Label("Open Data Folder", systemImage: "folder")
Label("lc.appBanner.openDataFolder".loc, systemImage: "folder")
}
}
}
Expand All @@ -159,36 +159,36 @@ struct LCAppBanner : View, LCAppSettingDelegate {
Button {
openSafariViewToCreateAppClip()
} label: {
Label("Create App Clip", systemImage: "appclip")
Label("lc.appBanner.createAppClip".loc, systemImage: "appclip")
}
Button {
copyLaunchUrl()
} label: {
Label("Copy Launch Url", systemImage: "link")
Label("lc.appBanner.copyLaunchUrl".loc, systemImage: "link")
}
Button {
saveIcon()
} label: {
Label("Save App Icon", systemImage: "square.and.arrow.down")
Label("lc.appBanner.saveAppIcon".loc, systemImage: "square.and.arrow.down")
}


} label: {
Label("Add to Home Screen", systemImage: "plus.app")
Label("lc.appBanner.addToHomeScreen".loc, systemImage: "plus.app")
}

Button {
openSettings()
} label: {
Label("Settings", systemImage: "gear")
Label("lc.tabView.settings".loc, systemImage: "gear")
}


if !model.uiIsShared {
Button(role: .destructive) {
Task{ await uninstall() }
} label: {
Label("Uninstall", systemImage: "trash")
Label("lc.appBanner.uninstall".loc, systemImage: "trash")
}

}
Expand All @@ -208,51 +208,51 @@ struct LCAppBanner : View, LCAppSettingDelegate {
Task { await handleURLSchemeLaunch() }
}

.alert("Confirm Uninstallation", isPresented: $confirmAppRemovalShow) {
.alert("lc.appBanner.confirmUninstallTitle".loc, isPresented: $confirmAppRemovalShow) {
Button(role: .destructive) {
self.confirmAppRemoval = true
self.appRemovalContinuation?.resume()
} label: {
Text("Uninstall")
Text("lc.appBanner.uninstall".loc)
}
Button("Cancel", role: .cancel) {
Button("lc.common.cancel".loc, role: .cancel) {
self.confirmAppRemoval = false
self.appRemovalContinuation?.resume()
}
} message: {
Text("Are you sure you want to uninstall \(appInfo.displayName()!)?")
Text("lc.appBanner.confirmUninstallMsg %@".localizeWithFormat(appInfo.displayName()!))
}
.alert("Delete Data Folder", isPresented: $confirmAppFolderRemovalShow) {
.alert("lc.appBanner.deleteDataTitle".loc, isPresented: $confirmAppFolderRemovalShow) {
Button(role: .destructive) {
self.confirmAppFolderRemoval = true
self.appFolderRemovalContinuation?.resume()
} label: {
Text("Delete")
Text("lc.common.delete".loc)
}
Button("Cancel", role: .cancel) {
Button("lc.common.cancel".loc, role: .cancel) {
self.confirmAppFolderRemoval = false
self.appFolderRemovalContinuation?.resume()
}
} message: {
Text("Do you also want to delete data folder of \(appInfo.displayName()!)? You can keep it for future use.")
Text("lc.appBanner.deleteDataMsg \(appInfo.displayName()!)")
}
.alert("Waiting for JIT", isPresented: $enablingJITShow) {
.alert("lc.appBanner.waitForJitTitle".loc, isPresented: $enablingJITShow) {
Button {
self.confirmEnablingJIT = true
self.confirmEnablingJITContinuation?.resume()
} label: {
Text("Launch Now")
Text("lc.appBanner.jitLaunchNow".loc)
}
Button("Cancel", role: .cancel) {
Button("lc.common.cancel", role: .cancel) {
self.confirmEnablingJIT = false
self.confirmEnablingJITContinuation?.resume()
}
} message: {
Text("Please use your favourite way to enable jit for current LiveContainer.")
Text("lc.appBanner.waitForJitMsg".loc)
}

.alert("Error", isPresented: $errorShow) {
Button("OK", action: {
.alert("lc.common.error".loc, isPresented: $errorShow) {
Button("lc.common.ok".loc, action: {
})
} message: {
Text(errorInfo)
Expand Down
42 changes: 21 additions & 21 deletions LiveContainerSwiftUI/LCAppListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct LCAppListView : View, LCAppBannerDelegate {
.animation(.easeInOut, value: apps)

if !sharedModel.isHiddenAppUnlocked {
Text(apps.count > 0 ? "\(apps.count) Apps in Total" : "Press the Plus Button to Install Apps.").foregroundStyle(.gray)
Text(apps.count > 0 ? "lc.appList.appCounter %lld".localizeWithFormat(apps.count) : "lc.appList.installTip".loc).foregroundStyle(.gray)
.onTapGesture(count: 3) {
Task { await authenticateUser() }
}
Expand All @@ -109,7 +109,7 @@ struct LCAppListView : View, LCAppBannerDelegate {
if sharedModel.isHiddenAppUnlocked {
LazyVStack {
HStack {
Text("Hidden Apps")
Text("lc.appList.hiddenApps".loc)
.font(.system(.title2).bold())
.border(Color.black)
Spacer()
Expand All @@ -123,14 +123,14 @@ struct LCAppListView : View, LCAppBannerDelegate {
.animation(.easeInOut, value: apps)

if hiddenApps.count == 0 {
Text("Long Press on a App to Make it Hidden.")
Text("lc.appList.hideAppTip".loc)
.foregroundStyle(.gray)
}
Text(apps.count + hiddenApps.count > 0 ? "\(apps.count + hiddenApps.count) Apps in Total" : "Press the Plus Button to Install Apps.").foregroundStyle(.gray)
Text(apps.count + hiddenApps.count > 0 ? "lc.appList.appCounter %lld".localizeWithFormat(apps.count + hiddenApps.count) : "lc.appList.installTip".loc).foregroundStyle(.gray)
}

if LCUtils.multiLCStatus == 2 {
Text("Manage apps in the primary LiveContainer").foregroundStyle(.gray).padding()
Text("lc.appList.manageInPrimaryTip".loc).foregroundStyle(.gray).padding()
}

}
Expand All @@ -146,12 +146,12 @@ struct LCAppListView : View, LCAppBannerDelegate {
onLaunchBundleIdChange()
}

.navigationTitle("My Apps")
.navigationTitle("lc.appList.myApps".loc)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
if LCUtils.multiLCStatus != 2 {
if !installprogressVisible {
Button("Add", systemImage: "plus", action: {
Button("Add".loc, systemImage: "plus", action: {
if choosingIPA {
choosingIPA = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: {
Expand All @@ -169,7 +169,7 @@ struct LCAppListView : View, LCAppBannerDelegate {
}
}
ToolbarItem(placement: .topBarTrailing) {
Button("Open Link", systemImage: "link", action: {
Button("lc.appList.openLink".loc, systemImage: "link", action: {
Task { await onOpenWebViewTapped() }
})
}
Expand All @@ -179,33 +179,33 @@ struct LCAppListView : View, LCAppBannerDelegate {
}
.navigationViewStyle(StackNavigationViewStyle())
.alert(isPresented: $errorShow){
Alert(title: Text("Error"), message: Text(errorInfo))
Alert(title: Text("lc.common.error".loc), message: Text(errorInfo))
}
.fileImporter(isPresented: $choosingIPA, allowedContentTypes: [.ipa]) { result in
Task { await startInstallApp(result) }
}
.alert("Installation", isPresented: $installReplaceComfirmVisible) {
.alert("lc.appList.installation".loc, isPresented: $installReplaceComfirmVisible) {
ForEach(installOptions, id: \.self) { installOption in
Button(role: installOption.isReplace ? .destructive : nil, action: {
self.installOptionChosen = installOption
self.installOptionContinuation?.resume()
}, label: {
Text(installOption.isReplace ? installOption.nameOfFolderToInstall : "Install as new")
Text(installOption.isReplace ? installOption.nameOfFolderToInstall : "lc.appList.installAsNew".loc)
})

}
Button(role: .cancel, action: {
self.installOptionChosen = nil
self.installOptionContinuation?.resume()
}, label: {
Text("Abort Installation")
Text("lc.appList.abortInstallation".loc)
})
} message: {
Text("There is an existing application with the same bundle identifier. Replace one or install as new.")
Text("lc.appList.installReplaceTip".loc)
}
.textFieldAlert(
isPresented: $webViewUrlInputOpened,
title: "Enter Url or Url Scheme",
title: "lc.appList.enterUrlTip".loc,
text: $webViewUrlInputContent,
placeholder: "scheme://",
action: { newText in
Expand Down Expand Up @@ -252,7 +252,7 @@ struct LCAppListView : View, LCAppBannerDelegate {

func openWebView(urlString: String) async {
guard var urlToOpen = URLComponents(string: urlString), urlToOpen.url != nil else {
errorInfo = "The input url is invalid. Please check and try again"
errorInfo = "lc.appList.urlInvalidError".loc
errorShow = true
webViewUrlInputContent = ""
return
Expand Down Expand Up @@ -283,7 +283,7 @@ struct LCAppListView : View, LCAppBannerDelegate {


guard let appToLaunch = appToLaunch else {
errorInfo = "Scheme \"\(urlToOpen.scheme!)\" cannot be opened by any app installed in LiveContainer."
errorInfo = "lc.appList.schemeCannotOpenError %@".localizeWithFormat(urlToOpen.scheme!)
errorShow = true
return
}
Expand Down Expand Up @@ -337,7 +337,7 @@ struct LCAppListView : View, LCAppBannerDelegate {

func installIpaFile(_ url:URL) async throws {
if(!url.startAccessingSecurityScopedResource()) {
throw "Failed to access IPA";
throw "lc.appList.ipaAccessError".loc;
}
let fm = FileManager()

Expand Down Expand Up @@ -368,13 +368,13 @@ struct LCAppListView : View, LCAppBannerDelegate {
}
}
guard let appBundleName = appBundleName else {
throw "App bundle not found"
throw "lc.appList.bundleNotFondError".loc
}

let appFolderPath = payloadPath.appendingPathComponent(appBundleName)

guard let newAppInfo = LCAppInfo(bundlePath: appFolderPath.path) else {
throw "Failed to read app's Info.plist."
throw "lc.appList.infoPlistCannotReadError".loc
}

var appRelativePath = "\(newAppInfo.bundleIdentifier()!).app"
Expand Down Expand Up @@ -422,7 +422,7 @@ struct LCAppListView : View, LCAppBannerDelegate {

// patch it
guard let finalNewApp else {
errorInfo = "Failed to Initialize AppInfo!"
errorInfo = "lc.appList.appInfoInitError".loc
errorShow = true
return
}
Expand Down Expand Up @@ -513,7 +513,7 @@ struct LCAppListView : View, LCAppBannerDelegate {
}

if !appFound {
errorInfo = "App not Found"
errorInfo = "lc.appList.appNotFoundError".loc
errorShow = true
}
}
Expand Down
Loading

0 comments on commit 20ba18f

Please sign in to comment.