See also: Translating the stdlib docs
Over the past few weeks I’ve helped integrate Fluent into the codebase for http://www.rust-lang.org (building off of Rui Zhao’s work), and it’s all working now. All the text in the website has been extracted out into Fluent FTL files and various translation teams are using Pontoon to submit translations. The Turkish translation has already been completed, and Korean and French seem to be coming soon!
I’d like to start seriously talking about localizing the compiler (i.e., any output from the compiler), as the next-easiest step.
This has been discussed before, at the time it was rejected due to a lack of bandwidth, but also I don’t think internationalization frameworks in Rust were quite ready at the time. I’ve been helping out the Fluent folks in the Rust design process and they’re sufficiently progressed for 99% of what we’ll need.
The framework itself isn’t hard to integrate, you can see the code for the website here. The basic idea is that you load FTL files for any language you’re interested in, build a “bundle” for each one, and then have your formatter use the bundle to pick the actual strings used.
I’ll post what the syntax could look like in a followup message.
Open questions I’d like people to discuss:
- Overall project organization:
- Do we have the bandwidth to do this at all? I can help integrate Fluent itself, and moving text into Fluent files is a very parallelizeable task. It’s a daunting one for the compiler, but it’s still parallelizeable.
- Are we confident that we can come up with a policy good enough to lead to quality translations? Technical translations are hard. The website has a policy which is decent – each translation must be reviewed by someone else. We probably want something similar. Things that would also help would be to annotate the fluent files with as much context as possible (linking to the error index where possible) and require translators to understand what the error is about first.
- Should we simultaneously start looking at localizing other tools?
- UX issues:
- How is language selection done? Some rust-specific environment variable?
$LC_ALL
? A command line flag that gets set byrustup
(which itself has a config value in.rustup
)?
- How is language selection done? Some rust-specific environment variable?
- Implementation issues:
- Presumably we should lazy load languages as they become needed. The website doesn’t do this (it loads everything up front so there is less of a locking overhead), but presumably the compiler will need this for performance
- It’s possible to have multiple lazy-loaded bundles per language, e.g. there can be one bundle that’s just used for typechecker errors, etc. This just means we won’t hit the costs of loading every single string the compiler uses the first time the compiler needs a string. I don’t know what the performance hit of doing this is, though, so this may be a premature optimization
- Should the FTL files be compiled into the binary, or be in a folder as part of the dist bundle?
- Should we just move error index stuff into a Fluent file and call it a day? There may be a different way to deal with the error index.
- Presumably we should lazy load languages as they become needed. The website doesn’t do this (it loads everything up front so there is less of a locking overhead), but presumably the compiler will need this for performance
I believe that to a large extent this can be run without interfering with compiler work at all, though I’m not sure if I personally have the bandwidth to be the only person running it.
Edit:
See my comment below, the compiler team already hopes to move diagnostics over to “diagnostics structs”. If we use a custom derive or similar macro for it, it becomes really easy to incrementally migrate to Fluent, in a largely-automated way. It shouldn’t be much work at all to convert the system to using translation strings, however moving everything to diagnostics structs will probably still require help
cc @ekuber @sebasmagri @oli-obk @skade @nikomatsakis @GuillaumeGomez