diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2011-11-16 14:30:21 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2011-11-16 14:30:21 +0000 |
commit | 711247f40bf28cc93e8be3e74bc5d654884c9ce4 (patch) | |
tree | bc5bc9f7fa4f47b49bd547a031535da7c6f8074e /iPhone/GTMUILocalizer.m | |
parent | 73d9542bde42d7b172f5db221d3403ceb4bdcf51 (diff) |
[Author: qsr]
Handle UIButton in GTMUILocalizer
To be noted: UISegmented Controls and UISearchBars were alredy
working. UISwitch doesn't have any strings to be localized.
R=dmaclach,thomasvl
APPROVED=thomasvl
Diffstat (limited to 'iPhone/GTMUILocalizer.m')
-rw-r--r-- | iPhone/GTMUILocalizer.m | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/iPhone/GTMUILocalizer.m b/iPhone/GTMUILocalizer.m index efebc42..c6b7fca 100644 --- a/iPhone/GTMUILocalizer.m +++ b/iPhone/GTMUILocalizer.m @@ -26,7 +26,7 @@ // -[self localizeObject:recursively:]. - (void)localizeToolbar:(UIToolbar *)toolbar; - (void)localizeView:(UIView *)view recursively:(BOOL)recursive; - +- (void)localizeButton:(UIButton *)button; @end @implementation GTMUILocalizer @@ -130,6 +130,11 @@ } } + // Specific types + if ([view isKindOfClass:[UIButton class]]) { + [self localizeButton:(UIButton *)view]; + } + // Then do all possible strings. if ([view respondsToSelector:@selector(title)] && [view respondsToSelector:@selector(setTitle:)]) { @@ -212,4 +217,20 @@ } } +- (void)localizeButton:(UIButton *)button { + UIControlState allStates[] = { UIControlStateNormal, + UIControlStateHighlighted, + UIControlStateDisabled, + UIControlStateSelected }; + for (size_t idx = 0; idx < (sizeof(allStates)/sizeof(allStates[0])) ; ++idx) { + UIControlState state = allStates[idx]; + NSString *value = [button titleForState:state]; + if (value) { + NSString* localizedValue = [self localizedStringForString:value]; + if (localizedValue) + [button setTitle:localizedValue forState:state]; + } + } +} + @end |