Stream: t-compiler/wg-diagnostics

Topic: translation


simulacrum (Jan 30 2020 at 23:25, on Zulip):

is that plan concrete implementation wise though? My impression is that we have broad strokes (e.g., maybe even what platform to use) but not the details.

Manish Goregaokar (Jan 30 2020 at 23:26, on Zulip):

Once we have diagnostics structs as listed in the issue then it should be easy ish to add i18n based on various json files or something that key off of the text error code or something

Manish Goregaokar (Jan 30 2020 at 23:26, on Zulip):

This assumes there's a human-understandable "error code" like object-safety-generics that we can key off of but if we decide against codes then we can still use this internally

simulacrum (Jan 30 2020 at 23:27, on Zulip):

(split off into new topic)

Manish Goregaokar (Jan 30 2020 at 23:27, on Zulip):

@simulacrum there are some open questions but in this case I think it's _mostly_ clear implementation wise what we can do

Manish Goregaokar (Jan 30 2020 at 23:27, on Zulip):

We don't even necessarily need to pull in Fluent

simulacrum (Jan 30 2020 at 23:28, on Zulip):

@Manish Goregaokar hm, okay

simulacrum (Jan 30 2020 at 23:28, on Zulip):

that's farther than I thought we were

Manish Goregaokar (Jan 30 2020 at 23:29, on Zulip):

Error i18n is blocked on y'all implementing the diagnostics derive

Manish Goregaokar (Jan 30 2020 at 23:29, on Zulip):

error index i18n isn't blocked on anything someone just needs to do it, also it would make sense to hold off until after we figure out error codes

Manish Goregaokar (Jan 30 2020 at 23:30, on Zulip):

@simulacrum note that this is only a plan, no implementation

Manish Goregaokar (Jan 30 2020 at 23:30, on Zulip):

But please loop me in on PRs implementing the diagnostics derive so I can ensure it's compatible with this

Manish Goregaokar (Jan 30 2020 at 23:30, on Zulip):

I was going to do it myself but I keep not having time lol

simulacrum (Jan 30 2020 at 23:31, on Zulip):

yeah, this also all sounds mostly compatible

simulacrum (Jan 30 2020 at 23:32, on Zulip):

I continue to be skeptical about the "many files on disk", but of course the final artifacts can bundle things up if needed

centril (Jan 30 2020 at 23:33, on Zulip):

@Manish Goregaokar did you have thoughts re. translation of error descriptions though? (i.e. the .md files we have today)

centril (Jan 30 2020 at 23:33, on Zulip):

these: https://github.com/rust-lang/rust/tree/master/src/librustc_error_codes/error_codes

Manish Goregaokar (Jan 30 2020 at 23:35, on Zulip):

As long as there's something to key off of this is quite easy.

Manish Goregaokar (Jan 30 2020 at 23:36, on Zulip):

Again, some open questions.

centril (Jan 30 2020 at 23:36, on Zulip):

it's basically just a string code that is linked up via a rustc_driver hashmap to descriptions

centril (Jan 30 2020 at 23:36, on Zulip):

it's very isolated

centril (Jan 30 2020 at 23:37, on Zulip):

but I was wondering re. the linking aspect; e.g. how do we store the translations and how does rustc load them?

centril (Jan 30 2020 at 23:38, on Zulip):

https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/registry/struct.Registry.html

Manish Goregaokar (Jan 30 2020 at 23:40, on Zulip):

@centril rustup component, basically json files or something. which specific format depends on what works with Pontoon and what can support the detail we need. I think for error codes the json format is fine.

Manish Goregaokar (Jan 30 2020 at 23:41, on Zulip):

Could also bake it in, but at least to start with a rustup component makes sense to me

Manish Goregaokar (Jan 30 2020 at 23:41, on Zulip):

For diagnostics we may need to use a format a bit more powerful than json

Manish Goregaokar (Jan 30 2020 at 23:41, on Zulip):

Maybe.

Manish Goregaokar (Jan 30 2020 at 23:41, on Zulip):

Either way these files are never hand generated

Manish Goregaokar (Jan 30 2020 at 23:41, on Zulip):

Er, handwritten

Manish Goregaokar (Jan 30 2020 at 23:42, on Zulip):

Or read by humans.

centril (Jan 30 2020 at 23:42, on Zulip):

Error descriptions are basically just a long string, so it requires nothing technically complicated beyond that I think

