i18n

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: MIT Imports: 17 Imported by: 0

README

I18n

I18n provides internationalization support for your application, it supports different storage solutions (backends) including a SQL database and YAML.

GoDoc

Documentation

https://doc.getqor.com/plugins/i18n.html

License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = "en-US"

Default default locale for i18n

Functions

func RenderInlineEditAssets

func RenderInlineEditAssets(isIncludeJQuery bool, isIncludeExtendAssetLib bool) (template.HTML, error)

RenderInlineEditAssets render inline edit html, it is using: http://vitalets.github.io/x-editable/index.html You could use Bootstrap or JQuery UI by set isIncludeExtendAssetLib to false and load files by yourself

Types

type Backend

type Backend interface {
	LoadTranslations() []*Translation
	SaveTranslation(*Translation) error
	DeleteTranslation(*Translation) error
}

Backend defined methods that needs for translation backend

type I18n

type I18n struct {
	Resource *admin.Resource

	Backends        []Backend
	FallbackLocales map[string][]string
	// contains filtered or unexported fields
}

I18n struct that hold all translations

func New

func New(backends ...Backend) *I18n

New initialize I18n with backends

func (*I18n) AddTranslation

func (i18n *I18n) AddTranslation(translation *Translation) error

AddTranslation add translation

func (*I18n) ConfigureQorResource

func (i18n *I18n) ConfigureQorResource(res resource.Resourcer)

ConfigureQorResource configure qor resource for qor admin

func (*I18n) Default

func (i18n *I18n) Default(value string) admin.I18n

Default default value of translation if key is missing

func (*I18n) DeleteTranslation

func (i18n *I18n) DeleteTranslation(translation *Translation) (err error)

DeleteTranslation delete translation

func (*I18n) Fallbacks

func (i18n *I18n) Fallbacks(locale ...string) admin.I18n

default value of translation if key is missing

func (*I18n) LoadTranslations

func (i18n *I18n) LoadTranslations() map[string]map[string]*Translation

LoadTranslations load translations as map `map[locale]map[key]*Translation`

func (I18n) ResourceName

func (I18n) ResourceName() string

ResourceName change display name in qor admin

func (*I18n) SaveTranslation

func (i18n *I18n) SaveTranslation(translation *Translation) error

SaveTranslation save translation

func (*I18n) Scope

func (i18n *I18n) Scope(scope string) admin.I18n

Scope i18n scope

func (*I18n) SetCacheStore

func (i18n *I18n) SetCacheStore(cacheStore cache.CacheStoreInterface)

SetCacheStore set i18n's cache store

func (*I18n) T

func (i18n *I18n) T(locale, key string, args ...interface{}) template.HTML

T translate with locale, key and arguments

type Translation

type Translation struct {
	Key     string
	Locale  string
	Value   string
	Backend Backend `json:"-"`
}

Translation is a struct for translations, including Translation Key, Locale, Value

Directories

Path Synopsis
backends

Jump to

Keyboard shortcuts

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