Skip to content
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

Feature suggestion: psuedolocalisation injection #769

Open
jacalata opened this issue Aug 17, 2017 · 4 comments
Open

Feature suggestion: psuedolocalisation injection #769

jacalata opened this issue Aug 17, 2017 · 4 comments

Comments

@jacalata
Copy link
Contributor

jacalata commented Aug 17, 2017

I am thinking of writing a feature that would allow me to pass in a function to use on any string to pseudolocalize it (probably using /bunkat/pseudoloc), and then would (handwave) wrap the messageFormat functions for one or more locales in this function before returning them (maybe here https://github.com/globalizejs/globalize/blob/master/src/message/formatter-runtime-bind.js#L38)

Use case: I want to generate pseudoloc files on build and be able to just switch to a language I don't expect to support (e.g mongolian) to see my app in pseudo. Before I start working on this, I thought I'd check
a) is this achievable today without changing the library?
b) are there similar/different existing plans to enable pseudoloc?

my planned functionality
setup will add this call:

    Globalize.pseudo.wrapper = function(inputStr) "[%%" + inputStr + "&&]"
    Globalize.pseudo.locale = mn_MN

messages..js will return

    Globalize.pseudo.wrapper =  function(inputStr) "[%%" + inputStr + "&&]" 
    Globalize.b588885275 = messageFormatterFn((function(  ) {
    return function (d) { return pseudo.wrapper("Hello, " + d.name;) }
    })(), Globalize("en").pluralGenerator({}));

so in my code I will have

    function Hello = Globalize.messageFormatter("Hello")
    Hello( {name: Joe} ) = "[%%Hello, Joe&&]"
@WilliamHolmes
Copy link

WilliamHolmes commented Jan 15, 2018

@jacalata Did you get any further with implementing a pseudo localization bundle?
I was hoping to start implementing something similar to check if any strings are concatenated or hard coded etc.

Ideally, globalize would support the zz locale.

@jacalata
Copy link
Contributor Author

jacalata commented Jan 19, 2018 via email

@WilliamHolmes
Copy link

WilliamHolmes commented Jan 19, 2018

@rxaviers I would have thought a pseudo build would be a common use case for large application builds/process. Is there any future plans or suggestions what we might do until then? I was looking as strong-globalize but I don’t want to change dependencies. Thanks.

@rxaviers
Copy link
Member

It's not clear to me why this should be inside globalize instead of an independent process, e.g.,
by applying pseudo localization to the data itself? One can generate the JSON translations for the default locale, then create the pseudo translations for an arbitrary locale by using that. Please, could you explain?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants