Skip to content

Commit 5cfa838

Browse files
committed
Localize strings
1 parent e570e44 commit 5cfa838

8 files changed

Lines changed: 57 additions & 21 deletions

File tree

Example/PSMeter.xcodeproj/project.pbxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/* End PBXBuildFile section */
1717

1818
/* Begin PBXFileReference section */
19+
04F24F3625323E9E00844054 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Main.strings; sourceTree = "<group>"; };
20+
04F24F3725323E9E00844054 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
1921
05E294CCB04CFBDC927FAAB5 /* Pods-PSMeter_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PSMeter_Example.debug.xcconfig"; path = "Target Support Files/Pods-PSMeter_Example/Pods-PSMeter_Example.debug.xcconfig"; sourceTree = "<group>"; };
2022
37BFB8A4F532B7D5F9D6A9C3 /* Pods-PSMeter_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PSMeter_Example.release.xcconfig"; path = "Target Support Files/Pods-PSMeter_Example/Pods-PSMeter_Example.release.xcconfig"; sourceTree = "<group>"; };
2123
5CC1F843F06F1F0B1214BB24 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
@@ -157,6 +159,7 @@
157159
English,
158160
en,
159161
Base,
162+
ar,
160163
);
161164
mainGroup = 607FACC71AFB9204008FA782;
162165
productRefGroup = 607FACD11AFB9204008FA782 /* Products */;
@@ -245,6 +248,7 @@
245248
isa = PBXVariantGroup;
246249
children = (
247250
607FACDA1AFB9204008FA782 /* Base */,
251+
04F24F3625323E9E00844054 /* ar */,
248252
);
249253
name = Main.storyboard;
250254
sourceTree = "<group>";
@@ -253,6 +257,7 @@
253257
isa = PBXVariantGroup;
254258
children = (
255259
607FACDF1AFB9204008FA782 /* Base */,
260+
04F24F3725323E9E00844054 /* ar */,
256261
);
257262
name = LaunchScreen.xib;
258263
sourceTree = "<group>";

Example/PSMeter.xcodeproj/xcshareddata/xcschemes/PSMeter-Example.xcscheme

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43-
language = ""
4443
shouldUseLaunchSchemeArgsEnv = "YES">
44+
<MacroExpansion>
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
48+
BuildableName = "PSMeter_Example.app"
49+
BlueprintName = "PSMeter_Example"
50+
ReferencedContainer = "container:PSMeter.xcodeproj">
51+
</BuildableReference>
52+
</MacroExpansion>
4553
<Testables>
4654
<TestableReference
4755
skipped = "NO">
@@ -54,23 +62,12 @@
5462
</BuildableReference>
5563
</TestableReference>
5664
</Testables>
57-
<MacroExpansion>
58-
<BuildableReference
59-
BuildableIdentifier = "primary"
60-
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
61-
BuildableName = "PSMeter_Example.app"
62-
BlueprintName = "PSMeter_Example"
63-
ReferencedContainer = "container:PSMeter.xcodeproj">
64-
</BuildableReference>
65-
</MacroExpansion>
66-
<AdditionalOptions>
67-
</AdditionalOptions>
6865
</TestAction>
6966
<LaunchAction
7067
buildConfiguration = "Debug"
7168
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
7269
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
73-
language = ""
70+
language = "ar"
7471
launchStyle = "0"
7572
useCustomWorkingDirectory = "NO"
7673
ignoresPersistentStateOnLaunch = "NO"
@@ -87,8 +84,6 @@
8784
ReferencedContainer = "container:PSMeter.xcodeproj">
8885
</BuildableReference>
8986
</BuildableProductRunnable>
90-
<AdditionalOptions>
91-
</AdditionalOptions>
9287
</LaunchAction>
9388
<ProfileAction
9489
buildConfiguration = "Release"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
/* Class = "UILabel"; text = "By Baianat"; ObjectID = "8ie-xW-0ye"; */
3+
"8ie-xW-0ye.text" = "By Baianat";
4+
5+
/* Class = "UILabel"; text = "PSMeter"; ObjectID = "kId-c2-rCX"; */
6+
"kId-c2-rCX.text" = "PSMeter";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
/* Class = "UILabel"; text = "E-mail"; ObjectID = "HDK-My-2Mj"; */
3+
"HDK-My-2Mj.text" = "E-mail";
4+
5+
/* Class = "UILabel"; text = "Register"; ObjectID = "c7U-Z6-faF"; */
6+
"c7U-Z6-faF.text" = "Register";
7+
8+
/* Class = "UIButton"; normalTitle = "Register"; ObjectID = "lDg-30-U6x"; */
9+
"lDg-30-U6x.normalTitle" = "Register";
10+
11+
/* Class = "UILabel"; text = "Password"; ObjectID = "pWD-O9-eFn"; */
12+
"pWD-O9-eFn.text" = "Password";

