Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to English if there is no sensible match #5043

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func init() {
bundle = i18n.NewBundle(language.English)
bundle.RegisterUnmarshalFunc("json", json.Unmarshal)

translated = []language.Tag{language.Make("en")} // the first item in this list will be the fallback if none match
dweymouth marked this conversation as resolved.
Show resolved Hide resolved
err := AddTranslationsFS(translations, "translations")
if err != nil {
fyne.LogError("Error occurred loading built-in translations", err)
Expand Down
5 changes: 5 additions & 0 deletions lang/lang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func TestAddTranslations(t *testing.T) {
assert.Equal(t, "Match2", L("Test2"))
}

func TestLocalize_Default(t *testing.T) {
dweymouth marked this conversation as resolved.
Show resolved Hide resolved
fallback := closestSupportedLocale([]string{"xx"})
assert.Equal(t, fyne.Locale("en"), fallback[0:2])
}

func TestLocalize_Fallback(t *testing.T) {
assert.Equal(t, "Missing", L("Missing"))
}
Expand Down
31 changes: 31 additions & 0 deletions lang/translations/base.de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Create Folder": "Erstelle Ordner",
"Advanced": "Erweitert",
"Confirm": "Bestätigen",
"Copy": "Kopieren",
"Enter filename": "Dateinamen eingeben",
"Error": "Fehler",
"File": "Datei",
"Folder": "Ordner",
"New Folder": "Neuer Ordner",
"No": "Nein",
"Quit": "Beenden",
"Redo": "Wiederholen",
"Save": "Speichern",
"Select all": "Alle auswählen",
"Show Hidden Files": "Versteckte Dateien anzeigen",
"Undo": "Rückgängig",
"Yes": "Ja",
"file.name": {
"other": "Name"
},
"file.parent": {
"other": "Übergeordneter Ordner"
},
"Cancel": "Abbrechen",
"Favourites": "Favoriten",
"Open": "Öffnen",
"Paste": "Einfügen",
"Cut": "Ausschneiden",
"OK": "OK"
}