i18n

package
v0.13.14 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: MIT Imports: 2 Imported by: 0

README

i18n middleware

This Buffalo middleware enables i18n features in your app:

  • User language detection from configurable sources
  • Translation helper using locales bundles from github.com/nicksnyder/go-i18n
  • Localized views

Installation

This middleware is setup by default on a new Buffalo app:

actions/app.go

var app *buffalo.App

// T is used to provide translations
var T *i18n.Translator

// App is where all routes and middleware for buffalo
// should be defined. This is the nerve center of your
// application.
func App() *buffalo.App {
    if app == nil {
        // [...]

        // Setup and use translations:
	var err error
	if T, err = i18n.New(packr.NewBox("../locales"), "en"); err != nil {
		app.Stop(err)
	}
	app.Use(T.Middleware())
    }
    return app
}

Use i18n.New to create a new instance of the translation module, then add the middleware (T.Middleware()) to the app to enable its features.

See https://gobuffalo.io/docs/localization for further info about Buffalo translation features and configuration.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CookieLanguageExtractor = i18nm.CookieLanguageExtractor

CookieLanguageExtractor is a LanguageExtractor implementation, using a cookie.

Deprecated: use github.com/gobuffalo/mw-i18n#CookieLanguageExtractor instead.

View Source
var HeaderLanguageExtractor = i18nm.HeaderLanguageExtractor

HeaderLanguageExtractor is a LanguageExtractor implementation, using a HTTP Accept-Language header.

Deprecated: use github.com/gobuffalo/mw-i18n#HeaderLanguageExtractor instead.

View Source
var New = i18nm.New

New Translator. Requires a packd.Box that points to the location of the translation files, as well as a default language. This will also call t.Load() and load the translations from disk.

Deprecated: use github.com/gobuffalo/mw-i18n#New instead.

View Source
var SessionLanguageExtractor = i18nm.SessionLanguageExtractor

SessionLanguageExtractor is a LanguageExtractor implementation, using a session.

Deprecated: use github.com/gobuffalo/mw-i18n#SessionLanguageExtractor instead.

View Source
var URLPrefixLanguageExtractor = i18nm.URLPrefixLanguageExtractor

URLPrefixLanguageExtractor is a LanguageExtractor implementation, using a prefix in the URL.

Deprecated: use github.com/gobuffalo/mw-i18n#URLPrefixLanguageExtractor instead.

Functions

This section is empty.

Types

type LanguageExtractor deprecated added in v0.12.0

type LanguageExtractor = i18nm.LanguageExtractor

LanguageExtractor can be implemented for custom finding of search languages. This can be useful if you want to load a user's language from something like a database. See Middleware() for more information on how the default implementation searches for languages.

Deprecated: use github.com/gobuffalo/mw-i18n#LanguageExtractor instead.

type LanguageExtractorOptions deprecated added in v0.12.0

type LanguageExtractorOptions = i18nm.LanguageExtractorOptions

LanguageExtractorOptions is a map of options for a LanguageExtractor.

Deprecated: use github.com/gobuffalo/mw-i18n#LanguageExtractorOptions instead.

type Translator deprecated

type Translator = i18nm.Translator

Translator for handling all your i18n needs.

Deprecated: use github.com/gobuffalo/mw-i18n#Translator instead.

Jump to

Keyboard shortcuts

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