Closed taophp closed 5 months ago
@infogulch any thoughts about this?
I agree that i18n is important and useful.
I doubt the utility of building in an imposed file structure specifically for translated documents. The described document selection design can be implemented entirely within the template language, and in fact this is how I envisioned xtemplate being used. Templates already have access to headers, cookies, parameters, etc, and can perform complex conditionals and control flow in order to select and render the appropriate document for a particular request. Perhaps a demo or example that shows how to use xtemplate to select different versions of documents would be a good fit for this repo.
As for string translation, I could see a custom dot provider that loads and can lookup translated strings from one or more of the mentioned file formats. Then configure it to use a field name like "T" and use it like {{ .T.Tr "Sign up now for a discount!" }}
.
Even if I don't think this should be built into xtemplate, your translated document design is a pretty good starting point. If you're building something like this on xtemplate and have some issue or you'd like some input, I'd be happy to help.
@infogulch Thanks. I'll let you know.
Currently, I see no easy, obvious way to handle T10N within xtemplate. And I don't think any ambitious web site or app should avoid this nowadays. So I'm sharing my thoughts about it below. Please, let me know what you think.
A default directory structure like this one below should be proposed, actionable with a simple configuration: The default translated directory tree:
And then, a simple configuration with T10N should be
_
ort_
), that handles string with arguments ; translated strings should be stored in files, something compatible with Weblate, maybe go-i18n JSON files or gotext JSON files; T10N files should live in a default directory, maybe configurable;