-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix NSLocalizedString and Add Localization Tests (#2824)
* Fix NSLocalizedString and add new tests * Address CR Feedback. * Forgot to change to StringByAppendingPath * Nevermind. ASSERT_OBJCEQ does indeed work. * Address feedback. * Address feedback.
- Loading branch information
Showing
14 changed files
with
357 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...les/WOCCatalog/WOCCatalog.vsimporter/WOCCatalog-WinStore10/Base.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"a" = "z"; | ||
"b" = "y"; | ||
"c" = "x"; | ||
"d" = "w"; | ||
"e" = "v"; | ||
"f" = "u"; | ||
"g" = "t"; | ||
"h" = "s"; | ||
"i" = "r"; | ||
"j" = "q"; | ||
"Hello World" = "English: Hello World"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
samples/WOCCatalog/WOCCatalog.vsimporter/WOCCatalog-WinStore10/de.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"a" = "1"; | ||
"b" = "2"; | ||
"c" = "3"; | ||
"d" = "4"; | ||
"e" = "5"; | ||
"f" = "6"; | ||
"g" = "7"; | ||
"h" = "8"; | ||
"i" = "9"; | ||
"j" = "10"; | ||
"Hello World" = "German: Hallo Welt"; |
11 changes: 11 additions & 0 deletions
11
...es/WOCCatalog/WOCCatalog.vsimporter/WOCCatalog-WinStore10/es_MX.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"a" = "z"; | ||
"b" = "x"; | ||
"c" = "c"; | ||
"d" = "v"; | ||
"e" = "b"; | ||
"f" = "n"; | ||
"g" = "m"; | ||
"h" = ","; | ||
"i" = "."; | ||
"j" = "/"; | ||
"Hello World" = "Spanish _: Hola Mundo"; |
11 changes: 11 additions & 0 deletions
11
...CCatalog/WOCCatalog.vsimporter/WOCCatalog-WinStore10/zh-Hant-TW.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"a" = "q"; | ||
"b" = "w"; | ||
"c" = "e"; | ||
"d" = "r"; | ||
"e" = "t"; | ||
"f" = "y"; | ||
"g" = "u"; | ||
"h" = "i"; | ||
"i" = "o"; | ||
"j" = "p"; | ||
"Hello World" = "zh-Hant-TW: 世界您好"; |
11 changes: 11 additions & 0 deletions
11
samples/WOCCatalog/WOCCatalog.vsimporter/WOCCatalog-WinStore10/zh.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"a" = "a"; | ||
"b" = "s"; | ||
"c" = "d"; | ||
"d" = "f"; | ||
"e" = "g"; | ||
"f" = "h"; | ||
"g" = "j"; | ||
"h" = "k"; | ||
"i" = "l"; | ||
"j" = ";"; | ||
"Hello World" = "zh-Hans-CN truncated: 世界您好"; |
21 changes: 21 additions & 0 deletions
21
samples/WOCCatalog/WOCCatalog/LocalizationViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//****************************************************************************** | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// | ||
// This code is licensed under the MIT License (MIT). | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
//****************************************************************************** | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface LocalizationViewController : UITableViewController <UITextFieldDelegate> | ||
@end |
82 changes: 82 additions & 0 deletions
82
samples/WOCCatalog/WOCCatalog/LocalizationViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//****************************************************************************** | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// | ||
// This code is licensed under the MIT License (MIT). | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
//****************************************************************************** | ||
|
||
#import "LocalizationViewController.h" | ||
|
||
static const CGFloat c_originX = 5; | ||
static const CGFloat c_originY = 8; | ||
static const CGFloat c_width = 260; | ||
static const CGFloat c_height = 50; | ||
|
||
@implementation LocalizationViewController { | ||
@private | ||
UITableViewCell* _cell; | ||
UITextField* _copyTextField; | ||
UILabel* _pasteTextLabel; | ||
} | ||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
self.tableView.allowsSelection = YES; | ||
} | ||
|
||
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { | ||
return 2; | ||
} | ||
|
||
- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath { | ||
return 70; | ||
} | ||
|
||
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { | ||
_cell = [tableView dequeueReusableCellWithIdentifier:@"MenuCell"]; | ||
if (nil == _cell) { | ||
_cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MenuCell"]; | ||
_cell.selectionStyle = UITableViewCellSelectionStyleNone; | ||
} | ||
|
||
CGRect frame = CGRectMake(c_originX, c_originY, c_width, c_height); | ||
|
||
if (indexPath.row == 0) { | ||
_copyTextField = [[UITextField alloc] initWithFrame:frame]; | ||
_copyTextField.textColor = [UIColor blackColor]; | ||
_copyTextField.font = [UIFont systemFontOfSize:17.0]; | ||
_copyTextField.text = @"Hello World"; | ||
[_copyTextField addTarget:self action:@selector(onCopyTextChanged:) forControlEvents:UIControlEventEditingChanged]; | ||
|
||
_cell.accessoryView = _copyTextField; | ||
_cell.textLabel.text = @"Enter Text"; | ||
} else if (indexPath.row == 1) { | ||
_pasteTextLabel = [[UILabel alloc] initWithFrame:frame]; | ||
_pasteTextLabel.textColor = [UIColor blackColor]; | ||
_pasteTextLabel.font = [UIFont systemFontOfSize:17.0]; | ||
_pasteTextLabel.textAlignment = NSTextAlignmentLeft; | ||
_pasteTextLabel.text = NSLocalizedString(_copyTextField.text, nil); | ||
_cell.accessoryView = _pasteTextLabel; | ||
_cell.textLabel.text = @"Localized Text"; | ||
} | ||
return _cell; | ||
} | ||
|
||
- (void)viewDidLayoutSubviews { | ||
[(UIScrollView*)self.view setContentSize:[self.view.subviews[0] bounds].size]; | ||
} | ||
|
||
- (void)onCopyTextChanged:(UITextField*)textField { | ||
_pasteTextLabel.text = NSLocalizedString(textField.text, nil); | ||
[[self tableView] setNeedsLayout]; | ||
} | ||
|
||
@end |
Oops, something went wrong.