| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/cocoa/ui_localizer.h" | 5 #import "chrome/browser/cocoa/ui_localizer.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Sanity check, there shouldn't be any strings with this id that aren't | 71 // Sanity check, there shouldn't be any strings with this id that aren't |
| 72 // in our map. | 72 // in our map. |
| 73 DLOG_IF(WARNING, [key hasPrefix:@"^ID"]) << "Key '" << utf8_key | 73 DLOG_IF(WARNING, [key hasPrefix:@"^ID"]) << "Key '" << utf8_key |
| 74 << "' wasn't in the resource map?"; | 74 << "' wasn't in the resource map?"; |
| 75 | 75 |
| 76 // If we didn't find anything, this string doesn't need localizing. | 76 // If we didn't find anything, this string doesn't need localizing. |
| 77 return nil; | 77 return nil; |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace ui_localizer | 80 } // namespace ui_localizer |
| 81 |
| 82 @interface GTMUILocalizer (PrivateAdditions) |
| 83 - (void)localizedObjects; |
| 84 @end |
| 85 |
| 86 @implementation GTMUILocalizer (PrivateAdditions) |
| 87 - (void)localizedObjects { |
| 88 // The ivars are private, so this method lets us trigger the localization |
| 89 // from -[ChromeUILocalizer awakeFromNib]. |
| 90 [self localizeObject:owner_ recursively:YES]; |
| 91 [self localizeObject:otherObjectToLocalize_ recursively:YES]; |
| 92 [self localizeObject:yetAnotherObjectToLocalize_ recursively:YES]; |
| 93 } |
| 94 @end |
| 95 |
| 96 @implementation ChromeUILocalizer |
| 97 - (void)awakeFromNib { |
| 98 // The GTM base is bundle based, since don't need the bundle, use this |
| 99 // override to bypass the bundle lookup and directly do the localization |
| 100 // calls. |
| 101 [self localizedObjects]; |
| 102 } |
| 103 #ifndef NDEBUG |
| 104 // Catch anyone that uses this directly. |
| 105 - (NSString *)localizedStringForString:(NSString *)string { |
| 106 LOG(FATAL) << "Don't use ChromeUILocalizer directly."; |
| 107 return @"Don't use ChromeUILocalizer directly."; |
| 108 } |
| 109 #endif |
| 110 @end |
| OLD | NEW |