Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Commit c5b49b7

Browse files
committed
Merge pull request #2 from ParsePlatform/nlutsenko.localization
Include and automate localized strings generation.
2 parents f1913e1 + f26b069 commit c5b49b7

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

ParseTwitterUtils.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Pod::Spec.new do |s|
1414

1515
s.public_header_files = 'ParseTwitterUtils/*.h'
1616
s.source_files = 'ParseTwitterUtils/**/*.{h,m}'
17+
s.resources = 'Resources/en.lproj'
1718

1819
s.frameworks = 'AudioToolbox',
1920
'CFNetwork',

ParseTwitterUtils.xcodeproj/project.pbxproj

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
06D00BAB1BC78F23005BAA6F /* ParseTwitterUtils.strings in Resources */ = {isa = PBXBuildFile; fileRef = 06D00BAD1BC78F23005BAA6F /* ParseTwitterUtils.strings */; };
11+
06D00BB51BC790F3005BAA6F /* PFTwitterLocalization.h in Headers */ = {isa = PBXBuildFile; fileRef = 06D00BB41BC790F3005BAA6F /* PFTwitterLocalization.h */; settings = {ASSET_TAGS = (); }; };
1012
77DE89F60F51105C769BEC0B /* libPods-ParseTwitterUtils-Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F31BB2625FB261014BCD4FB6 /* libPods-ParseTwitterUtils-Tests.a */; };
1113
8135E4951B4B6A0E0092F452 /* PF_Twitter_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8135E48E1B4B6A0E0092F452 /* PF_Twitter_Private.h */; };
1214
8135E4961B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 8135E48F1B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.h */; };
@@ -34,7 +36,6 @@
3436
817A37CC1B4B741A00129AFA /* PF_OAuthCore.m in Sources */ = {isa = PBXBuildFile; fileRef = 817A37CA1B4B741A00129AFA /* PF_OAuthCore.m */; };
3537
819DAAD61BB5EC79002BDE2B /* PFTwitterAlertView.h in Headers */ = {isa = PBXBuildFile; fileRef = 819DAAD41BB5EC79002BDE2B /* PFTwitterAlertView.h */; settings = {ASSET_TAGS = (); }; };
3638
819DAAD71BB5EC79002BDE2B /* PFTwitterAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 819DAAD51BB5EC79002BDE2B /* PFTwitterAlertView.m */; settings = {ASSET_TAGS = (); }; };
37-
81B3F22B1AC9CA5300A92677 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 81B3F22A1AC9CA5300A92677 /* Localizable.strings */; };
3839
81CB98CC1AB7905D00136FA5 /* ParseTwitterUtils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* ParseTwitterUtils.framework */; };
3940
81CB98D81AB791FB00136FA5 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 813DFC921AB2515A00F25A08 /* Bolts.framework */; };
4041
81CB98DB1AB7920E00136FA5 /* Parse.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 813DFC941AB251F700F25A08 /* Parse.framework */; };
@@ -62,6 +63,8 @@
6263
/* End PBXContainerItemProxy section */
6364