simulacrum (Jan 30 2020 at 23:42, on Zulip):

I continue to think the linking aspect is not too interesting :)

simulacrum (Jan 30 2020 at 23:42, on Zulip):

like, we can definitely do it

simulacrum (Jan 30 2020 at 23:42, on Zulip):

I personally favor the existing solution as being just fine

centril (Jan 30 2020 at 23:42, on Zulip):

I agree in the sense that it's not complicated

centril (Jan 30 2020 at 23:43, on Zulip):

@Manish Goregaokar I suspect the error descriptions are the most readily translatable asset we have

centril (Jan 30 2020 at 23:43, on Zulip):

since it's so simple

Manish Goregaokar (Jan 30 2020 at 23:43, on Zulip):

Yes those are the easiest

centril (Jan 30 2020 at 23:43, on Zulip):

basically you need to swap out a string for another string

Manish Goregaokar (Jan 30 2020 at 23:43, on Zulip):

I actually started doing them at one point lol and then left it

Manish Goregaokar (Jan 30 2020 at 23:44, on Zulip):

It's not hard tbh

Manish Goregaokar (Jan 30 2020 at 23:44, on Zulip):

Like if you want me to jot down a full plan in an issue I can

centril (Jan 30 2020 at 23:44, on Zulip):

yea; if we setup some infra I bet people will come and do it

Manish Goregaokar (Jan 30 2020 at 23:44, on Zulip):

there's a bunch of initial work that needs to be done

centril (Jan 30 2020 at 23:45, on Zulip):

@Manish Goregaokar in rustup?

Manish Goregaokar (Jan 30 2020 at 23:45, on Zulip):

Okay one question: presumably y'all still want to write these as MD files yes? So we should be generating the English json files via some step which Pontoon can then consume

Manish Goregaokar (Jan 30 2020 at 23:45, on Zulip):

@centril also in rustc so it knows how to load these etc

Manish Goregaokar (Jan 30 2020 at 23:46, on Zulip):

For all of this there are two options: forcing rustc users to write things in the json/whatever format, or using what we use today and having an autogenrtation step

centril (Jan 30 2020 at 23:46, on Zulip):

MD files is a pretty new (but nice!) thing -- they used to be hard-coded strings in the errors.rs files

Manish Goregaokar (Jan 30 2020 at 23:46, on Zulip):

Both work, it's up to y'all

Manish Goregaokar (Jan 30 2020 at 23:46, on Zulip):

I know! I wrote half of them :)

centril (Jan 30 2020 at 23:46, on Zulip):

:D

centril (Jan 30 2020 at 23:47, on Zulip):

also in rustc so it knows how to load these etc

@Manish Goregaokar could we start with a dumb -Z flag perhaps?

centril (Jan 30 2020 at 23:47, on Zulip):

and no rustup support initially

Manish Goregaokar (Jan 30 2020 at 23:47, on Zulip):

Yes

Manish Goregaokar (Jan 30 2020 at 23:47, on Zulip):

If y'all want I can file a bunch of concrete issues

Manish Goregaokar (Jan 30 2020 at 23:48, on Zulip):

And a meta issue and a plan or whatever

centril (Jan 30 2020 at 23:48, on Zulip):

sounds helpful :heart:

Manish Goregaokar (Jan 30 2020 at 23:48, on Zulip):

Don't have bandwidth to do this myself but I can watch and help

Manish Goregaokar (Jan 30 2020 at 23:48, on Zulip):

I was mostly waiting for diagnostics derive to happen first

Manish Goregaokar (Jan 30 2020 at 23:49, on Zulip):

For short diagnostics we may not be able to have a sensible generation step and diagnostics writers may need to write text for the diagnostic in a file fwiw

Manish Goregaokar (Jan 30 2020 at 23:50, on Zulip):

But maybe not

centril (Jan 30 2020 at 23:51, on Zulip):

maybe we can hard-code the English strings in the struct to make the diagnostics dev UX less "jumpy"

centril (Jan 30 2020 at 23:51, on Zulip):

also to facilitate the move

Manish Goregaokar (Jan 30 2020 at 23:52, on Zulip):

@centril we can hardcode provided there's a way to extract it in a structured format, which is trickier for structs

Manish Goregaokar (Jan 30 2020 at 23:52, on Zulip):

That said it's possible to just use a basic parse script for this. Annoying

Last update: Feb 25 2020 at 04:15UTC