JSPM

catberry-l10n-handlebars-helper

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q53357F

Handlebars helper for Catberry localization plugin

Package Exports

  • catberry-l10n-handlebars-helper

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (catberry-l10n-handlebars-helper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Handlebars helper for Catberry localization plugin

NPM

Description

You can use Handlebars helper that puts localized value anywhere 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"}}

Contribution

If you have found a bug, please create pull request with mocha unit-test which reproduces it or describe all details in an issue if you can not implement test. If you want to propose some improvements just create an issue or a pull request but please do not forget to use npm test to be sure that your code is awesome.

All changes should satisfy this Code Style Guide.

Also your changes should be covered by unit tests using mocha.

Denis Rechkunov denis.rechkunov@gmail.com