diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2010-05-06 22:35:09 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2010-05-06 22:35:09 +0000 |
commit | 2ebeaf6626b9543e569f1e29fb6c6149c904502e (patch) | |
tree | d1be65fdbb1c7df25b32680d89f35fcd528f3604 /Foundation/GTMLocalizedString.h | |
parent | 68f68d2763dac1dc1677b3e49eec507709c4dce9 (diff) |
[Author: dmaclach]
So I can get around warnings on CoverStory on SnowLeopard. Hopefully Apple
will fix this on their end and we can drop back to NSLocalizedString
in future SDKs.
R=thomasvl
Diffstat (limited to 'Foundation/GTMLocalizedString.h')
-rw-r--r-- | Foundation/GTMLocalizedString.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/Foundation/GTMLocalizedString.h b/Foundation/GTMLocalizedString.h new file mode 100644 index 0000000..c5fcde6 --- /dev/null +++ b/Foundation/GTMLocalizedString.h @@ -0,0 +1,84 @@ +// +// GTMLocalizedString.h +// +// Copyright (c) 2010 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import <Foundation/Foundation.h> +#import "GTMDefines.h" + +// The NSLocalizedString macros do not have NS_FORMAT_ARGUMENT modifiers put +// on them which means you get warnings on Snow Leopard with when +// GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES and you do things like: +// NSString *foo +// = [NSString stringWithFormat:NSLocalizedString(@"blah %@", nil), @"bar"]; +// The GTMLocalizedString functions fix that for you so you can do: +// NSString *foo +// = [NSString stringWithFormat:GTMLocalizedString(@"blah %@", nil), @"bar"]; +// and you will compile cleanly. +// If you use genstrings you can call it with +// genstrings -s GTMLocalizedString ... +// and it should work as expected. +// You can override how GTM gets its localized strings (if you are using +// something other than NSLocalizedString) by redefining +// GTMLocalizedStringWithDefaultValueInternal. + +#ifndef GTMLocalizedStringWithDefaultValueInternal + #define GTMLocalizedStringWithDefaultValueInternal \ + NSLocalizedStringWithDefaultValue +#endif + +GTM_INLINE NSString *GTMLocalizedString(NSString *key, + NSString *comment) NS_FORMAT_ARGUMENT(1) { + return GTMLocalizedStringWithDefaultValueInternal(key, + nil, + [NSBundle mainBundle], + @"", + comment); +} + +GTM_INLINE NSString *GTMLocalizedStringFromTable(NSString *key, + NSString *tableName, + NSString *comment) NS_FORMAT_ARGUMENT(1) { + return GTMLocalizedStringWithDefaultValueInternal(key, + tableName, + [NSBundle mainBundle], + @"", + comment); +} + +GTM_INLINE NSString *GTMLocalizedStringFromTableInBundle(NSString *key, + NSString *tableName, + NSBundle *bundle, + NSString *comment) NS_FORMAT_ARGUMENT(1) { + return GTMLocalizedStringWithDefaultValueInternal(key, + tableName, + bundle, + @"", + comment); +} + +GTM_INLINE NSString *GTMLocalizedStringWithDefaultValue(NSString *key, + NSString *tableName, + NSBundle *bundle, + NSString *value, + NSString *comment) NS_FORMAT_ARGUMENT(1) { + return GTMLocalizedStringWithDefaultValueInternal(key, + tableName, + bundle, + value, + comment); +} + |