Skip to content

Commit 238f554

Browse files
authored
Merge pull request #31 from noppefoxwolf/feature/localization
Add localization.
2 parents d2466ec + 49b91a8 commit 238f554

12 files changed

Lines changed: 42 additions & 5 deletions

File tree

Example.swiftpm/.swiftpm/xcode/xcshareddata/xcschemes/SwiftUIExample.xcscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
ReferencedContainer = "container:">
5151
</BuildableReference>
5252
</BuildableProductRunnable>
53+
<CommandLineArguments>
54+
<CommandLineArgument
55+
argument = "-AppleLanguages (en)"
56+
isEnabled = "YES">
57+
</CommandLineArgument>
58+
</CommandLineArguments>
5359
</LaunchAction>
5460
<ProfileAction
5561
buildConfiguration = "Release"

Example.swiftpm/.swiftpm/xcode/xcshareddata/xcschemes/UIKitExample.xcscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
ReferencedContainer = "container:">
5252
</BuildableReference>
5353
</BuildableProductRunnable>
54+
<CommandLineArguments>
55+
<CommandLineArgument
56+
argument = "-AppleLanguages (ja)"
57+
isEnabled = "YES">
58+
</CommandLineArgument>
59+
</CommandLineArguments>
5460
</LaunchAction>
5561
<ProfileAction
5662
buildConfiguration = "Release"

Example.swiftpm/Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AppleProductTypes
99

1010
let package = Package(
1111
name: "Example",
12+
defaultLocalization: "en",
1213
platforms: [
1314
.iOS("15.2")
1415
],

Example.swiftpm/Source/SwiftUIExampleModule/Resource/en.lproj/Localizable.strings

Whitespace-only changes.

Example.swiftpm/Source/SwiftUIExampleModule/Resource/ja.lproj/Localizable.strings

Whitespace-only changes.

Example.swiftpm/Source/UIKItExampleModule/Resource/en.lproj/Localizable.strings

Whitespace-only changes.

Example.swiftpm/Source/UIKItExampleModule/Resource/ja.lproj/Localizable.strings

Whitespace-only changes.

Package.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "DebugMenu",
8+
defaultLocalization: "en",
89
platforms: [.iOS(.v14)],
910
products: [
1011
.library(
@@ -14,7 +15,10 @@ let package = Package(
1415
],
1516
targets: [
1617
.target(
17-
name: "DebugMenu"
18+
name: "DebugMenu",
19+
resources: [
20+
.process("Resource"),
21+
]
1822
),
1923
.testTarget(
2024
name: "DebugMenuTests",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Foundation
2+
3+
extension String {
4+
static var showWidget: String { makeLocalizaedString("Show widget") }
5+
static var hideWidget: String { makeLocalizaedString("Hide widget") }
6+
static var hideUntilNextLaunch: String { makeLocalizaedString("Hide until next launch") }
7+
static var cancel: String { makeLocalizaedString("Cancel") }
8+
9+
private static func makeLocalizaedString(_ key: String) -> String {
10+
NSLocalizedString(key, bundle: .module, comment: "")
11+
}
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"Cancel" = "Cancel";
2+
"Hide widget" = "Hide widget";
3+
"Show widget" = "Show widget";
4+
"Hide until next launch" = "Hide until next launch";

0 commit comments

Comments
 (0)