* v0.9.2
- * sogod.m: added localization methods. Current locale is put into WOContext
- upon first request. All locales are cached in the application object.
+ * sogod.m: added localization methods. Current locale is put into
+ WOContext upon first request. All locales are cached in the
+ application object.
- * [English,French].lproj: created. Put appropriate Locale representations
- here.
+ * [English,French].lproj: created. Put appropriate Locale
+ representations here.
* GNUmakefile: added LANGUAGES and LOCALIZED_RESOURCES.
/* localization */
- (NSDictionary *)currentLocaleConsideringLanguages:(NSArray *)_langs {
- unsigned i, count;
-
- // assume _langs is ordered by priority
- count = [_langs count];
- for(i = 0; i < count; i++) {
- NSString *lname;
- NSDictionary *locale;
-
- lname = [_langs objectAtIndex:i];
- locale = [self localeForLanguageNamed:lname];
- if(locale)
- return locale;
- }
- // no appropriate language, fallback to default
- return [self localeForLanguageNamed:@"English"];
+ unsigned i, count;
+
+ /* assume _langs is ordered by priority */
+ count = [_langs count];
+ for (i = 0; i < count; i++) {
+ NSString *lname;
+ NSDictionary *locale;
+
+ lname = [_langs objectAtIndex:i];
+ locale = [self localeForLanguageNamed:lname];
+ if (locale)
+ return locale;
+ }
+ /* no appropriate language, fallback to default */
+ return [self localeForLanguageNamed:@"English"];
}
- (NSDictionary *)localeForLanguageNamed:(NSString *)_name {
- NSString *lpath;
- NSDictionary *locale;
+ NSString *lpath;
+ NSDictionary *locale;
- NSAssert(_name != nil, @"_name MUST NOT be nil!");
- if((locale = [self->localeLUT objectForKey:_name]) != nil)
- return locale;
- lpath = [[self resourceManager]
- pathForResourceNamed:@"Locale"
- inFramework:nil
- languages:[NSArray arrayWithObject:_name]];
- locale = [[NSString stringWithContentsOfFile:lpath]
- propertyList];
- if(locale == nil) {
- NSLog(@"%s didn't find locale with name:%@",
- __PRETTY_FUNCTION__,
- _name);
- return nil;
- }
- [self->localeLUT setObject:locale forKey:_name];
+ NSAssert(_name != nil, @"_name MUST NOT be nil!");
+ if ((locale = [self->localeLUT objectForKey:_name]) != nil)
return locale;
+
+ lpath = [[self resourceManager]
+ pathForResourceNamed:@"Locale"
+ inFramework:nil
+ languages:[NSArray arrayWithObject:_name]];
+ locale = [[NSString stringWithContentsOfFile:lpath] propertyList];
+ if (locale == nil) {
+ NSLog(@"%s didn't find locale with name:%@",
+ __PRETTY_FUNCTION__,
+ _name);
+ return nil;
+ }
+ [self->localeLUT setObject:locale forKey:_name];
+ return locale;
}
@end /* SOGo */