This repository has been archived by the owner on Oct 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Add Bidi utilities #42
Merged
Merged
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
a66fab3
Test
be77f99
Merge branch 'release-candidate' into stable
41e54b4
Add CODEOWNERS
5c3fb31
Merge branch 'release-candidate' into stable
f8d5eec
Merge branch 'release-candidate' into stable
ea4158c
Merge branch 'release-candidate' into stable
ianegordon 0fd9412
Merge branch 'release-candidate' into stable
ianegordon 3079740
Bump version number
ff95ee1
Update CHANGELOG
f34691a
Merge branch 'release-candidate' into stable
5b0f22e
Merge branch 'release-candidate' into stable
fa05ea3
Merge branch 'release-candidate' into stable
8f28a55
Merge branch 'release-candidate' into stable
33a5fa7
BiDi updates
ffe9177
ZZZ
05859c5
Add NSLocale category
03f40fa
Add NSLocale
c398210
Cleanup
e372ce0
BiDi examples
ac894eb
Add missing unicode control and Hello
b779562
Cleanup
66f0b30
Update Bidi strings
08c2586
Merge branch 'bidi' of https://github.com/material-foundation/materia…
89c6b81
Add icon and tests
2232d1f
Cleanup docs and spacing.
1028c36
Cleanup & Documentation
51b6740
Cleanup
2ae02f9
Renaming
b7307c0
Remove outdated test. Cleanup
7cfe76d
Test
3a68989
BiDi updates
078ca48
ZZZ
4ae581a
Add NSLocale category
cef3639
Add NSLocale
47e9480
Cleanup
e8db89b
BiDi examples
c9728e8
Add missing unicode control and Hello
fc87c53
Cleanup
000d042
Update Bidi strings
9b5e9e5
Add icon and tests
b889b58
Cleanup docs and spacing.
70469a6
Cleanup & Documentation
664eb42
Cleanup
5e041e8
Renaming
1b6d24c
Merge branch 'bidi' of github.com:material-foundation/material-intern…
5b5d1c0
Remove outdated test. Cleanup
9560ad8
Merge branch 'experimental-bidi' of github.com:material-foundation/ma…
a053a9d
Remove WS
71b95d7
Remove WS
d16c1d0
Feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 23 additions & 0 deletions
23
...ples/Flags/MDFInternationalizationExample/Assets.xcassets/BidiIcon.imageset/Contents.json
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,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "baseline_compare_arrows_black_36pt_1x.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "baseline_compare_arrows_black_36pt_2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "baseline_compare_arrows_black_36pt_3x.png", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+178 Bytes
...ple/Assets.xcassets/BidiIcon.imageset/baseline_compare_arrows_black_36pt_1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+234 Bytes
...ple/Assets.xcassets/BidiIcon.imageset/baseline_compare_arrows_black_36pt_2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+341 Bytes
...ple/Assets.xcassets/BidiIcon.imageset/baseline_compare_arrows_black_36pt_3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 109 additions & 10 deletions
119
Examples/Flags/MDFInternationalizationExample/Base.lproj/Main.storyboard
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
Examples/Flags/MDFInternationalizationExample/BidirectionalViewController.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 2018-present Google Inc. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface BidirectionalViewController : UIViewController | ||
|
||
@end |
77 changes: 77 additions & 0 deletions
77
Examples/Flags/MDFInternationalizationExample/BidirectionalViewController.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,77 @@ | ||
/* | ||
Copyright 2018-present Google Inc. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#import "BidirectionalViewController.h" | ||
|
||
|
||
static NSString *kMDFLTREmbedding = @"\u202a"; // left-to-right embedding | ||
static NSString *kMDFRTLEmbedding = @"\u202b"; // right-to-left embedding | ||
static NSString *kMDFBidiPopEmbedding = @"\u202c"; // pop directional embedding | ||
|
||
static NSString *kMDFLTRMark = @"\u200e"; // left-to-right mark | ||
static NSString *kMDFRTLMark = @"\u200f"; // right-to-left mark | ||
|
||
// The following only work on iOS 10+ | ||
static NSString *kMDFLTRIsolate = @"\u2066"; // left-to-right isolate | ||
static NSString *kMDFRTLIsolate = @"\u2067"; // right-to-left isolate | ||
static NSString *kMDFFirstStrongIsolate = @"\u2068"; // first strong isolate | ||
static NSString *kMDFPopIsolate = @"\u2069"; // pop directional isolate | ||
|
||
|
||
@interface BidirectionalViewController () | ||
|
||
@property (weak, nonatomic) IBOutlet UILabel *labelOne; | ||
@property (weak, nonatomic) IBOutlet UILabel *labelTwo; | ||
@property (weak, nonatomic) IBOutlet UILabel *labelThree; | ||
@property (weak, nonatomic) IBOutlet UILabel *labelFour; | ||
|
||
@end | ||
|
||
@implementation BidirectionalViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view. | ||
// The following lines will display a (: if the markers are supported, ): if not. | ||
self.labelOne.text = | ||
[NSString stringWithFormat:@"Bidi Isolate supported %@)%@:", kMDFRTLIsolate, kMDFPopIsolate]; | ||
self.labelTwo.text = | ||
[NSString stringWithFormat:@"Bidi Embed supported %@)%@:", kMDFRTLEmbedding, kMDFBidiPopEmbedding]; | ||
// self.labelThree.text = @"1st a-\u2068.)\u200f\u2069-b"; | ||
// self.labelFour.text = @"1st a-\u2068\u200f.)\u2069-b"; | ||
// self.labelFour.text = @"الو" // Hello | ||
NSString *three = [NSString stringWithFormat:@"Read %@15 books%@ EOL", kMDFFirstStrongIsolate, kMDFPopIsolate]; | ||
self.labelThree.text = three; | ||
NSString *four = [NSString stringWithFormat:@"Read %@15 كتاب%@ EOL", kMDFFirstStrongIsolate, kMDFPopIsolate]; | ||
self.labelFour.text = four; | ||
} | ||
|
||
- (void)didReceiveMemoryWarning { | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
/* | ||
#pragma mark - Navigation | ||
|
||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | ||
// Get the new view controller using [segue destinationViewController]. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
|
||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2018-present Google Inc. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSLocale (MaterialRTL) | ||
|
||
/** | ||
Is the direction of the current locale's default language Left-To-Right? | ||
|
||
@return YES if the language is LTR, NO if the language is any other direction. | ||
*/ | ||
+ (BOOL)mdf_isDefaultLanguageLTR; | ||
|
||
/** | ||
Is the direction of the current locale's default language Right-To-Left? | ||
|
||
@return YES if the language is RTL, NO if the language is any other direction. | ||
*/ | ||
+ (BOOL)mdf_isDefaultLanguageRTL; | ||
|
||
@end | ||
|
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,38 @@ | ||
/* | ||
Copyright 2018-present Google Inc. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#import "NSLocale+MaterialRTL.h" | ||
|
||
@implementation NSLocale (MaterialRTL) | ||
|
||
+ (BOOL)mdf_isDefaultLanguageLTR { | ||
NSString *languageCode = [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]; | ||
NSLocaleLanguageDirection characterDirection = | ||
[NSLocale characterDirectionForLanguage:languageCode]; | ||
BOOL localeLanguageDirectionIsLTR = (characterDirection == NSLocaleLanguageDirectionLeftToRight); | ||
return localeLanguageDirectionIsLTR; | ||
} | ||
|
||
+ (BOOL)mdf_isDefaultLanguageRTL { | ||
NSString *languageCode = [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]; | ||
NSLocaleLanguageDirection characterDirection = | ||
[NSLocale characterDirectionForLanguage:languageCode]; | ||
BOOL localeLanguageDirectionIsRTL = (characterDirection == NSLocaleLanguageDirectionRightToLeft); | ||
return localeLanguageDirectionIsRTL; | ||
} | ||
|
||
@end | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[stylenit] Indentation here and above.