6465
/* Begin PBXFileReference section */
66+
06D00BAE1BC78F29005BAA6F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/ParseTwitterUtils.strings; sourceTree = "<group>"; };
67+
06D00BB41BC790F3005BAA6F /* PFTwitterLocalization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFTwitterLocalization.h; sourceTree = "<group>"; };
6568
8135E48E1B4B6A0E0092F452 /* PF_Twitter_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PF_Twitter_Private.h; sourceTree = "<group>"; };
6669
8135E48F1B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFTwitterAuthenticationProvider.h; sourceTree = "<group>"; };
6770
8135E4901B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFTwitterAuthenticationProvider.m; sourceTree = "<group>"; };
@@ -101,7 +104,6 @@
101104
81930A391BBDE76E00A5E4BB /* PFTwitterTestMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PFTwitterTestMacros.h; sourceTree = "<group>"; };
102105
819DAAD41BB5EC79002BDE2B /* PFTwitterAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFTwitterAlertView.h; sourceTree = "<group>"; };
103106
819DAAD51BB5EC79002BDE2B /* PFTwitterAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFTwitterAlertView.m; sourceTree = "<group>"; };
104-
81B3F22A1AC9CA5300A92677 /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = Localizable.strings; path = Resources/Localizable.strings; sourceTree = SOURCE_ROOT; };
105107
81CB98C61AB7905D00136FA5 /* ParseTwitterUtils-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ParseTwitterUtils-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
106108
81CB98D31AB7906D00136FA5 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Resources/Info.plist; sourceTree = "<group>"; };
107109
81CB98DC1AB7921C00136FA5 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/lib/libsqlite3.dylib; sourceTree = DEVELOPER_DIR; };
@@ -217,6 +219,7 @@
217219
813E54A61BB5E52000C727E8 /* PFTwitterPrivateUtilities.m */,
218220
819DAAD41BB5EC79002BDE2B /* PFTwitterAlertView.h */,
219221
819DAAD51BB5EC79002BDE2B /* PFTwitterAlertView.m */,
222+
06D00BB41BC790F3005BAA6F /* PFTwitterLocalization.h */,
220223
);
221224
path = Internal;
222225
sourceTree = "<group>";
@@ -243,8 +246,8 @@
243246
813DFC961AB2524C00F25A08 /* Resources */ = {
244247
isa = PBXGroup;
245248
children = (
246-
81B3F22A1AC9CA5300A92677 /* Localizable.strings */,
247249
813DFC971AB2526000F25A08 /* third_party_licenses.txt */,
250+
06D00BAD1BC78F23005BAA6F /* ParseTwitterUtils.strings */,
248251
);
249252
name = Resources;
250253
path = Classes;
@@ -406,6 +409,7 @@
406409
81D342A11B4C7DA500B6C124 /* ParseTwitterUtils.h in Headers */,
407410
813E54AA1BB5E5FF00C727E8 /* PFTwitterPrivateUtilities.h in Headers */,
408411
8135E49A1B4B6A0E0092F452 /* PFTwitterUtils.h in Headers */,
412+
06D00BB51BC790F3005BAA6F /* PFTwitterLocalization.h in Headers */,
409413
8135E4951B4B6A0E0092F452 /* PF_Twitter_Private.h in Headers */,
410414
8135E4961B4B6A0E0092F452 /* PFTwitterAuthenticationProvider.h in Headers */,
411415
819DAAD61BB5EC79002BDE2B /* PFTwitterAlertView.h in Headers */,
@@ -499,23 +503,7 @@
499503
developmentRegion = English;
500504
hasScannedForEncodings = 1;
501505
knownRegions = (
502-
English,
503-
Japanese,
504-
French,
505-
German,
506-
da,
507-
de,
508-
es,
509-
fr,
510-
it,
511-
ja,
512-
nl,
513-
no,
514-
sl,
515-
sv,
516-
tr,
517506
en,
518-
Base,
519507
);
520508
mainGroup = 0867D691FE84028FC02AAC07 /* Breakpad */;
521509
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
@@ -535,7 +523,7 @@
535523
buildActionMask = 2147483647;
536524
files = (
537525
813DFC981AB2526000F25A08 /* third_party_licenses.txt in Resources */,
538-
81B3F22B1AC9CA5300A92677 /* Localizable.strings in Resources */,
526+
06D00BAB1BC78F23005BAA6F /* ParseTwitterUtils.strings in Resources */,
539527
);
540528
runOnlyForDeploymentPostprocessing = 0;
541529
};
@@ -613,7 +601,8 @@
613601
);
614602
runOnlyForDeploymentPostprocessing = 0;
615603
shellPath = /bin/sh;
616-
shellScript = "# Generate localizable strings\nfind $PROJECT_DIR -name '*.m' -print0 | xargs -0 genstrings -q -o $PROJECT_DIR/Resources\necho \"Finished converting images\"";
604+
shellScript = "# Generate localizable strings\nLOCALIZATION_FOLDER=$PROJECT_DIR/Resources/en.lproj\nLOCALIZATION_MACRO=PFTWLocalizedString\n\nfind $PROJECT_DIR/ParseTwitterUtils -name '*.m' -print0 | xargs -0 xcrun extractLocStrings -s $LOCALIZATION_MACRO -q -o $LOCALIZATION_FOLDER\n\nmv $LOCALIZATION_FOLDER/Localizable.strings $LOCALIZATION_FOLDER/ParseTwitterUtils.strings\n";
605+
showEnvVarsInLog = 0;
617606
};
618607
81F035F41BC311FA0055BFDE /* Fetch latest Parse.framework */ = {
619608
isa = PBXShellScriptBuildPhase;
@@ -683,6 +672,18 @@
683672
};
684673
/* End PBXTargetDependency section */
685674

675+
/* Begin PBXVariantGroup section */
676+
06D00BAD1BC78F23005BAA6F /* ParseTwitterUtils.strings */ = {
677+
isa = PBXVariantGroup;
678+
children = (
679+
06D00BAE1BC78F29005BAA6F /* en */,
680+
);
681+
name = ParseTwitterUtils.strings;
682+
path = Resources;
683+
sourceTree = SOURCE_ROOT;
684+
};
685+
/* End PBXVariantGroup section */
686+
686687
/* Begin XCBuildConfiguration section */
687688
1DEB921F08733DC00010E9CD /* Debug */ = {
688689
isa = XCBuildConfiguration;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) 2015-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#ifndef PFTwitterLocalization_h
11+
#define PFTwitterLocalization_h
12+
13+
#define PFTWLocalizedString(key, comment) \
14+
[[NSBundle bundleForClass:[self class]] localizedStringForKey:key value:nil table:@"ParseTwitterUtils"]
15+
16+
#endif

ParseTwitterUtils/PF_Twitter.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#import "PFTwitterAlertView.h"
2424
#import "PFTwitterPrivateUtilities.h"
2525
#import "PF_OAuthCore.h"
26+
#import "PFTwitterLocalization.h"
2627

2728
@implementation PF_Twitter
2829

@@ -409,9 +410,9 @@ - (BFTask *)_performWebViewAuthAsync {
409410

410411
// Call async on the main thread, as the completion isn't executed on the main thread
411412
dispatch_async(dispatch_get_main_queue(), ^{
412-
[PFTwitterAlertView showAlertWithTitle:NSLocalizedString(@"Select a Twitter Account", @"Select a Twitter Account")
413+
[PFTwitterAlertView showAlertWithTitle:PFTWLocalizedString(@"Select a Twitter Account", @"Select a Twitter Account")
413414
message:nil
414-
cancelButtonTitle:NSLocalizedString(@"Cancel", @"Cancel")
415+
cancelButtonTitle:PFTWLocalizedString(@"Cancel", @"Cancel")
415416
otherButtonTitles:usernames
416417
completion:^(NSUInteger buttonIndex) {
417418
if (buttonIndex == NSNotFound) {
File renamed without changes.

0 commit comments

Comments
 (0)