mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
Added constants for supported language codes
This commit is contained in:
parent
e12372e28c
commit
9869f89018
1 changed files with 35 additions and 19 deletions
|
|
@ -14,6 +14,22 @@ type Localizer struct {
|
||||||
S TranslationSet
|
S TranslationSet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ISO 639-1 supported language codes.
|
||||||
|
const (
|
||||||
|
// Polish
|
||||||
|
PL = "pl"
|
||||||
|
// Dutch
|
||||||
|
NL = "nl"
|
||||||
|
// German
|
||||||
|
DE = "de"
|
||||||
|
// Turkish
|
||||||
|
TR = "tr"
|
||||||
|
// English
|
||||||
|
EN = "en"
|
||||||
|
// French
|
||||||
|
FR = "fr"
|
||||||
|
)
|
||||||
|
|
||||||
func NewTranslationSetFromConfig(log *logrus.Entry, configLanguage string) (*TranslationSet, error) {
|
func NewTranslationSetFromConfig(log *logrus.Entry, configLanguage string) (*TranslationSet, error) {
|
||||||
if configLanguage == "auto" {
|
if configLanguage == "auto" {
|
||||||
language := detectLanguage(jibber_jabber.DetectLanguage)
|
language := detectLanguage(jibber_jabber.DetectLanguage)
|
||||||
|
|
@ -25,7 +41,7 @@ func NewTranslationSetFromConfig(log *logrus.Entry, configLanguage string) (*Tra
|
||||||
return NewTranslationSet(log, configLanguage), nil
|
return NewTranslationSet(log, configLanguage), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewTranslationSet(log, "en"), errors.New("Language not found: " + configLanguage)
|
return NewTranslationSet(log, EN), errors.New("Language not found: " + configLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTranslationSet(log *logrus.Entry, language string) *TranslationSet {
|
func NewTranslationSet(log *logrus.Entry, language string) *TranslationSet {
|
||||||
|
|
@ -42,12 +58,12 @@ func NewTranslationSet(log *logrus.Entry, language string) *TranslationSet {
|
||||||
// GetTranslationSets gets all the translation sets, keyed by language code
|
// GetTranslationSets gets all the translation sets, keyed by language code
|
||||||
func GetTranslationSets() map[string]TranslationSet {
|
func GetTranslationSets() map[string]TranslationSet {
|
||||||
return map[string]TranslationSet{
|
return map[string]TranslationSet{
|
||||||
"pl": polishSet(),
|
PL: polishSet(),
|
||||||
"nl": dutchSet(),
|
NL: dutchSet(),
|
||||||
"de": germanSet(),
|
DE: germanSet(),
|
||||||
"tr": turkishSet(),
|
TR: turkishSet(),
|
||||||
"en": englishSet(),
|
EN: englishSet(),
|
||||||
"fr": frenchSet(),
|
FR: frenchSet(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,17 +72,17 @@ func GetTranslationSets() map[string]TranslationSet {
|
||||||
// It returns an english translation set if not found.
|
// It returns an english translation set if not found.
|
||||||
func getTranslationSet(languageCode string) TranslationSet {
|
func getTranslationSet(languageCode string) TranslationSet {
|
||||||
switch languageCode {
|
switch languageCode {
|
||||||
case "pl":
|
case PL:
|
||||||
return polishSet()
|
return polishSet()
|
||||||
case "nl":
|
case NL:
|
||||||
return dutchSet()
|
return dutchSet()
|
||||||
case "de":
|
case DE:
|
||||||
return germanSet()
|
return germanSet()
|
||||||
case "tr":
|
case TR:
|
||||||
return turkishSet()
|
return turkishSet()
|
||||||
case "en":
|
case EN:
|
||||||
return englishSet()
|
return englishSet()
|
||||||
case "fr":
|
case FR:
|
||||||
return frenchSet()
|
return frenchSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,12 +92,12 @@ func getTranslationSet(languageCode string) TranslationSet {
|
||||||
// getSupportedLanguages returns all the supported languages.
|
// getSupportedLanguages returns all the supported languages.
|
||||||
func getSupportedLanguages() []string {
|
func getSupportedLanguages() []string {
|
||||||
return []string{
|
return []string{
|
||||||
"pl",
|
PL,
|
||||||
"nl",
|
NL,
|
||||||
"de",
|
DE,
|
||||||
"tr",
|
TR,
|
||||||
"en",
|
EN,
|
||||||
"fr",
|
FR,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue