groue/GRMustache.swift

Localization Customization

Open

#37 创建于 2016年10月25日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)Swift (154 fork)github user discovery
enhancementhelp wanted

仓库指标

Star
 (629 star)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南