Replies: 3 comments 3 replies
-
I will look into this more soon and hopefully resolve #9. |
Beta Was this translation helpful? Give feedback.
-
I can try to make a PR, but this idea changes too much, I don't know if it will break compatibility, because this logic is like this: all core source code uses strings to call the functions in the i18n package, and then we use the AST package of the go standard library to parse all the calls in the syntax tree containing the methods in the i18n package before any app initialization and save them to a map, the key value pair of the map is a translated copy of multiple Chinese, when we complete the translation, Before the main function is called, load our translated map file into memory, at this time, all GO code calls i18n will query the map key-value pair in the language file we specified in the main function, and each call will return the MAP key:English corresponding value: the text we translated. https://github.com/richardwilkes/gcs/blob/master/ux/about.go#L57-L58 |
Beta Was this translation helpful? Give feedback.
-
I did this before and did it this way. Flow:
Step 1 is treated like a cache , so the whole process is idempotent and if the hash of the text is the same then you use whats already there. This also avoids the merge problem. Step 2 is required because of mistakes but also layout in a GUI and also per locale differences that always crop up. Also machine make screwups and you can do an overide back into the file format. When running any App, these can all be changed at runtime. Should be so that you can see where the translation came from and then override it if need. This is why Providence and Overrides become so important in the data format used. Packing. This is tricky. It's common for apps to get bigger and bigger and the translations files can get huge too. So some like to keep the translation pace external and some dont. This is why you kind of end up with I18n CMS. Self similar extension. Because Text is very often reused between not just apps but Orgs, you end up wanting a way to have the thing be a server of sorts. A CLI can obviously also run and expose a simple HTTP API for this later. Storage in git is referred. Some orgs use a mono repo, some use a single repo for all their translations. This is also where Overrides comes in again, because you can then do overrides in each App without touching the Org main repos / ontology. Images are also often per locale too. So you can use the exact same architecture for images too, and so then override per locale. This is where git LFS is great so you can just store all the text and images in a repo, mono repo, take your pick. Locale overrides. At runtime, it's also good like @ddkwork said, to allow users to override what locale is used. Makes UAT testing way way easier too. By the end of it you kind of end up with a CMS that is git LFS based. With a simple bleve indexer and searcher that watches file mutations you can have simple search too. This is useful for the Orgs and Apps concept. The main thing is there its all self similar. |
Beta Was this translation helpful? Give feedback.
-
use this for support i18n
https://github.com/richardwilkes/toolbox/blob/master/i18n/i18n/main.go
Beta Was this translation helpful? Give feedback.
All reactions