-
Notifications
You must be signed in to change notification settings - Fork 8
New and Unified Translation System #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…a-typst-templates into new_translation_model
…a-typst-templates into new_translation_model
|
The Toml is structured weirdly imo, would it not be better to have the toml structured like: # translations
[en]
date = "date"
pointsingle = "point"
pointplural = "points"
# ...
[de]
date = "Datum"
pointsingle = "Punkt"
pointplural = "Punkte"This way it would be easier to add a new language (and producing cleaner diffs). And you wouldn't have to specify an array of available languages. Then we could also make en the default, and always fallback to that, if no translation for one word in a language is given |
|
@St0rml I think this is a good idea, but I support @Rdeisenroth argument that the toml structure could be improved (@Rdeisenroth proposed structure would be a good fit for this). |
This PR introduces a new and unified translation. The system utilizes
.tomlfiles which are defined per template and contain all strings which need to be translated. Thecommon/lang.typprovides the heart of this translation system: The functionThis function retrieves the relevant string from the
.tomlfile and returns the value in the correct language based on the text context. While this is not ideal for overhead, it is quite simple and intuitive in my opinion.The
.tomlfiles are structured like so:check-localeoflang.typ, which should be called after a template is instantiated to check whether the user-given language is supported by the ´translations.toml´ file of this template[translations]holds all translations identified bykey.language-code. By design of TOML, no duplicated keys can be created here, preventing mistakes for longer tables.This branch is based on #21