diff options
Diffstat (limited to 'platform/darwin/src/MGLAttributionInfo.mm')
-rw-r--r-- | platform/darwin/src/MGLAttributionInfo.mm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm index 92fb9b689f..29dd5229a7 100644 --- a/platform/darwin/src/MGLAttributionInfo.mm +++ b/platform/darwin/src/MGLAttributionInfo.mm @@ -168,6 +168,25 @@ return components.URL; } +- (NSAttributedString *)titleWithStyle:(MGLAttributionInfoStyle)style +{ + NSString *openStreetMap = NSLocalizedStringWithDefaultValue(@"OSM_FULL_NAME", nil, nil, @"OpenStreetMap", @"OpenStreetMap full name attribution"); + NSString *OSM = NSLocalizedStringWithDefaultValue(@"OSM_SHORT_NAME", nil, nil, @"OSM", @"OpenStreetMap short name attribution"); + + NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithAttributedString:self.title]; + [title removeAttribute:NSUnderlineStyleAttributeName range:NSMakeRange(0, [title.string length])]; + + BOOL isAbbreviated = (style == MGLAttributionInfoStyleShort); + + if ([title.string rangeOfString:@"OpenStreetMap"].location != NSNotFound) { + [title.mutableString replaceOccurrencesOfString:@"OpenStreetMap" withString:isAbbreviated ? OSM : openStreetMap + options:NSCaseInsensitiveSearch + range:NSMakeRange(0, [title.mutableString length])]; + } + + return title; +} + - (BOOL)isEqual:(id)object { return [object isKindOfClass:[self class]] && [[object title] isEqual:self.title] && [[object URL] isEqual:self.URL]; } |