i18n

package
v8.4.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2017 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package i18n provides internalization and localization via middleware. See _examples/miscellaneous/i18n

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c Config) context.Handler

New returns a new i18n middleware

func Translate

func Translate(ctx context.Context, format string, args ...interface{}) string

Translate returns the translated word from a context the second parameter is the key of the world or line inside the .ini file the third parameter is the '%s' of the world or line inside the .ini file

func TranslatedMap

func TranslatedMap(ctx context.Context, sourceInterface interface{}) map[string]interface{}

TranslatedMap returns translated map[string]interface{} from i18n structure.

Types

type Config

type Config struct {
	// Default set it if you want a default language
	//
	// Checked: Configuration state, not at runtime
	Default string
	// URLParameter is the name of the url parameter which the language can be indentified
	//
	// Checked: Serving state, runtime
	URLParameter string
	// Languages is a map[string]string which the key is the language i81n and the value is the file location
	//
	// Example of key is: 'en-US'
	// Example of value is: './locales/en-US.ini'
	Languages map[string]string
}

Config the i18n options

Jump to

Keyboard shortcuts

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