by Jesse Collis
NSLocalizedString macros provided in
UIBundle.h are bound to your application's language very early in your app's lifecycle. You may have an app that would benefic from it's own internal run time language selection.
JCLocalizedString aims to provide the same default behaviour as and compatibility as
NSLocalizedStirng while adding additional features like runtime language selection and custom bundles.
I'm very passionate about doing this localisation thing well; I recently did a presentation at Melbourne Cocoaheads on how I think you should use
NSLocalizedString to make localising your app much much easier.
JCLocalizedString is in very early stages so comments and pull requests are appreciated!
JCLocalizedString defines new macros to replace NSLocalizedString with the same API
JCLocalizedString((NSString *)key, (NSString *)description) JCLocalizedStringFromTable((NSString *)key, (NSString *)tbl, (NSString *)comment) JCLocalizedStringFromTableInBundle((NSString *)key, (NSString *)tbl, (NSString *)bundle, (NSString *)comment) JCLocalizedStringWithDefaultValue((NSString *)key, (NSString *)tbl, (NSString *)bundle, (NSString *)val, (NSString *)comment)
Changing the bundle at run time will generate a global notification named
Define a custom bundle in info.plsit
JCLocalizationBundle key in info.plist to the name of your custom butotn.
genstrings with JCLocalizedString
- use the custom class thing
- enforce my own things
The code is copyright (c) 2012, Jesse Collis email@example.com. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.