Move translations to frontend
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
b51293fe3d
commit
e4097a42af
6 changed files with 39 additions and 128 deletions
|
@ -1,44 +0,0 @@
|
||||||
{
|
|
||||||
"alert-secret-not-found": {
|
|
||||||
"other": "Das ist nicht das Secret, was du suchst\u0026hellip; - Falls du diesen Link noch nicht selbst geöffnet hast, könnte das Secret kompromittiert sein, da jemand anderes den Link geöffnet haben könnte."
|
|
||||||
},
|
|
||||||
"alert-something-went-wrong": {
|
|
||||||
"other": "Irgendwas ging schief. Entschuldigung\u0026hellip;"
|
|
||||||
},
|
|
||||||
"btn-create-secret": {
|
|
||||||
"other": "Secret erstellen!"
|
|
||||||
},
|
|
||||||
"btn-new-secret": {
|
|
||||||
"other": "Neues Secret"
|
|
||||||
},
|
|
||||||
"btn-reveal-secret": {
|
|
||||||
"other": "Zeig mir das Secret!"
|
|
||||||
},
|
|
||||||
"label-secret-data": {
|
|
||||||
"other": "Inhalt des Secrets:"
|
|
||||||
},
|
|
||||||
"text-burn-hint": {
|
|
||||||
"other": "Bitte rufe die URL nicht selbst auf, da das Secret dadurch zerstört würde. Gib sie einfach weiter!"
|
|
||||||
},
|
|
||||||
"text-hint-burned": {
|
|
||||||
"other": "\u003cstrong\u003eAchtung:\u003c/strong\u003e Du kannst das nur einmal ansehen! Sobald du die Seite neu lädst, ist das Secret verschwunden, also besser direkt kopieren und sicher abspeichern\u0026hellip;"
|
|
||||||
},
|
|
||||||
"text-powered-by": {
|
|
||||||
"other": "Läuft mit"
|
|
||||||
},
|
|
||||||
"text-pre-reveal-hint": {
|
|
||||||
"other": "Um das Secret anzuzeigen klicke diesen Button aber denk dran, dass das Secret nur einmal angezeigt und dabei gelöscht wird."
|
|
||||||
},
|
|
||||||
"text-pre-url": {
|
|
||||||
"other": "Dein Secret wurde angelegt und unter folgender URL gespeichert:"
|
|
||||||
},
|
|
||||||
"title-new-secret": {
|
|
||||||
"other": "Erstelle ein neues Secret"
|
|
||||||
},
|
|
||||||
"title-reading-secret": {
|
|
||||||
"other": "Secret auslesen\u0026hellip;"
|
|
||||||
},
|
|
||||||
"title-secret-created": {
|
|
||||||
"other": "Secret erstellt!"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
{
|
|
||||||
"alert-secret-not-found": {
|
|
||||||
"other": "This is not the secret you are looking for\u0026hellip; - If you expected the secret to be here it might be comprimised as someone else might have opened the link already."
|
|
||||||
},
|
|
||||||
"alert-something-went-wrong": {
|
|
||||||
"other": "Something went wrong. I'm very sorry about this\u0026hellip;"
|
|
||||||
},
|
|
||||||
"btn-create-secret": {
|
|
||||||
"other": "Create the secret!"
|
|
||||||
},
|
|
||||||
"btn-new-secret": {
|
|
||||||
"other": "New Secret"
|
|
||||||
},
|
|
||||||
"btn-reveal-secret": {
|
|
||||||
"other": "Show me the secret!"
|
|
||||||
},
|
|
||||||
"label-secret-data": {
|
|
||||||
"other": "Secret data:"
|
|
||||||
},
|
|
||||||
"text-burn-hint": {
|
|
||||||
"other": "Please remember not to go to this URL yourself as that would destroy the secret. Just pass it to someone else!"
|
|
||||||
},
|
|
||||||
"text-hint-burned": {
|
|
||||||
"other": "\u003cstrong\u003eAttention:\u003c/strong\u003e You're only seeing this once. As soon as you reload the page the secret will be gone so maybe copy it now\u0026hellip;"
|
|
||||||
},
|
|
||||||
"text-powered-by": {
|
|
||||||
"other": "Powered by"
|
|
||||||
},
|
|
||||||
"text-pre-reveal-hint": {
|
|
||||||
"other": "To reveal the secret click this button but be aware doing so will destroy the secret. You can only view it once!"
|
|
||||||
},
|
|
||||||
"text-pre-url": {
|
|
||||||
"other": "Your secret was created and stored using this URL:"
|
|
||||||
},
|
|
||||||
"title-new-secret": {
|
|
||||||
"other": "Create a new secret"
|
|
||||||
},
|
|
||||||
"title-reading-secret": {
|
|
||||||
"other": "Reading your secret\u0026hellip;"
|
|
||||||
},
|
|
||||||
"title-secret-created": {
|
|
||||||
"other": "Secret created!"
|
|
||||||
}
|
|
||||||
}
|
|
16
src/langs/de.json
Normal file
16
src/langs/de.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"alert-secret-not-found": "Das ist nicht das Secret, was du suchst… - Falls du diesen Link noch nicht selbst geöffnet hast, könnte das Secret kompromittiert sein, da jemand anderes den Link geöffnet haben könnte.",
|
||||||
|
"alert-something-went-wrong": "Irgendwas ging schief. Entschuldigung…",
|
||||||
|
"btn-create-secret": "Secret erstellen!",
|
||||||
|
"btn-new-secret": "Neues Secret",
|
||||||
|
"btn-reveal-secret": "Zeig mir das Secret!",
|
||||||
|
"label-secret-data": "Inhalt des Secrets:",
|
||||||
|
"text-burn-hint": "Bitte rufe die URL nicht selbst auf, da das Secret dadurch zerstört würde. Gib sie einfach weiter!",
|
||||||
|
"text-hint-burned": "<strong>Achtung:</strong> Du kannst das nur einmal ansehen! Sobald du die Seite neu lädst, ist das Secret verschwunden, also besser direkt kopieren und sicher abspeichern…",
|
||||||
|
"text-powered-by": "Läuft mit",
|
||||||
|
"text-pre-reveal-hint": "Um das Secret anzuzeigen klicke diesen Button aber denk dran, dass das Secret nur einmal angezeigt und dabei gelöscht wird.",
|
||||||
|
"text-pre-url": "Dein Secret wurde angelegt und unter folgender URL gespeichert:",
|
||||||
|
"title-new-secret": "Erstelle ein neues Secret",
|
||||||
|
"title-reading-secret": "Secret auslesen…",
|
||||||
|
"title-secret-created": "Secret erstellt!"
|
||||||
|
}
|
16
src/langs/en.json
Normal file
16
src/langs/en.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"alert-secret-not-found": "This is not the secret you are looking for… - If you expected the secret to be here it might be comprimised as someone else might have opened the link already.",
|
||||||
|
"alert-something-went-wrong": "Something went wrong. I'm very sorry about this…",
|
||||||
|
"btn-create-secret": "Create the secret!",
|
||||||
|
"btn-new-secret": "New Secret",
|
||||||
|
"btn-reveal-secret": "Show me the secret!",
|
||||||
|
"label-secret-data": "Secret data:",
|
||||||
|
"text-burn-hint": "Please remember not to go to this URL yourself as that would destroy the secret. Just pass it to someone else!",
|
||||||
|
"text-hint-burned": "<strong>Attention:</strong> You're only seeing this once. As soon as you reload the page the secret will be gone so maybe copy it now…",
|
||||||
|
"text-powered-by": "Powered by",
|
||||||
|
"text-pre-reveal-hint": "To reveal the secret click this button but be aware doing so will destroy the secret. You can only view it once!",
|
||||||
|
"text-pre-url": "Your secret was created and stored using this URL:",
|
||||||
|
"title-new-secret": "Create a new secret",
|
||||||
|
"title-reading-secret": "Reading your secret…",
|
||||||
|
"title-secret-created": "Secret created!"
|
||||||
|
}
|
7
src/langs/langs.js
Normal file
7
src/langs/langs.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import lang_de from './de.json'
|
||||||
|
import lang_en from './en.json'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
de: lang_de,
|
||||||
|
en:lang_en,
|
||||||
|
}
|
|
@ -1,40 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/nicksnyder/go-i18n/i18n"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
for _, filename := range AssetNames() {
|
|
||||||
if !strings.HasPrefix(filename, "frontend/locale") || !strings.HasSuffix(filename, ".all.json") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
translationData, _ := Asset(filename)
|
|
||||||
if err := i18n.ParseTranslationFileBytes(filename, translationData); err != nil {
|
|
||||||
log.Fatalf("Unable to load translation data %q: %s", filename, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func addTranslateFunc(t template.FuncMap, r *http.Request) template.FuncMap {
|
|
||||||
cookie, _ := r.Cookie("lang")
|
|
||||||
|
|
||||||
cookieLang := ""
|
|
||||||
if cookie != nil {
|
|
||||||
cookieLang = cookie.Value
|
|
||||||
}
|
|
||||||
qpLang := r.URL.Query().Get("hl")
|
|
||||||
acceptLang := r.Header.Get("Accept-Language")
|
|
||||||
defaultLang := "en-US" // known valid language
|
|
||||||
|
|
||||||
T, _ := i18n.Tfunc(cookieLang, qpLang, acceptLang, defaultLang)
|
|
||||||
|
|
||||||
t["T"] = T
|
|
||||||
return t
|
|
||||||
}
|
|
Loading…
Reference in a new issue