Socket
Socket
Sign inDemoInstall

github.com/volatile/i18n

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/volatile/i18n

Package i18n is a handler and helper for the core (https://godoc.org/github.com/volatile/core). It provides internationalization functions following the client preferences. A translation is associated to a key, which is associated to a language tag, which is part of Locales map. All translations can be stored like this: decimalMark and thousandsMark are special keys that define the digits separators for decimals and thousands when using Tn or Fmtn. With these translations, you need to Init this package (the second argument is the default locale): When a client makes a request, the best locale must be matched to his preferences. To achieve this, you need to Use the handler with one or more matchers: The client locale is set as soon as a matcher is confident. A matcher is a function that returns the locale parsed from core.Context with its level of confidence. These ones are actually available: MatcherAcceptLanguageHeader and MatcherFormValue. A translation can be accessed with T, receiving the core.Context (which contains the matched locale), the translation key, and optional arguments (if the translation contains formatting verbs): If a translation has pluralized forms, you can use Tn and the most appropriate form will be used according to the quantity: will result in "You have 333,000.333 bucks in your basement.". If you use templates, TemplatesFuncs provides a map of all usable functions. Example with package response (https://godoc.org/github.com/volatile/response) package:


Version published

Readme

Source

i18n

Package i18n is a handler and helper for the core.
It provides internationalization functions following the client preferences.

GoDoc

FAQs

Last updated on 06 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc