Handlebars helper for Catberry localization plugin
JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.editorconfig
.eslintignore
.eslintrc
.gitignore
.npmignore
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
index.js
package.json

README.md

Handlebars helper for Catberry localization plugin

Gitter

Installation

npm install catberry-l10n-handlebars-helper --save

Description

You can use Handlebars helper that puts localized value wherever you want:

{{l10n "SOME_LOCALIZATION_KEY" "en-us" 5}}
  • first found string - localization key
  • first found number - pluralization count (optional)
  • second found string - current user localization (optional)

Let's say we have such localization dictionary:

{
	"COMMENT": ["comment", "comments"]
}

And we use such helper parameters:

{{l10n "COMMENT" "en-us" 1}}

It outputs comment word.

{{l10n "COMMENT" "en-us" 5}}

It outputs comments word.

Also, if you do not specify locale value into helper arguments it will take locale value from template data context.

{{l10n "COMMENT" 5}}

Also, you can use it without plural count

{{l10n "COMMENT"}}

Contributing

There are a lot of ways to contribute:

Denis Rechkunov denis.rechkunov@gmail.com