-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Globalization of Node Error Messages #9174
Comments
I would suggest separating actual globalization of error messages from other improvements (like wrapping lower level error messages within higher level ones, etc.). |
Today's discussion: https://gist.github.com/srl295/4b11872ca4d6e26b69c1 |
Following up on today's discussion: https://gist.github.com/jasnell/1ee1e23a30875683dca2 (slightly revised version) /cc @tjfontaine @bmeck @srl295 |
ok, I'm trying to get my head around this proposal, but it seems that it is mixing too many concepts. We have to have a clear differentiation between In the other hand, provisioning is in the loader realm (getting data from files available in the runtime), and this is the most confusing part for me here. How will this map to the client runtime (browser)? How will this work with ES6 Loader? I'm worry that we will be introducing a complete new way of provisioning, sort of a black magic, instead of just providing an imperative api that allow users to require/provision data and other resources. Can someone provide the ultimate goal here? It is not very clear from the notes and proposal. |
@srl295 @jasnell How does globalization of error messages relate to https://gist.github.com/srl295/4b11872ca4d6e26b69c1 and https://gist.github.com/jasnell/1ee1e23a30875683dca2? Is the idea to implement globalization of error messages with resources and bundles? If so, I would suggest to first discuss these items in separate issues (as they would be used more generally, not only to globalize error messages), and to mention that globalizing error messages depends on them. Otherwise I'm concerned the relationship between these concepts may be confusing. |
@misterdjules yes, there are really three separate items here that need to be split out.
If implemented properly, these will overlap somewhat in that the js api used by node's own core library ought to be identical to that used by module developers -- although the internals of each will differ. For node's own messages, before I can go much further, a decision ought to be made: are we going to make ICU mandatory or not. The reason is because ICU exposes a very efficient message bundle API already that can be directly leveraged by node. At compile time we would generate an ICU dat file containing all of nodes own messages and would use that within the node src and lib. If ICU is going to be optional, we would need to introduce an abstraction api or use a different mechanism such as gettext. I can go either direction but I'd need to know which the core team would prefer. |
@caridy keep in mind that this is still a very early proposal. I don't yet have answers for how this maps to the browser, how it works with the ES6 loader, etc. We will be working through those bits, however. I will be making sure those questions are answered and I'm working with one of our (ibm's) rep's to emca-402 ( @srl295 ) to ensure that whatever direction we go here will work with ES6. Suggestions are definitely welcome if you have any. Specifically, this proposal deals with locale-aware resource loading only. That is, any module might have a collection of resources (files such as templates, message bundles, images) that are locale specific (a favicon intended for en-US users may not be appropriate for fr-CA users, etc). I know there are many other ways that can be divided up (as you suggest) but to keep things simple, this proposal focuses specifically on locale / bcp47. Right now, module developers are required to use The Right now, the point of putting this proposal up is to solicit feedback early in the design process. Is this heading the right direction? If it's not, what are we missing? What would be a better approach? Is there something fundamental that I'm overlooking? Or, perhaps more importantly: is there a reason why this absolutely should not be in the node core lib? |
@misterdjules ... let's keep this issue open and focused on the localization of nodes own error messages and I will create a separate issue for the Resource/Bundle API and make sure the two link back to one another |
Looking at #9258 and this ticket, along with the proposals linked above, and based on the experience @rxaviers and me gathered working on Globalize on top of CLDR, my recommendation is to keep it very simple and private: Implement a private module to translate node's error messages. Don't try to expose anything as public APIs. Once Ecma-402 supports ICU message format, use that for JS modules. To make that migration easier, use ICU message format in that private module - definitely don't invent your own syntax (like "hello %s"). |
//cc @joyent/node-coreteam ... Core team: when you get a moment I'd appreciate a look here: a6e66cc ... it's not yet fully baked and does not build on Windows or Ubuntu yet but it demonstrates the basic direction on externalizing nodes own messages. The tl/dr version is: (1) If --with-intl is enabled, a new static dependency lib is compiled that contains the externalized resources. These are simple printf style template strings stored within an ICU dat file compiled statically into a lib linked into node itself. Right now, only en, en_US, and ROOT locales are supported.
(All of Node's own messages are quite simple so printf templates here are more than sufficient. Things get a bit too complicated very quickly if we start trying to do full ICU messageformat support. The idea is to keep it simple) (4) From Within the JS Core Library code, do a (5) Next steps are to make sure this is building correctly on all our supported platforms which I'll be working on today and tomorrow. In the meantime, I'd appreciate any comments / feedback. |
Opening the issue for tracking: Need to explore globalization and general improvement of node error messages (log and user).
The text was updated successfully, but these errors were encountered: