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

Move default messages into Globalize #575

Open
alunny opened this issue Jan 10, 2016 · 5 comments
Open

Move default messages into Globalize #575

alunny opened this issue Jan 10, 2016 · 5 comments

Comments

@alunny
Copy link
Collaborator

alunny commented Jan 10, 2016

As discussed in rxaviers/react-globalize-compiler#5, the fact that react-globalize monkeypatches Globalize to support default messages (ie. using the string in the default language as the key for the message) complicates the code for react-globalize-complier and globalize-compiler. Large projects that use both react-globalize elements and calls to Globalize.messageFormatter/formatMessage can run into complications - some code might hit a Globalize that has been monkeypatched, while other code might hit an unpatched Globalize object.

If the default messages code were moved into Globalize itself, this would be much simpler.

@rxaviers
Copy link
Member

👍 I like the idea of moving that code in here. Basically, the patched API looks like this Globalize.formatMessage(pathOrMessageItself) and has a logic to either treat the first argument as a path or as the message itself (default message). It's an API that works for react-globalize. We could elaborate something more generic porting it over here, one idea is to require argument to explicitly tell what it's about, for example:

Globalize.formatMessage({
  path: <path>
});

// or
Globalize.formatMessage({
  message: <message>
})

@jquery/globalize any input anyone?

@rxaviers
Copy link
Member

rxaviers commented Feb 1, 2016

The lack of input at least shows we have no objections... 😄

I would like to stress the API first. For the record: (a) should we make it backwards compatible (i.e., the Object argument above is incompatible with the current String one)? (b) consider supporting rxaviers/react-globalize-compiler#6

@rxaviers
Copy link
Member

cc @Setogit... By looking at your examples at strong-globalize I believe you do something similar in your end. I thought you could be interested in this issue as well. We are aiming to bring default message functionality over to Globalize.

@necolas
Copy link

necolas commented Jun 2, 2016

Andrew pointed me here after I uncovered the same issue. Part of the globalize compiler tool chain can't extract messages from FormatMessage elements that are moved as part of babel/react code optimizations. I was looking into dropping our dependency on react-globalize (which I assumed would be faster than finding/fixing the compiler issue) so that we can use these optimizers, but then found that the way we use globalize is dependent on react-globalize's monkey-patching :).

@rxaviers
Copy link
Member

rxaviers commented Jun 6, 2016

Hi @necolas, thanks for your input.

I'm open to bring this feature into Globalize. I believe it's a good move and no one went against it so far. Although, we lack resources in order to implement it. Would anyone from your team be interested in contributing this feature?

About the compiler issue, although addressing this in Globalize fixes it for you, I still think it would be good and helpful to know more about the details of the problem you faced. Could you file an issue in https://github.com/jquery-support/globalize-compiler or https://github.com/rxaviers/react-globalize-compiler/ (the one that seems most appropriate) please? Thanks

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