PSMeter/Classes/PSMeter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public protocol PSMeterDelegate {
1818

1919
// MARK: Public Attributes
2020

21-
@IBInspectable public var titleText: String = "Password Strength" {
21+
@IBInspectable public var titleText: String = "passwordStrength".localized {
2222
didSet {
2323
self.strengthTitleLabel.text = titleText
2424
}

PSMeter/Classes/PasswordDecorator/PStrengthViewStatesDecorator.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public struct PStrengthViewStatesDecorator {
4141
public static func defaultValues() -> PStrengthViewStatesDecorator {
4242
return PStrengthViewStatesDecorator(
4343
emptyPasswordDecorator: StateDecorator(text: "--", textColor: .gray, progressColor: .gray),
44-
veryWeakPasswordDecorator: StateDecorator(text: "Very Weak", textColor: weakColor, progressColor: weakColor),
45-
weakPasswordDecorator: StateDecorator(text: "Weak", textColor: weakColor, progressColor: weakColor),
46-
fairPasswordDecorator: StateDecorator(text: "Fair", textColor: veryWeakColor, progressColor: veryWeakColor),
47-
strongPasswordDecorator: StateDecorator(text: "Strong", textColor: strongColor, progressColor: strongColor),
48-
veryStrongPasswordDecorator: StateDecorator(text: "Very Strong", textColor: veryStrongColor, progressColor: veryStrongColor))
44+
veryWeakPasswordDecorator: StateDecorator(text: "veryWeak".localized, textColor: weakColor, progressColor: weakColor),
45+
weakPasswordDecorator: StateDecorator(text: "weak".localized, textColor: weakColor, progressColor: weakColor),
46+
fairPasswordDecorator: StateDecorator(text: "fair".localized, textColor: veryWeakColor, progressColor: veryWeakColor),
47+
strongPasswordDecorator: StateDecorator(text: "strong".localized, textColor: strongColor, progressColor: strongColor),
48+
veryStrongPasswordDecorator: StateDecorator(text: "veryStrong".localized, textColor: veryStrongColor, progressColor: veryStrongColor))
4949
}
5050

5151
}
@@ -70,3 +70,9 @@ protocol ViewDecoratorProtocol {
7070
var textColor: UIColor! {get set}
7171
var progressColor: UIColor! {get set}
7272
}
73+
74+
extension String {
75+
var localized: String {
76+
return NSLocalizedString(self, tableName: nil, bundle: Bundle.init(for: PSMeter.self), value: "", comment: "")
77+
}
78+
}

ar.lproj/Localizable.strings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"weak" = "ضعيف";
2+
"veryWeak" = "ضعيفة جدا";
3+
"fair" = "متوسطة";
4+
"strong" = "قوية";
5+
"veryStrong" = "قوية جدا";
6+
"passwordStrength" = "قوة كلمة السر";

en.lproj/Localizable.strings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"weak" = "Weak";
2+
"veryWeak" = "Very Weak";
3+
"fair" = "Fair";
4+
"strong" = "Strong";
5+
"veryStrong" = "Very Strong";
6+
"passwordStrength" = "Password Strength";

0 commit comments

Comments
 (0)