Documentation/templates/strings/objc.md
| Name | Description |
|---|---|
| File names | strings/objc-string-h.stencil & strings/objc-string-m.stencil |
| Configuration example | <pre>strings: |
| inputs: path/to/Localizable.strings | |
| outputs: |
- templateName: objc-h
output: Localizable.h
- templateName: objc-m
output: Localizable.m</pre> |
| Language | Objective-C | | Author | Eric Slosser |
You can customize some elements of this template by overriding the following parameters when invoking swiftgen. See the dedicated documentation.
| Parameter Name | Default Value | Description |
|---|---|---|
bundle | [NSBundle bundleForClass:BundleToken.class] | Allows you to set from which bundle strings are loaded from. By default, it'll point to the same bundle as where the generated code is. Note: ignored if lookupFunction parameter is set. |
headerName | "Localizable.h" | The name of the ObjC header generated by the objc-string-h template. The generated .m file will #include "{{headerName}}". This parameter should have the same value as the output file name used for the template: objc-string-h entry in your config file. |
noComments | N/A | Setting this parameter will disable the comments containing the comment from the strings file or the translation of a key. |
Extract:
@interface Localizable : NSObject
/// Some alert body there
+ (NSString*)alertMessage;
/// Title for an alert
+ (NSString*)alertTitle;
/// These are %3$@'s %1$d %2$@.
+ (NSString*)objectOwnershipWithValues:(NSInteger)p1 :(id)p2 :(id)p3;
/// This is a %% character.
+ (NSString*)percent;
...
@end
// simple strings
NSString* message = Localizable.alertMessage
NSString* title = Localizable.alertTitle
// with parameters, note that each argument needs to be of the correct type
NSString* apples = [Localizable.applesCountWithValue:3];
NSString* bananas = [Localizable.bananasOwnerWithValues:5 :@"Olivier"];