Multiple Localized .strings Files in iOS App Bundle

前端 未结 5 1218
清酒与你
清酒与你 2020-12-09 13:07

I have a fairly complicated project, consisting of several large localized sub-projects.

Most of my sub-projects are localized through a single Localizable.s

5条回答
  •  無奈伤痛
    2020-12-09 13:52

    I have another solution.

    #define localizedString(key)    [NSLocalizedString(key, nil) isEqualToString:key] ? \
                                [[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"]]  localizedStringForKey:key value:@"" table:nil] : \
                                NSLocalizedString(key, nil)
    

    so for instance if we're going to find a key "title" = "Manager"; in Localizable.strings (fr) and if not there then the result for the key "title" will be just same as the key.

    In this case we can find the key "title" in localizable.string (en) but if can find in (fr) we can just use it.

提交回复
热议问题