From 49b91a836a884cef92d252c9d39a9d5a7fb6da6d Mon Sep 17 00:00:00 2001 From: noppefoxwolf Date: Fri, 17 Jun 2022 03:56:42 +0900 Subject: [PATCH] Add localization (ja). --- .../xcshareddata/xcschemes/SwiftUIExample.xcscheme | 6 ++++++ .../xcshareddata/xcschemes/UIKitExample.xcscheme | 6 ++++++ Example.swiftpm/Package.swift | 1 + .../Resource/en.lproj/Localizable.strings | 0 .../Resource/ja.lproj/Localizable.strings | 0 .../Resource/en.lproj/Localizable.strings | 0 .../Resource/ja.lproj/Localizable.strings | 0 Package.swift | 6 +++++- Sources/DebugMenu/Extensions/L10n.swift | 12 ++++++++++++ .../DebugMenu/Resource/en.lproj/Localizable.strings | 4 ++++ .../DebugMenu/Resource/ja.lproj/Localizable.strings | 4 ++++ Sources/DebugMenu/View/FloatingViewController.swift | 8 ++++---- 12 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 Example.swiftpm/Source/SwiftUIExampleModule/Resource/en.lproj/Localizable.strings create mode 100644 Example.swiftpm/Source/SwiftUIExampleModule/Resource/ja.lproj/Localizable.strings create mode 100644 Example.swiftpm/Source/UIKItExampleModule/Resource/en.lproj/Localizable.strings create mode 100644 Example.swiftpm/Source/UIKItExampleModule/Resource/ja.lproj/Localizable.strings create mode 100644 Sources/DebugMenu/Extensions/L10n.swift create mode 100644 Sources/DebugMenu/Resource/en.lproj/Localizable.strings create mode 100644 Sources/DebugMenu/Resource/ja.lproj/Localizable.strings diff --git a/Example.swiftpm/.swiftpm/xcode/xcshareddata/xcschemes/SwiftUIExample.xcscheme b/Example.swiftpm/.swiftpm/xcode/xcshareddata/xcschemes/SwiftUIExample.xcscheme index b90b0e9..fa7c306 100644 --- a/Example.swiftpm/.swiftpm/xcode/xcshareddata/xcschemes/SwiftUIExample.xcscheme +++ b/Example.swiftpm/.swiftpm/xcode/xcshareddata/xcschemes/SwiftUIExample.xcscheme @@ -50,6 +50,12 @@ ReferencedContainer = "container:"> + + + + + + + + String { + NSLocalizedString(key, bundle: .module, comment: "") + } +} diff --git a/Sources/DebugMenu/Resource/en.lproj/Localizable.strings b/Sources/DebugMenu/Resource/en.lproj/Localizable.strings new file mode 100644 index 0000000..c1016ea --- /dev/null +++ b/Sources/DebugMenu/Resource/en.lproj/Localizable.strings @@ -0,0 +1,4 @@ +"Cancel" = "Cancel"; +"Hide widget" = "Hide widget"; +"Show widget" = "Show widget"; +"Hide until next launch" = "Hide until next launch"; diff --git a/Sources/DebugMenu/Resource/ja.lproj/Localizable.strings b/Sources/DebugMenu/Resource/ja.lproj/Localizable.strings new file mode 100644 index 0000000..d844a1f --- /dev/null +++ b/Sources/DebugMenu/Resource/ja.lproj/Localizable.strings @@ -0,0 +1,4 @@ +"Cancel" = "キャンセル"; +"Hide widget" = "ウィジェットを非表示"; +"Show widget" = "ウィジェットを表示"; +"Hide until next launch" = "次回起動までランチャーを非表示"; diff --git a/Sources/DebugMenu/View/FloatingViewController.swift b/Sources/DebugMenu/View/FloatingViewController.swift index ce31d40..560e012 100644 --- a/Sources/DebugMenu/View/FloatingViewController.swift +++ b/Sources/DebugMenu/View/FloatingViewController.swift @@ -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 @@ -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() @@ -134,7 +134,7 @@ internal class FloatingViewController: UIViewController { } else { sheet.addAction( .init( - title: "Hide widget", + title: .hideWidget, style: .destructive, handler: { [weak self] _ in self?.widgetView.hide() @@ -142,7 +142,7 @@ internal class FloatingViewController: UIViewController { ) ) } - sheet.addAction(.init(title: "Cancel", style: .cancel, handler: nil)) + sheet.addAction(.init(title: .cancel, style: .cancel, handler: nil)) present(sheet, animated: true, completion: nil) } }