1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

add LoadKV method on Iris.Application.I18N instance

This commit is contained in:
Gerasimos (Makis) Maropoulos
2023-03-18 15:43:18 +02:00
parent 41326d4ddd
commit 0954986a66
9 changed files with 108 additions and 11 deletions

View File

@@ -4,7 +4,7 @@ User = Λογαριασμός
[debug]
Title = Μενού προγραμματιστή
AccessLog = Πρόσβαση στο αρχείο καταγραφής
AccessLogClear = Καθαρισμός {{tr "debug.AccessLog"}}
AccessLogClear = Καθαρισμός {{ tr "debug.AccessLog" }}
[user.connections]
Title = {{tr "nav.User"}} Συνδέσεις
Title = {{ tr "nav.User" }} Συνδέσεις

View File

@@ -1,4 +1,4 @@
[forms]
member = μέλος
register = Γίνε {{uppercase (tr "forms.member") }}
register = Γίνε {{ uppercase (tr "forms.member") }}
registered = εγγεγραμμένοι

View File

@@ -6,7 +6,7 @@ User = Account
[debug]
Title = Developer Menu
AccessLog = Access Log
AccessLogClear = Clear {{tr "debug.AccessLog"}}
AccessLogClear = Clear {{ tr "debug.AccessLog" }}
[user.connections]
Title = {{tr "nav.User"}} Connections
Title = {{ tr "nav.User" }} Connections

View File

@@ -1,4 +1,4 @@
[forms]
member = member
register = Become a {{uppercase (tr "forms.member") }}
register = Become a {{ uppercase (tr "forms.member") }}
registered = registered

View File

@@ -13,6 +13,16 @@ var embeddedFS embed.FS
func main() {
app := newApp()
// http://localhost:8080
// http://localhost:8080?lang=el
// http://localhost:8080?lang=el
// http://localhost:8080?lang=el-GR
// http://localhost:8080?lang=en
// http://localhost:8080?lang=en-US
//
// http://localhost:8080/title
// http://localhost:8080/title?lang=el-GR
// ...
app.Listen(":8080")
}
@@ -30,11 +40,14 @@ func newApp() *iris.Application {
// Instead of:
// err := app.I18n.Load("./locales/*/*.ini", "en-US", "el-GR")
// Apply the below in order to build with embedded locales inside your executable binary.
// apply the below in order to build with embedded locales inside your executable binary.
err := app.I18n.LoadFS(embeddedFS, "./embedded/locales/*/*.ini", "en-US", "el-GR")
if err != nil {
panic(err)
}
} // OR to load all languages by filename:
// app.I18n.LoadFS(embeddedFS, "./embedded/locales/*/*.ini")
// Then set the default language using:
// app.I18n.SetDefault("en-US")
app.Get("/", func(ctx iris.Context) {
text := ctx.Tr("forms.register") // en-US: prints "Become a MEMBER".