Skip to content

Commit

Permalink
Add localization (ja).
Browse files Browse the repository at this point in the history
  • Loading branch information
noppefoxwolf committed Jun 16, 2022
1 parent d2466ec commit 49b91a8
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
ReferencedContainer = "container:">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "-AppleLanguages (en)"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
ReferencedContainer = "container:">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "-AppleLanguages (ja)"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
1 change: 1 addition & 0 deletions Example.swiftpm/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AppleProductTypes

let package = Package(
name: "Example",
defaultLocalization: "en",
platforms: [
.iOS("15.2")
],
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PackageDescription

let package = Package(
name: "DebugMenu",
defaultLocalization: "en",
platforms: [.iOS(.v14)],
products: [
.library(
Expand All @@ -14,7 +15,10 @@ let package = Package(
],
targets: [
.target(
name: "DebugMenu"
name: "DebugMenu",
resources: [
.process("Resource"),
]
),
.testTarget(
name: "DebugMenuTests",
Expand Down
12 changes: 12 additions & 0 deletions Sources/DebugMenu/Extensions/L10n.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

extension String {
static var showWidget: String { makeLocalizaedString("Show widget") }
static var hideWidget: String { makeLocalizaedString("Hide widget") }
static var hideUntilNextLaunch: String { makeLocalizaedString("Hide until next launch") }
static var cancel: String { makeLocalizaedString("Cancel") }

private static func makeLocalizaedString(_ key: String) -> String {
NSLocalizedString(key, bundle: .module, comment: "")
}
}
4 changes: 4 additions & 0 deletions Sources/DebugMenu/Resource/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"Cancel" = "Cancel";
"Hide widget" = "Hide widget";
"Show widget" = "Show widget";
"Hide until next launch" = "Hide until next launch";
4 changes: 4 additions & 0 deletions Sources/DebugMenu/Resource/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"Cancel" = "キャンセル";
"Hide widget" = "ウィジェットを非表示";
"Show widget" = "ウィジェットを表示";
"Hide until next launch" = "次回起動までランチャーを非表示";
8 changes: 4 additions & 4 deletions Sources/DebugMenu/View/FloatingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ internal class FloatingViewController: UIViewController {
let sheet = UIAlertController(title: "DebugMenu", message: nil, preferredStyle: .alert)
sheet.addAction(
.init(
title: "Hide until next launch",
title: .hideUntilNextLaunch,
style: .destructive,
handler: { [weak self] _ in
self?.launchView.isHidden = true
Expand All @@ -124,7 +124,7 @@ internal class FloatingViewController: UIViewController {
if widgetView.isHidden {
sheet.addAction(
.init(
title: "Show widget",
title: .showWidget,
style: .default,
handler: { [weak self] _ in
self?.widgetView.show()
Expand All @@ -134,15 +134,15 @@ internal class FloatingViewController: UIViewController {
} else {
sheet.addAction(
.init(
title: "Hide widget",
title: .hideWidget,
style: .destructive,
handler: { [weak self] _ in
self?.widgetView.hide()
}
)
)
}
sheet.addAction(.init(title: "Cancel", style: .cancel, handler: nil))
sheet.addAction(.init(title: .cancel, style: .cancel, handler: nil))
present(sheet, animated: true, completion: nil)
}
}

0 comments on commit 49b91a8

Please sign in to comment.