i18n

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

  • Copyright (c) 2018. Abstrium SAS <team (at) pydio.com>
  • This file is part of Pydio Cells. *
  • Pydio Cells is free software: you can redistribute it and/or modify
  • it under the terms of the GNU Affero General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • Pydio Cells is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU Affero General Public License for more details. *
  • You should have received a copy of the GNU Affero General Public License
  • along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>. *
  • The latest code can be found at <https://pydio.com>.

Package i18n wraps go-i18n lib for manipulating bundles

Index

Constants

This section is empty.

Variables

View Source
var (
	AvailableLanguages = map[string]string{
		"en-us": "English",
		"fr":    "Français",
		"de":    "Deutsch",
		"es-es": "Español",
		"it":    "Italiano",
		"pt-br": "Portuguese",
	}

	LanguagesLegacyNames = map[string]string{
		"en":    "en-us",
		"fr":    "fr",
		"es":    "es-es",
		"it":    "it",
		"pt":    "pt-pt",
		"pt-br": "pt-br",
		"de":    "de",

		"ru":    "ru",
		"ca":    "ca",
		"cs":    "cs",
		"da":    "da",
		"et":    "et",
		"fi":    "fi",
		"he":    "he",
		"hu":    "hu",
		"ja":    "ja",
		"ko":    "ko",
		"nl":    "nl",
		"nn":    "nn-no",
		"pl":    "pl",
		"si":    "sl",
		"sv":    "sv-se",
		"tr":    "tr",
		"zh-cn": "zh-cn",
		"zh-tw": "zh-tw",
	}
)

Functions

func GetDefaultLanguage

func GetDefaultLanguage(conf config.Config) string

GetDefaultLanguage reads default language from config

func UserLanguage

func UserLanguage(ctx context.Context, user *idm.User, conf config.Config) string

UserLanguage looks for the user roles and check if a language parameter is set (starting from the last). Otherwise returns the default language from config

func UserLanguageFromContext

func UserLanguageFromContext(ctx context.Context, conf config.Config, returnDefault bool) string

UserLanguageFromContext tries to find Claims in context and get the language for the corresponding user. If nothing is found, if returnDefault is true it returns the global default language, otherwise it returns an empty string.

func UserLanguagesFromRestRequest

func UserLanguagesFromRestRequest(req *restful.Request, conf config.Config) []string

UserLanguagesFromRestRequest tries to find user language from various sources: X-Pydio-Language header, user language inside the system (set via roles), or Accept-Language standard header.

Types

type I18nBundle

type I18nBundle struct {
	bundle.Bundle
}

func NewI18nBundle

func NewI18nBundle(box packr.Box) *I18nBundle

func (*I18nBundle) GetTranslationFunc

func (b *I18nBundle) GetTranslationFunc(languages ...string) i18n.TranslateFunc

GetTranslationFunc provides the correct translation func for language or the IdentityFunc if language is not supported. Languages can be a list of weighted languages as provided in the http header Accept-Language

func (*I18nBundle) LoadPackrTranslationFiles

func (b *I18nBundle) LoadPackrTranslationFiles(box packr.Box)

LoadPackrTranslationFiles loads goi18n translation files from packr boxes

Jump to

Keyboard shortcuts

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