i18n

package module
v0.0.0-...-dbdc49b Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 10 Imported by: 0

README

Backlog

  • SHOULD add template helper for translation inside templates
  • COULD add middleware that provides a localizer, based on accept-language
  • COULD go for 100% test coverage
  • COULD add a big-T (T) interface

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(logs *zap.Logger, cfg Conf, p Params) (b *i18n.Bundle, err error)

New inits the i18n bundle

Types

type Conf

type Conf struct {
	DefaultLanguage string   `env:"RB_I18N_DEFAULT_LANGUAGE" envDefault:"en-US"`
	Dir             string   `env:"RB_I18N_DIR"`
	FileNames       []string `env:"RB_I18N_FILE_NAMES" envSeparator:":"`
}

Conf configures the i18n setup

func ParseConf

func ParseConf() (cfg Conf, err error)

ParseConf parses the env

type MessageFiles

type MessageFiles fs.FS

MessageFiles are translations files on a filesystem

func FromDir

func FromDir(logs *zap.Logger, cfg Conf) MessageFiles

FromDir provides translation files from an actual directory

func FromEmbed

func FromEmbed(efs embed.FS) MessageFiles

FromEmbed creates a translation message files fs from an embedded filesystem

type Params

type Params struct {
	fx.In
	Files MessageFiles
}

Params are parameters for the bundle constructor

Jump to

Keyboard shortcuts

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