feat(web): video player i18n#28192
Conversation
There was a problem hiding this comment.
Don't translate non-english languages
There was a problem hiding this comment.
Even when they are copied from the official translations? https://github.com/muxinc/media-chrome/blob/f040fdbf499c7bda140cf3442673a1c69dff02eb/src/js/lang/de.ts
There was a problem hiding this comment.
It's not about the source, it's about merge conflicts with weblate that are annoying to fix. For us it'd be much easier if you could just add them on weblate after this PR is merged
| }); | ||
|
|
||
| addTranslation($lang, { | ||
| ...En, |
There was a problem hiding this comment.
IMO it's better to not fall back to the library's translations at all and just have a type error when upgrading instead. That way I can easily pick up on it when working through renovate PRs and we have a guarantee of being fully translatable
There was a problem hiding this comment.
Done, I have added a few translation strings that I foresee we'll maybe use in the near future (quality selection ones, captions), and deferred the others to upstream via En[{{key}}]. Does that make sense?
re: types, removing a key value pair now results in a type error.
There was a problem hiding this comment.
I didn't realize there were this many. What do you think about having a const defaults: keyof typeof En = ['Some key', 'Some other key'] and then you go ...Object.fromEntries(defaults.map((k) => [k, k])) and spread that into the object?
There was a problem hiding this comment.
I can't make that work with typing unfortunately, all the defaults in defaults are marked not present in the object. If you have a solution, sure that sounds good, but I don'tknow how to :)
There was a problem hiding this comment.
const videoPlayerDefaults = [
'A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.',
'Audio',
] as const satisfies Array<keyof typeof En>;
const foo = Object.fromEntries(videoPlayerDefaults.map((key) => [key, key])) as {
[K in (typeof videoPlayerDefaults)[number]]: K;
};as const satisfies is probably the magic sauce you were missing. It's not pretty; most likely people who actually know what they're doing could do this more cleanly. It's what I had in mind though and it seems to be working at least 😅
45f6150 to
9094190
Compare
Description
Follow-up PR to the custom video player. This is not the solution we wanted, but the media-chrome team is not interested in weblate or adding many languages in one go (see muxinc/media-chromenumber#1290), so adding the strings to our own weblate translations is an alternative solution.
I copied over the existing translations they have upstream.
Upsides of the specific implementation of spreading
...En(the english strings) and then overriding some of them:Downsides:
How Has This Been Tested?
Change to all these languages, and another one (fallback remains english)
min-wto fit long German words)Please describe to which degree, if any, an LLM was used in creating this pull request.
None