Skip to content

barrettj/EXiLE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EXiLE

EXiLE (Easy Xib Localization Entity) is meant to be an easy way to localize iOS projects that use XIBs without having to deal with duplicating the XIBs for each localization.

EXiLE loops through all the nested views and generates what it thinks the a good localization key would be for each element (prefixing each one with the string you pass, so items on different view controllers will have different prefixes) and adding a suffix based on the type of UIView the item is.

How to Use It / How I Use It

I #import "EXiLE.h" in my precompiled header so it's always available.

In my AppDelegate application:didFinishLaunchingWithOptions:, I add the following:

// setup a block so you can be notified when a localization is missing
EXILE.onUnlocalizedString = ^(NSString *unlocalizedString, NSString *localizationKey) {
    NSLog(@"\"%@\" = \"%@\";", localizationKey, unlocalizedString);
    };

Then in your ViewControllers, add this to viewDidLoad:

[EXILE localizeViewController:self withLocalizationPrefix:@"BJVC"];

Then if you run your app (assuming you didn't already have the fields localized), you'll get output similar to the following:

2012-04-11 09:08:44.750 EXiLE-Demo[99460:fb03] "BJVC_THIS_IS_THE_BUTTON_TEXT_BUTTON_TEXT" = "This is the Button Text";
2012-04-11 09:08:44.752 EXiLE-Demo[99460:fb03] "BJVC_THIS_IS_A_LABEL_LABEL" = "This is a label";
2012-04-11 09:08:44.752 EXiLE-Demo[99460:fb03] "BJVC_THIS_IS_A_NESTED_LABEL_LABEL" = "This is a nested label";
2012-04-11 09:08:44.753 EXiLE-Demo[99460:fb03] "BJVC_THIS_IS_A_LABEL_WITH_A_DIFFERENT_ACCESSIBILITY_LABEL_LABEL" = "This is a label with a different accessibility label";
2012-04-11 09:08:44.754 EXiLE-Demo[99460:fb03] "BJVC_IM_EXTRA_ACCESSIBLE_ACCESSIBILITY_LABEL" = "I'm extra accessible!";
2012-04-11 09:08:44.754 EXiLE-Demo[99460:fb03] "BJVC_THE_FIRST_SEGMENT_SEGMENT_TEXT" = "The First Segment";
2012-04-11 09:08:44.755 EXiLE-Demo[99460:fb03] "BJVC_THE_SECOND_SEGMENT_SEGMENT_TEXT" = "The Second Segment";
2012-04-11 09:08:44.756 EXiLE-Demo[99460:fb03] "BJVC_IM_A_VIEW_WITH_AN_ACCESSIBILITY_LABEL_ACCESSIBILITY_LABEL" = "I'm a view with an accessibility label";
2012-04-11 09:08:44.757 EXiLE-Demo[99460:fb03] "SUPER_LONG_LABEL_TEXT" = "This is a really long label so I wouldn't want to use the autogenerated key because that has a high likelyhood of changing so we specify the key using a special syntax.";

Which you can basically copy and paste into your Localizable.strings file (after removing the timestamps from the beginning of a line).

Ignoring a Control

Any control who's text starts and ends with an underscore will not be localized (as it's assumed that control's text will be set via code later on)

E.G.:

_I'm set in code later_

Manually Specifying a Localization Key

If you want to manually specify the localization key for a control (instead of having EXiLE generate one for you), append the control's text with LOCALIZATION_KEY

E.G.:

This is a really long label, but I don't want the name to be really long.**LONG_LABEL**

ARC

This project uses ARC.

License

Released under an MIT License with a please tweet me (@barrettjacobsen) to let me know you're using it, mostly because I'm vain.

About

Easy Xib Localization Entity

Resources

License

Stars

Watchers

Forks

Packages

No packages published