i18n

package
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

Internationalization

New language

To localize into a new language:

  1. Create a folder in locales/ with the ISO 639-1 (preferred) or ISO 639-2 code.

  2. Copy the canonical example from locales/en/default.po:

    cp locales/en/default.po locales/<lang>/default.po
    
  3. Translate the msgstr values. Do not change other values in the file.

  4. Save the file and submit a pull request.

Update an existing language

To update an existing language:

  1. Find the language in the locales/ folder.

  2. Update the language on line 3.

  3. Update the msgstr fields to the new values.

  4. Save the file.

  5. Submit a pull request.

Terms

  • realm - public health authority, state, or hospital system. The system is multi-tenant, and a user can be a member of multiple realms. For example, the same doctor might operate clinics across state lines. In the US, each state is a "realm". In other areas, a realm could be a country or region.

  • case worker - someone at a health clinic, testing facility, doctor's office, etc that is managing cases related to COVID-19.

  • patient - the person who is being given a test result for COVID-19.

  • short code - 6-8 digit (numeric-only) code that is dictated to a patient by a case worker over the phone.

  • long code - 16+ alpha-numeric code that is sent to the patient via an SMS text message. This requires the patient to provide a phone number. If no phone number is provided, no long code is generated.

  • backup code - 6-8 digit (numeric-only) code that is dictated to a patient by a case worker over the phone if and only if the long code fails to dispatch (e.g. due to network issues). This requires the patient to provide a phone number. If no phone number is provided, no backup code is generated.

  • signing key - this refers to an asymmetric signing key (cryptography).

Documentation

Overview

Package i18n defines internationalization and localization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocaleMap

type LocaleMap struct {
	// contains filtered or unexported fields
}

LocaleMap is a map of locale names to their data structure.

func Load

func Load(pth string, opts ...Option) (*LocaleMap, error)

Load parses and loads the localization files from disk. It builds the locale matcher based on the currently available data (organized by folder).

Due to the heavy I/O, callers should cache the resulting value and only call Load when data needs to be refreshed.

func (*LocaleMap) Canonicalize

func (l *LocaleMap) Canonicalize(id string) (result string, retErr error)

Canonicalize converts the given ID to the expected name.

func (*LocaleMap) Lookup

func (l *LocaleMap) Lookup(ids ...string) *gotext.Locale

Lookup finds the best locale for the given ids. If none exists, the default locale is used.

If reloading is enabled, the locales are reloaded before lookup. If reloading fails, it panics. For this reason, you should not enable reloading in production.

type Option

type Option func(*LocaleMap) *LocaleMap

Option is an option to creating a locale map.

func WithReloading

func WithReloading(v bool) Option

WithReloading enables hot reloading for the map.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL