KarenLocalizer is a library that allows developers to add localization support to their tweaks.
KarenLocalizer setup and usage (assuming you already have the latest version of Theos)
git clone https://github.com/akemin-dayo/KarenLocalizer.git
cd KarenLocalizer/
make setup
-
In your project's
Makefile
, addkarenlocalizer
to yourTweakName_LIBRARIES
variable. -
In your project's
control
file, addnet.angelxwind.karenlocalizer
to theDepends:
field.
You can use KarenLocalizer to localize text inside your tweaks. For instance, any UIAlertViews your tweak shows, or text inside your tweak's UIViews, etc.
You should not use KarenLocalizer in things that already support localization (UIKit apps, etc.). While there isn't anything wrong with doing so, it's just unnecessary.
#import <KarenLocalizer/KarenLocalizer.h>
#import <UIKit/UIKit.h>
KarenLocalizer *karenLocalizer;
%ctor {
karenLocalizer = [[KarenLocalizer alloc] initWithKarenLocalizerBundle:@"ExampleLocalizedTweak"];
}
%hook SpringBoard
-(void) applicationDidFinishLaunching:(id)arg {
%orig(arg);
UIAlertView *exampleAlert = [[UIAlertView alloc] initWithTitle:[karenLocalizer karenLocalizeString:@"LOCALIZED_TITLE"]
message:[karenLocalizer karenLocalizeString:@"LOCALIZED_MESSAGE"]
delegate:self
cancelButtonTitle:[karenLocalizer karenLocalizeString:@"LOCALIZED_BUTTON"]
otherButtonTitles:nil];
[exampleAlert show];
}
%end
With the above example, you'd need to place Localizable.strings
in layout/Library/KarenLocalizer/ExampleLocalizedTweak.bundle/Japanese.lproj/Localizable.strings
"LOCALIZED_TITLE" = "タイトル";
"LOCALIZED_MESSAGE" = "メッセージ";
"LOCALIZED_BUTTON" = "ボタン";
Note that KarenLocalizer will always look inside /Library/KarenLocalizer/
for bundles during initialisation.
Licensed under the 2-Clause BSD License.