mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 07:10:37 +00:00
(+defaultWritingDirectionForLanguage:): Implement.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19291 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cfe33cfa9e
commit
476a373bf8
3 changed files with 41 additions and 4 deletions
|
@ -139,8 +139,35 @@ static NSParagraphStyle *defaultStyle = nil;
|
|||
|
||||
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString*) language
|
||||
{
|
||||
// FIXME
|
||||
return NSWritingDirectionNaturalDirection;
|
||||
static NSArray *rightToLeft;
|
||||
NSWritingDirection writingDirection;
|
||||
NSString *langCode = nil;
|
||||
|
||||
/* If language is 5/6 characters long with underscore in the middle,
|
||||
treat it as ISO language-region format. */
|
||||
if ([language length] == 5 && [language characterAtIndex: 2] == '_')
|
||||
langCode = [language substringToIndex: 2];
|
||||
else if ([language length] == 6 && [language characterAtIndex: 3] == '_')
|
||||
langCode = [language substringToIndex: 3];
|
||||
/* Else if it's just two or three chars long, treat as ISO 639 code. */
|
||||
else if ([language length] == 2 || [language length] == 3)
|
||||
langCode = language;
|
||||
|
||||
if (!rightToLeft)
|
||||
// Holds languages whose current scripts are written right to left.
|
||||
rightToLeft = [[NSArray alloc] initWithObjects: @"ar", @"ara", @"arc",
|
||||
@"chi", @"fa", @"fas", @"he", @"heb", @"iw",
|
||||
@"ji", @"kas", @"ks", @"ku", @"kur", @"pa",
|
||||
@"pan", @"per" @"ps", @"pus", @"sd", @"snd",
|
||||
@"syr", @"tk", @"tmh", @"tuk", @"ug",
|
||||
@"uig", @"ur," @"urd", @"yi", @"yid", @"zh",
|
||||
@"zho", nil];
|
||||
if ([rightToLeft containsObject: langCode] == YES)
|
||||
writingDirection = NSWritingDirectionRightToLeft;
|
||||
else // If it's not RTL, assume LTR.
|
||||
writingDirection = NSWritingDirectionLeftToRight;
|
||||
|
||||
return writingDirection;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue