cogentcore / core

A free and open source framework for building powerful, fast, elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the web with a single Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.77k stars 83 forks source link

Add some kind of text language translation facility. #9

Open rcoreilly opened 6 years ago

rcoreilly commented 6 years ago

Qt requires you to wrap all use of string literals in some magic cookie, in Go it would be something like: tr.Tr("Ok") ?

But might be simpler to just have Label directly take responsibility for translating everything it gets, with a "translate" property that gets set to true by default, but can be turned off? All fixed-content gui elements go through Label eventually so probably that makes sense, and is more automatic and clean.

is there any existing Go infrastructure that would be helpful for this?

impl can simply be a big map of maps or something like that. need to deal with asset issues for the translation database, etc #8

rcoreilly commented 4 years ago

This is the standard library for doing this in go: https://godoc.org/golang.org/x/text/message

kkoreilly commented 1 year ago

This should probably be implemented through an automatic translation on Label, as that would be much easier for people and require no significant breaking changes. Some basic automatic translation generator CLI (as a goki translate command) built on Google Translate or something similar with the option to add custom translations for things would be good. This would allow people to generate basic translations and then make things fully correct if they have the resources to do so. A global map of maps (the first with language name keys and the second with the words/phrases used in the code as keys) is probably the easiest way to implement this. The user's preferred language would be stored in gi.Prefs, and it would default to the system language. Translation shouldn't be too difficult to implement a basic version of, so it should be a relatively high priority.