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
Reintroduce pseudo-localization #83
Comments
Maybe just introducing some generic "post-processing" on messages in MessageContext, and then adding let ctx = new MessageContext(['ar'], {
process: fluent_pseudolocales.transform.bind('ar-XB')
});
let msg = ctx.formatValue('l10n-id'); |
That was my first thought as well. A few additional thoughts below. I'll try to have answers tomorrow. We have to take into account how this will interact with the language negotiation. Would we expect the user to set their requested locale to a pseudolocale in order to enable it? Would we require that developers add pseudolocales to the list of Perhaps it would make sense to encode pseudolocales as Unicode extensions to BCP47? Something like What should be the outcome of formatting a date or a number in a pseudolocalized translation? Also, the first step might be to only support build-time pseudolocalization. |
Google just went for Now, my problem with this is that because they used Since we'd be doing runtime pseudo, maybe we don't need extensions (and they wouldn't be unicode extensions, but rather variants ( Google originally used Maybe all we need is: let ctx = new MessageContext('pl', {
process: pseudo
}); and it'll transform polish strings? This way we could get a pseudo of the current locale, irrelevant of what it is. |
How would you decide when to turn pseudolocalization on? A different logic independent of the language negotiation? |
Yeah! This way the user can either detect pseudo from a langtag ( |
Yeah! This way the user can either detect pseudo from a langtag (oh,
you're using XA region?) or by some checkbox.
If the user sets their requested to en-XA and the available only have
en-US, the result of the language negotiation will be `en-US`. At the moment
when we’d create the MessageContext we wouldn’t know the region was XA.
On the other hand, if we add en-XA to the list of available locales, and
the files for it do not exists on disk, we will fail to fetch anything.
We’d need to extend the IO logic to fetch them. This might mean moving the
pseudolocalization to fluent-web. I think it would be better to have it on
a lower level though.
Does the language negotiation preserve extensions found on the requested
locales?
|
Oh, you're right.
I agree.
yes. So, maybe private-extension? |
There's discussion in http://unicode.org/cldr/trac/ticket/3971 and http://unicode.org/cldr/trac/ticket/9819 on why CLDR didn't go for variant tags. It's mostly about compatibility with existing code. Also, since I'm reconsidering my stance on where this logic should live. Having it higher up, e.g. in fluent-web would allow multiple approaches:
fluent-web can also transform translations in a way which preserves HTML for the overlay mechanic. |
I'd think that the most accute way to implement the actual pseudo localization would be on the AST? |
On buildtime or on runtime? |
For both, I guess. |
Transforming the runtime AST means doing the transformation inside of We still need to solve the problem of fetching valid locale files. Given that it looks like fluent-web (or fluent-react) would need to handle the pseudolocalization anyways (if only to be HTML-aware), I think it makes sense to special-case For example, given the following result of language negotiation:
…a developer using let ctx = new MessageContext(negotiated, { pseudo: makeAccent });
ctx.addMessages( /* en-US translations to be transformed into en-XA */); Or, if the build pipeline is capable of building pseudolocales up front, the IO code would simply fetch the pre-made let ctx = new MessageContext(negotiated);
ctx.addMessages( /* en-XA translations generated on build-time */); |
I do not agree with Stas that we have to use |
Note that the approach from my previous comment will work with any scheme of specifying pseudolocales. In my example I chose to put There's value in using |
@stasm - would you have time to draft a plan to get this into a POC state? I'm happy to commit to work on that, but would prefer to follow your vision. |
Some POC prototyping gave me this: https://youtu.be/E3t8-u8e5D0 It's actually quite simple to get to that point, and even get Intl hooked in. There's going to be more work to be done to get complex messages handling. I'm wondering if it's better to import pseudo for side-effects and allow itself to hook into fluent: import "fluent-pseudo";
let cx = new MessageContext(locales, {
usePseudo: true
}); or make people hook it explicitly: // strategy1 - 30% longer via duplication of vovels, larin chars transformed, LTR
import { strategy1 } from "fluent-pseudo";
let cx = new MessageContext(locales, {
transform: strategy1
}); Enough for now, will wait for stas :) |
I find the explicit version easier to understand. It will also be easier to test. |
From a developer point-of-view, I don't expect that any Firefox developer will be touching code at that abstraction level. We explicitly don't want these folks to know that MessageContext even exists. |
Agreed. IIUC this issue is about the low-level API which |
@zbraniecki and I talked about this yesterday and today. We'd like to start simple with the approach from comment #83 (comment).
|
This issue uses the word Say, I'm a firefox developer, and I want to run my local build with psaccent on. How would I do that, and which parts of our code stack are involved in doing so, and what would they need to do? |
Good point. I meant the users of the library here. Elsewhere I meant the user of the app.
You would start by flipping a pref somewhere in the UI. The values of the pref could be: |
Can we close this issue? We have capability for pseudolocalization since fluent 0.7 and we use it in Gecko. Or should we wait until we extract |
Hey @zbraniecki, by chance would you have some guidance or documentation about how to use pseudolanguages with fluent.js/fluent-react in a plain web page (as opposed to in Firefox)? Thanks! |
|
Thanks for the pointers! This is what I did to support pseudo locales in the profiler: firefox-devtools/profiler#3188 We enable a pseudo locale by calling a function in the devtools console. Would the file https://github.com/firefox-devtools/profiler/pull/3188/files#diff-ca1e6802f7be91e16b4123f89f090a2c40053a53e52b73ed3d69469619179d24 be suitable as |
yeah, it looks good! For a while we used a hardcoded list which is quite stable - https://github.com/mozilla-b2g/gaia/blob/master/shared/js/intl/l20n-client.js#L31-L35 |
Coming back from the Unicode Conference, there was a lot of chatter about pseudo-locales.
Fluent already had a pretty good support for pseudo-locales in the past and due to our client-side mode, we offer an exciting approach to pseudo-locales - runtime pseudolocalization.
I'd like to bring back this: https://github.com/l20n/l20n.js/blob/v3.x/src/lib/pseudo.js to modern fluent.
@stasm - do you have any thoughts on how would you like it to work?
The text was updated successfully, but these errors were encountered: