Inherits from NSObject
Conforms to GRMustacheFilter
GRMustacheRendering
Declared in GRMustacheLocalizer.h

Overview

GRMustacheLocalizer can localize the content of a Mustache section. It also has a filter facet that localizes your data.

Companion guide: https://github.com/groue/GRMustache/blob/master/Guides/standard_library.md#localize

The GRMustache standard library has a localize key which returns a GRMustacheLocalizer that localizes just like the NSLocalizableString macro does: with the Localizable.strings table of the main bundle.

Localizing data:

{{ localize(greeting) }} renders NSLocalizedString(@"Hello", nil), assuming the greeting key resolves to the Hello string.

Localizing sections:

{{#localize}}Hello{{/localize}} renders NSLocalizedString(@"Hello", nil).

Localizing sections with arguments:

{{#localize}}Hello {{name}}{{/localize}} builds the format string Hello %@, localizes it with NSLocalizedString, and finally injects the name with [NSString stringWithFormat:].

Localize sections with arguments and conditions:

{{#localize}}Good morning {{#title}}{{title}}{{/title}} {{name}}{{/localize}} build the format string Good morning %@" or @"Good morning %@ %@, depending on the presence of the title key. It then injects the name, or both title and name, with [NSString stringWithFormat:], to build the final rendering.

Custom GRMustacheLocalizer

You can build your own localizing helper with the initWithBundle:tableName: method. The helper would then localize using the specified table from the specified bundle.

Properties

bundle

The bundle where to look for localized strings.

@property (nonatomic, retain, readonly) NSBundle *bundle

Availability

v6.4

Declared In

GRMustacheLocalizer.h

tableName

The table where to look for localized strings.

@property (nonatomic, retain, readonly) NSString *tableName

Availability

v6.4

Discussion

If nil, the default Localizable.strings table would be searched.

Declared In

GRMustacheLocalizer.h

Instance Methods

initWithBundle:tableName:

Returns an initialized localizing helper.

- (instancetype)initWithBundle:(NSBundle *)bundle tableName:(NSString *)tableName

Parameters

bundle

The bundle where to look for localized strings. If nil, the main bundle is used.

tableName

The table where to look for localized strings. If nil, the default Localizable.strings table would be searched.

Return Value

A newly initialized localizing helper.

Availability

v6.4

Declared In

GRMustacheLocalizer.h