Fiber with i18n
This is a quick example of how to use nicksnyder/go-i18n package to translate your Fiber application into multiple languages.
Demoβ
- Run Fiber application;
- Open
http://127.0.0.1:3000/?unread=1and see:
Hello Bob
I have 1 unread email.
Bob has 1 unread email.
- Next, go to
http://127.0.0.1:3000/?unread=4and see pluralization of your message:
Hello Bob
I have 4 unread emails.
Bob has 4 unread emails.
- OK. Try translation of other languages, just add
&lang=es(or&lang=ru) query to the URL:
Hola Bob
Tengo 4 correos electrΓ³nicos no leΓdos
Bob tiene 4 correos electrΓ³nicos no leΓdos
Getting Startedβ
go run main.go
Set ENV=development to enable template hot-reload:
ENV=development go run main.go
File Structureβ
i18n/
βββ lang/
β βββ active.en.toml # English translations (default)
β βββ active.es.toml # Spanish translations
β βββ active.ru.toml # Russian translations
βββ templates/
β βββ index.html # HTML template
βββ main.go # Application entry point
βββ go.mod
βββ go.sum