PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/google-toolbox-for-mac/iPhone/GTMUILocalizer.h

http://macfuse.googlecode.com/
C++ Header | 81 lines | 16 code | 6 blank | 59 comment | 0 complexity | dfe313b8b8c28c4f1f0bf37bb035c864 MD5 | raw file
 1//
 2//  GTMUILocalizer.h
 3//
 4//  Copyright 2011 Google Inc.
 5//
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
 9//
10//  http://www.apache.org/licenses/LICENSE-2.0
11//
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
17//
18
19#import <UIKit/UIKit.h>
20
21// A class for localizing nibs by doing simple string replacement.
22// To use this, make an instance of GTMUILocalizer in your nib. Connect the
23// owner outlet of the your instance to the File Owner of the nib. It expects
24// the owner outlet to be an instance or subclass of UIViewController.  Using
25// the bundle of the nib it will then localize any items in the
26// UIViewController's view and subviews when awakeFromNib is called on the
27// GTMUILocalizer instance.
28// You can optionally hook up otherObjectToLocalize and
29// yetAnotherObjectToLocalize and those will also be localized. Strings in the
30// nib that you want localized must start with ^ (shift-6). The strings will
31// be looked up in the Localizable.strings table without the caret as the
32// key.
33//
34// As an example if I wanted to localize a button with the word "Print" on
35// it, I would put it in a view controlled by a UIViewController that was
36// the owner of the nib. I would set it's title to be "^Print". I would then
37// create an instance of GTMUILocalizer and set it's owner to be the owner
38// of the nib.
39// In my Localizable.strings file in my fr.lproj directory for the bundle
40// I would put "Print" = "Imprimer";
41// Then when my app launched in French I would get a button labeled
42// "Imprimer". Note that GTMUILocalizer is only for strings, and doesn't
43// resize, move or change text alignment on any of the things it modifies.
44// If you absolutely need a caret at the beginning of the string
45// post-localization, you can put "Foo" = "^Foo"; in your strings file and
46// it will work.
47// Your nib could be located in a variety of places depending on what you want
48// to do. I would recommend having your "master" nib directly in Resources.
49// If for some reason you needed to do some custom localization of the
50// nib you could copy the master nib into your specific locale folder, and
51// then you only need to adjust the items in the nib that you need to
52// customize. You can leave the strings in the "^Foo" convention and they
53// will localize properly. This keeps the differences between the nibs down
54// to the bare essentials.
55//
56@interface GTMUILocalizer : NSObject {
57 @private
58  id owner_;
59  id otherObjectToLocalize_;
60  id yetAnotherObjectToLocalize_;
61  NSBundle *bundle_;
62}
63@property(nonatomic, assign) IBOutlet id owner;
64@property(nonatomic, assign) IBOutlet id otherObjectToLocalize;
65@property(nonatomic, assign) IBOutlet id yetAnotherObjectToLocalize;
66
67- (id)initWithBundle:(NSBundle *)bundle;
68
69// Localize |object|. If |recursive| is true, it will attempt
70// to localize objects owned/referenced by |object|.
71- (void)localizeObject:(id)object recursively:(BOOL)recursive;
72
73// A method for subclasses to override in case you have a different
74// way to go about getting localized strings.
75// If |string| does not start with ^ you should return nil.
76// If |string| is nil, you should return nil
77- (NSString *)localizedStringForString:(NSString *)string;
78
79// Allows subclasses to override how the bundle is picked up
80+ (NSBundle *)bundleForOwner:(id)owner;
81@end