-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLanguageHelper.m
44 lines (35 loc) · 1.09 KB
/
LanguageHelper.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// LanguageHelper.m
// qeebuConference
//
// Created by hanson on 11/25/12.
// Copyright (c) 2012 com. All rights reserved.
//
#import "LanguageHelper.h"
@implementation LanguageHelper
static NSBundle *bundle = nil;
+(void)initialize {
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"CurrentLanguages"];
NSString *current = [languages objectAtIndex:0];
[self setLanguage:current];
}
/*
example calls:
[Language setLanguage:@"it"];
[Language setLanguage:@"de"];
*/
+(void)setLanguage:(NSString *)lan {
NSLog(@"preferredLang: %@", lan);
NSString *path = [[ NSBundle mainBundle ] pathForResource:lan ofType:@"lproj" ];
bundle = [NSBundle bundleWithPath:path];
}
+(NSString *)get:(NSString *)key alter:(NSString *)alternate {
return [bundle localizedStringForKey:key value:alternate table:nil];
}
+(NSString *)currentLanguage{
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"CurrentLanguages"];
return [languages objectAtIndex:0];
}
@end