PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/google-toolbox-for-mac/Foundation/GTMLocalizedString.h

http://macfuse.googlecode.com/
C++ Header | 79 lines | 39 code | 8 blank | 32 comment | 0 complexity | 20c855411ded77c2cb410486eb5776c3 MD5 | raw file
 1//
 2//  GTMLocalizedString.h
 3//
 4//  Copyright (c) 2010 Google Inc. All rights reserved.
 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 <Foundation/Foundation.h>
20#import "GTMDefines.h"
21
22// The NSLocalizedString macros do not have NS_FORMAT_ARGUMENT modifiers put
23// on them which means you get warnings on Snow Leopard with when 
24// GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES and you do things like:
25// NSString *foo 
26//   = [NSString stringWithFormat:NSLocalizedString(@"blah %@", nil), @"bar"];
27// The GTMLocalizedString functions fix that for you so you can do:
28// NSString *foo 
29//   = [NSString stringWithFormat:GTMLocalizedString(@"blah %@", nil), @"bar"];
30// and you will compile cleanly.
31// If you use genstrings you can call it with 
32// genstrings -s GTMLocalizedString ...
33// and it should work as expected.
34// You can override how GTM gets its localized strings (if you are using
35// something other than NSLocalizedString) by redefining 
36// GTMLocalizedStringWithDefaultValueInternal.
37
38#ifndef GTMLocalizedStringWithDefaultValueInternal
39  #define GTMLocalizedStringWithDefaultValueInternal \
40      NSLocalizedStringWithDefaultValue
41#endif
42
43GTM_INLINE NS_FORMAT_ARGUMENT(1) NSString *GTMLocalizedString(
44    NSString *key,  NSString *comment) {
45  return GTMLocalizedStringWithDefaultValueInternal(key, 
46                                                    nil, 
47                                                    [NSBundle mainBundle], 
48                                                    @"", 
49                                                    comment);
50}
51
52GTM_INLINE NS_FORMAT_ARGUMENT(1) NSString *GTMLocalizedStringFromTable(
53    NSString *key, NSString *tableName, NSString *comment) {
54  return GTMLocalizedStringWithDefaultValueInternal(key, 
55                                                    tableName, 
56                                                    [NSBundle mainBundle], 
57                                                    @"", 
58                                                    comment);
59}
60
61GTM_INLINE NS_FORMAT_ARGUMENT(1) NSString *GTMLocalizedStringFromTableInBundle(
62    NSString *key,  NSString *tableName, NSBundle *bundle, NSString *comment) {
63  return GTMLocalizedStringWithDefaultValueInternal(key, 
64                                                    tableName, 
65                                                    bundle, 
66                                                    @"", 
67                                                    comment);
68}
69
70GTM_INLINE NS_FORMAT_ARGUMENT(1) NSString *GTMLocalizedStringWithDefaultValue(
71    NSString *key, NSString *tableName, NSBundle *bundle, NSString *value,
72    NSString *comment) {
73  return GTMLocalizedStringWithDefaultValueInternal(key, 
74                                                    tableName, 
75                                                    bundle, 
76                                                    value, 
77                                                    comment);
78}
79