Now after changing language (for example: dp_set_current_language(@"de")) all objects, which was configured for dynamic localization, update their content.
###Static localization
For static localization select language (for example: dp_set_current_language(@"de")) and use DPLocalizedString() macro in NSLocalizedString() maner.
###Proxy objects
Use DPAutolocalizationProxy class methods or their replacements.
Some contols (since iOS 6) are support attributed values. You can specify attributes using special format (<attributes>{string}), it also reqire to set isAttributedKey property to YES. Attributes will apply for string inside {}, other parts will use parameters specified by control. For example:
name - set font name - <name=\"Courier-BoldOblique\">{string}
size - set font size - <size=12.0>{string} or <size=12>{string}
color - set text color in RGB or RGBA format - <color=12,56,189>{string} or <color=12,56,189,255>{string}
traits - set font traits: b (bold), i (italic); and text attributes u (underline), s (strikethrough), m (monospace); ! used for remove attibute - <traits=b>{string} or <traits=!b>{string}
kern - set font kerning
link - set link attribute - <link=\"https://github.com/nullic/DPLocalizationManager\">{link to DPLocalizationManager}
spacing - set space between paragraphs
linespacing - set space between lines
alignment - set alignment of paragraph <alignment=center>{Center\n}<alignment=left>{Left}. Valid values: leftcenterrightjustifiednatural. Due to NSParagraphStyle behaviour each paragraph should be ended with \n and each section should have alignment if it is used in any place of localization string.
Replacements
You can specify replacement using next format: [<replacer>]. This feature also reqire set isAttributedKey property to YES.
Example:
img - insert image named - [<img=\"image_name_here\"> size=(16,16) offset=(0,0)] - size and offset are optinal parameters. By default size is (image.width, image.height); offset is (0, font.descender)
Installation
CocoaPods
DPLocalization is available through CocoaPods, to install
it simply add the following line to your Podfile:
pod "DPLocalization"
Carthage
To integrate DPLocalization into your Xcode project using Carthage, specify it in your Cartfile:
github "nullic/DPLocalizationManager"
Run carthage update to build the framework and drag the built DPLocalization.framework into your Xcode project.
Localization check
dpstrings.py it is Python script, that used for checking most common usage of library. It's scan {some} folder for sources and resoures and make validation for common errors (missing keys, duplication).
Usage example: python dpstrings.py -p "MyProjectPath" -l "en;ru;".
For more information: python dpstrings.py --help.
License
DPLocalization is available under the MIT license. See the LICENSE file for more info.
请发表评论