kataras / i18n Goto Github PK
View Code? Open in Web Editor NEW:new: High-performant and powerful localization and internationalization support for Go
Home Page: https://en.wikipedia.org/wiki/Website_localization
License: MIT License
:new: High-performant and powerful localization and internationalization support for Go
Home Page: https://en.wikipedia.org/wiki/Website_localization
License: MIT License
Describe the bug
a:
b:
- 1
- 2
Tr("en","a") -> ""
expect
b:
- 1
- 2
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
Describe the bug
(*I18n) Tr()
is not consistent when producing translated templates. It seems the index of selecting/searching the language is not correct. I use custom language tags e.g. ka-KE
(Kamba language).
To Reproduce
Steps to reproduce the behavior:
https://goplay.tools/snippet/55lBTIz199v
Running it multiple times shows that it randomly displays either fr-FR
or ka-KE
.
Expected behavior
Should only display ka-KE
consistently.
Screenshots
N/A
Desktop (please complete the following information):
It would be nice to upgrade dependencies of the project, because I think it is starting to pull some old versions of other packages.
Example of upgraded code is in my fork commit: 080c239
Describe the bug
When using i18n.SetDefaultLanguage("en-US") in the init() function, an error is threw at runtime:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x8d204e]
goroutine 1 [running]:
github.com/kataras/i18n.(*I18n).SetDefault(0x0, {0xa9b1d5?, 0x587?})
/home/titi/go/pkg/mod/github.com/kataras/[email protected]/i18n.go:173 +0x4e
github.com/kataras/i18n.SetDefaultLanguage(...)
/home/titi/go/pkg/mod/github.com/kataras/[email protected]/i18n.go:43
main.init.0()
/home/titi/Dev/api/telegram/friendly-brocolli/main.go:44 +0xa6
exit status 2
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Shouldn't throw an error but continue the code
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
Describe the bug
I'm trying a basic implementation using english and spanish translations files but when trying to do this:
func main() {
enText := i18n.Tr("en", "textWithLink", "A123456")
fmt.Println(enText)
}
and in my locales/en-US I have my example json like:
{ "textWithLink": "Lorem ipsum [This is my link](https://domain.example.com/form/%s/create)" }
Then I'm getting on my result translation: Lorem ipsum [This is my link](https://domain.example.com/form/[A123456]/create)
string passed as parameter is printing between [ ]
Why is happening this?
Describe the bug
Automatic language detection recently got broken in my project.
To Reproduce
Steps to reproduce the behavior:
Accept-Language: en-GB,en;q=0.5
ga
Expected behavior
Since both en-GB and en are supplied, and en is available as a folder (and not missing any translations), en should be chosen in my eyes.
ga
is missing some strings, so English is used for them instead.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
locales/
locales/nl
locales/nl/base.yaml
locales/da
locales/da/base.yaml
locales/en
locales/en/other-component.yaml
locales/en/base.yaml
locales/ga
locales/ga/base.yaml
locales/pl
locales/pl/base.yaml
locales/fr
locales/fr/base.yaml
locales/de
locales/de/other-component.yaml
locales/de/base.yaml
locale := i18n.GetLocale(r)
templateData["tr"] = locale.GetMessage
ga
is default, unless de
is chosen.It works in another browser where I send Accept-Language: de,en-US;q=0.7,en;q=0.3
(de
is chosen / displayed).
Appreciate your help :) Thank you!
Thanks for this great library, I put together an example of how to use it with Go 1.16 embed.FS:
package locales
import (
"embed"
)
//go:embed */*.yml
var translations embed.FS
func I18n() (*i18n.I18n, error) {
// assuming embedded files at ./en/*.yml
return i18n.New(i18n.Assets(translationNames, translations.ReadFile), "en")
}
func translationNames() (filenames []string) {
fs.WalkDir(translations, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
filenames = append(filenames, path)
return nil
})
return filenames
}
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
iris v12.1.8
go 1.14.2
locales not found in /opt/etc/rcacs/locales/en-US.ini
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.