GRMustache.swift icon indicating copy to clipboard operation
GRMustache.swift copied to clipboard

Localization Customization

Open groue opened this issue 9 years ago • 2 comments

The Localizer filter brings localization to your mustache templates:

let template = ...
template.register(StandardLibrary.Localizer(), forKey: "localize")

It can localize:

  • variables: {{ localize(greeting) }} renders the localization of the greeting variable
  • template snippets: {{# localize }}Hello{{/ localize }} renders the localization of "Hello"
  • embedded variables: {{# localize }}Hello {{name}}{{/ localize }} localizes "Hello %@", and uses the result at a format string in which in injects the rendering of the name variable

As it is today, Localizer uses NSLocalizedString. Two areas of improvements are:

  • Make Localizer extensible so that it can be fueled by another localization engine than NSLocalizedString
  • Make it use a custom locale

groue avatar Oct 25 '16 12:10 groue

CC @vadimeisenbergibm since this topic may be of some interest for Kitura

groue avatar Oct 25 '16 12:10 groue

@groue Until now we did not receive any localization requirements, so I have no opinion on this topic.

vadimeisenbergibm avatar Nov 06 '16 13:11 vadimeisenbergibm