keep localizations in repo

This commit is contained in:
nytpu
2021-05-12 12:51:51 -06:00
parent e1598af3ea
commit 27717cfd39
3 changed files with 152 additions and 2 deletions
+152
View File
@@ -0,0 +1,152 @@
// Code generated by go-localize; DO NOT EDIT.
// This file was generated by robots at
// 2021-05-12 12:51:18.836789452 -0600 MDT m=+0.005105757
package localizations
import (
"bytes"
"fmt"
"strings"
"text/template"
)
var localizations = map[string]string{
"en-US.errors.bad_command": "Unrecognized Command.",
"en-US.errors.bad_content_type": "Unintelligible content type: {{.mime}}",
"en-US.errors.bad_feed": "Cannot interpret {{.meta}} as a feed",
"en-US.errors.core_init": "Error in initialization: {{.error}}",
"en-US.errors.corrupt_json_error": "comitium.json is corrupted: {{.error}}",
"en-US.errors.gem_bad_response": "Unexpected Gemini response {{.code}} {{.meta}}",
"en-US.errors.gopher_no_extract": "Gemini-style feeds served over gopher are currently unsupported.",
"en-US.errors.http_bad_repsonse": "Unexpected HTTP response {{.status}}",
"en-US.errors.http_no_extract": "Extracting feed from HTML pages is currently unsupported.",
"en-US.errors.no_argument": "{{.command}} doesn't take an argument!",
"en-US.errors.no_command": "Please provide a command.",
"en-US.errors.no_data_dir": "Error finding a suitable directory! Falling back to the current working directory. See \"comitium help\" or comitium(1) for more information.",
"en-US.errors.no_url_add": "Please provide a URL to add.",
"en-US.errors.no_url_remove": "Please provide a URL to remove.",
"en-US.errors.read_file_error": "error reading '{{.file}}': {{.error}}",
"en-US.errors.saving": "Error writing '{{.file}}': {{.error}}",
"en-US.errors.unsupported_protocol": "Unsupported protocol '{{.scheme}}'",
"en-US.errors.url_add": "Error adding URL: {{.error}}",
"en-US.errors.url_parse": "Error parsing URL: {{.error}}",
"en-US.errors.version": "comitium v{{.version}}, commit {{.commit}}",
"en-US.files.comitium_footer": "aggregated using comitium v{{.version}}-{{.commit}}",
"en-US.files.feed_default_header": "comitium subscriptions",
"en-US.files.feed_subscriptions_link": "Currently aggregating {{.num}} capsules, gopherholes, and websites.",
"en-US.files.generated_on": "Generated on {{.date}}",
"en-US.files.subscriptions_feeds_subtitle": "Gemini, Atom, RSS, and JSON feeds from all over.",
"en-US.files.subscriptions_feeds_title": "feeds",
"en-US.files.subscriptions_pages_subtitle": "Watching these pages for any changes that occur.",
"en-US.files.subscriptions_pages_title": "pages",
"en-US.files.subscriptions_subscribed_feeds": "subscribed feeds",
"fr-FR.errors.bad_command": "Commande inconue.",
"fr-FR.errors.bad_content_type": "Type de contenu inintelligible: {{.mime}}",
"fr-FR.errors.bad_feed": "{{.meta}} n'est pas un flux reconnu",
"fr-FR.errors.core_init": "Erreur d'initialisation: {{.error}}",
"fr-FR.errors.corrupt_json_error": "comitium.json est corrompu: {{.error}}",
"fr-FR.errors.gem_bad_response": "Réponse Gemini non attendue {{.code}} {{.meta}}",
"fr-FR.errors.gopher_no_extract": "Les flux Gemini publiés via Gopher ne sont actuellement pas pris en charge.",
"fr-FR.errors.http_bad_repsonse": "Réponse HTTP inattendue {{.status}}",
"fr-FR.errors.http_no_extract": "L'extraction du flux à partir de pages HTML n'est actuellement pas prise en charge.",
"fr-FR.errors.no_argument": "{{.command}} ne prend pas d'argument!",
"fr-FR.errors.no_command": "Please provide a command.",
"fr-FR.errors.no_data_dir": "Erreur lors de la recherche d'un répertoire approprié! Revenir au répertoire de travail actuel. Voir \"comitium help\" ou comitium (1) pour plus d'informations",
"fr-FR.errors.no_url_add": "Merci d'indiquer une URL à ajouter.",
"fr-FR.errors.no_url_remove": "Merci d'indiquer une URL à supprimer.",
"fr-FR.errors.read_file_error": "erreur lors de la lecture de '{{.file}}': {{.error}}",
"fr-FR.errors.saving": "erreur lors de l'écriture de '{{.file}}': {{.error}}",
"fr-FR.errors.unsupported_protocol": "Protocol non supporté '{{.scheme}}'",
"fr-FR.errors.url_add": "Erreur lors de l'ajout de l'URL: {{.error}}",
"fr-FR.errors.url_parse": "Erreur lors de l'analyse de l'URL: {{.error}}",
"fr-FR.errors.version": "comitium v{{.version}}, commit {{.commit}}",
"fr-FR.files.comitium_footer": "Agrégé par comitium v{{.version}}-{{.commit}}",
"fr-FR.files.feed_default_header": "Flux abonnés via comitium",
"fr-FR.files.feed_subscriptions_link": "{{.num}} capsules, gopherholes et sites internet sont agrégés.",
"fr-FR.files.generated_on": "Généré le {{.date}}",
"fr-FR.files.subscriptions_feeds_subtitle": "Tous les flux Gemini, Atom, RSS et JSON.",
"fr-FR.files.subscriptions_feeds_title": "flux",
"fr-FR.files.subscriptions_pages_subtitle": "Ces pages sont surveillées pour tout changement.",
"fr-FR.files.subscriptions_pages_title": "pages",
"fr-FR.files.subscriptions_subscribed_feeds": "Abonnements",
}
type Replacements map[string]interface{}
type Localizer struct {
Locale string
FallbackLocale string
Localizations map[string]string
}
func New(locale string, fallbackLocale string) *Localizer {
t := &Localizer{Locale: locale, FallbackLocale: fallbackLocale}
t.Localizations = localizations
return t
}
func (t Localizer) SetLocales(locale, fallback string) Localizer {
t.Locale = locale
t.FallbackLocale = fallback
return t
}
func (t Localizer) SetLocale(locale string) Localizer {
t.Locale = locale
return t
}
func (t Localizer) SetFallbackLocale(fallback string) Localizer {
t.FallbackLocale = fallback
return t
}
func (t Localizer) GetWithLocale(locale, key string, replacements ...*Replacements) string {
str, ok := t.Localizations[t.getLocalizationKey(locale, key)]
if !ok {
str, ok = t.Localizations[t.getLocalizationKey(t.FallbackLocale, key)]
if !ok {
return key
}
}
// If the str doesn't have any substitutions, no need to
// template.Execute.
if strings.Index(str, "}}") == -1 {
return str
}
return t.replace(str, replacements...)
}
func (t Localizer) Get(key string, replacements ...*Replacements) string {
str := t.GetWithLocale(t.Locale, key, replacements...)
return str
}
func (t Localizer) getLocalizationKey(locale string, key string) string {
return fmt.Sprintf("%v.%v", locale, key)
}
func (t Localizer) replace(str string, replacements ...*Replacements) string {
b := &bytes.Buffer{}
tmpl, err := template.New("").Parse(str)
if err != nil {
return str
}
replacementsMerge := Replacements{}
for _, replacement := range replacements {
for k, v := range *replacement {
replacementsMerge[k] = v
}
}
err = template.Must(tmpl, err).Execute(b, replacementsMerge)
if err != nil {
return str
}
buff := b.String()
return buff
}