l10n

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: MIT Imports: 6 Imported by: 0

README

fork for library

Changes:

  • upgrade for work with gorm v2
  • change stratagy for update sync column
  • add interface for sync languages of all models in database

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Global = "en-US"

Global global language

Functions

func IsLocalizable

func IsLocalizable(db *gorm.DB) (IsLocalizable bool)

IsLocalizable return model is localizable or not

func RegisterCallbacks

func RegisterCallbacks(db *gorm.DB)

RegisterCallbacks register callback into GORM DB

Types

type Locale

type Locale struct {
	LanguageCode string `sql:"size:20" gorm:"primary_key"`
}

Locale embed this struct into GROM-backend models to enable localization feature for your model

func (Locale) IsGlobal

func (l Locale) IsGlobal() bool

IsGlobal return if current locale is global

func (*Locale) SetLocale

func (l *Locale) SetLocale(locale string)

SetLocale set model's locale

type LocaleCodes

type LocaleCodes struct {
	LanguageAvailableCode pq.StringArray `gorm:"type:varchar(64)[]" json:"LanguageAvailableCode" l10n:"sync"`
}

type LocaleCreatable

type LocaleCreatable struct {
	Locale
}

LocaleCreatable if you embed it into your model, it will make the resource be creatable from locales, by default, you can only create it from global

func (LocaleCreatable) CreatableFromLocale

func (LocaleCreatable) CreatableFromLocale()

CreatableFromLocale a method to allow your mod=el be creatable from locales

type LocalizeActionArgument

type LocalizeActionArgument struct {
	From string
	To   []string
}

LocalizeActionArgument localize action's argument

Jump to

Keyboard shortcuts

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