phrases

package
v0.0.0-...-553e66b Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

* * Gosora Phrase System * Copyright Azareal 2017 - 2020 *

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPhrase

func AddPhrase()

? - Use runtime reflection for updating phrases? TODO: Implement these

func AddTmplIndexCallback

func AddTmplIndexCallback(h func([][]byte))

func ChangeLanguagePack

func ChangeLanguagePack(name string) (exists bool)

TODO: Use atomics to store the pointer of the current active langpack? nolint

func CurrentLanguagePackName

func CurrentLanguagePackName() (name string)

func DeletePhrase

func DeletePhrase()

func GetAccountPhrase

func GetAccountPhrase(name string) string

func GetAllPermPresets

func GetAllPermPresets() map[string]string

func GetAllSettingPhrases

func GetAllSettingPhrases() map[string]string

func GetErrorPhrase

func GetErrorPhrase(name string) string

TODO: Does comma ok work with multi-dimensional maps?

func GetErrorPhraseBytes

func GetErrorPhraseBytes(name string) []byte

func GetHumanLangPhrase

func GetHumanLangPhrase(name string) (string, bool)

func GetLevelPhrase

func GetLevelPhrase(level int) string

func GetNoticePhrase

func GetNoticePhrase(name string) string

func GetOSPhrase

func GetOSPhrase(name string) (string, bool)

func GetPermPhrase

func GetPermPhrase(name string) string

func GetSettingPhrase

func GetSettingPhrase(name string) string

func GetTitlePhrase

func GetTitlePhrase(name string) string

func GetTitlePhrasef

func GetTitlePhrasef(name string, params ...interface{}) string

func GetTmplPhrase

func GetTmplPhrase(name string) string

func GetTmplPhrasef

func GetTmplPhrasef(name string, params ...interface{}) string

func GetTmplPhrases

func GetTmplPhrases() map[string]string

func GetTmplPhrasesByPrefix

func GetTmplPhrasesByPrefix(prefix string) (phrases map[string]string, ok bool)

func GetTmplPhrasesBytes

func GetTmplPhrasesBytes(tmplID int) [][]byte

func GetUserAgentPhrase

func GetUserAgentPhrase(name string) (string, bool)

func InitPhrases

func InitPhrases(lang string) error

func LoadLangPack

func LoadLangPack(name string) error

TODO: Implement this

func RegisterTmplPhraseNames

func RegisterTmplPhraseNames(phraseNames []string) (tmplID int)

func SaveLangPack

func SaveLangPack(langPack *LanguagePack) error

TODO: Implement this

func TmplIndexCallback

func TmplIndexCallback(tmplID int, phraseSet [][]byte)

func UpdatePhrase

func UpdatePhrase()

Types

type LanguagePack

type LanguagePack struct {
	Name    string
	IsoCode string
	ModTime time.Time

	// Should we use a sync map or a struct for these? It would be nice, if we could keep all the phrases consistent.
	Levels              LevelPhrases
	Perms               map[string]string
	SettingPhrases      map[string]string
	PermPresets         map[string]string
	Accounts            map[string]string // TODO: Apply these phrases in the software proper
	UserAgents          map[string]string
	OperatingSystems    map[string]string
	HumanLanguages      map[string]string
	Errors              map[string]string // Temp stand-in
	ErrorsBytes         map[string][]byte
	NoticePhrases       map[string]string
	PageTitles          map[string]string
	TmplPhrases         map[string]string
	TmplPhrasesPrefixes map[string]map[string]string // [prefix][name]phrase

	TmplIndicesToPhrases [][][]byte // [tmplID][index]phrase
}

! For the sake of thread safety, you must never modify a *LanguagePack directly, but to create a copy of it and overwrite the entry in the sync.Map

func GetCurrentLangPack

func GetCurrentLangPack() *LanguagePack

! Please don't mutate *LanguagePack

func GetLangPack

func GetLangPack() *LanguagePack

func GetLanguagePackByName

func GetLanguagePackByName(name string) (pack *LanguagePack, ok bool)

type LevelPhrases

type LevelPhrases struct {
	Level    string
	LevelMax string // ? Add a max level setting?

	// Override the phrase for individual levels, if the phrases exist
	Levels []string // index = level
}

TODO: We'll be implementing the level phrases in the software proper very very soon!

Jump to

Keyboard shortcuts

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