Conversation
|
Lol wow, nice work. I might need a few days to go through this. That cool? |
|
(and I'm sure you see tests are failing) |
|
Taking a little time to review is absolutely fine. :) Found the test-failure-generator. It turns out the node |
|
Any thoughts yet, @SlexAxton? |
|
My other thought: The format-js guys technically pulled out our old peg parser and changed some things but otherwise were kind of very similar. I very seriously doubt we could use their peg as it is, but since there's is an external dependency, maybe if we forked it, made our necessary changes and used it as a dependency it'd increase the chances of our implementations at least converging at the AST level. Does that sound crazy? |
|
Regarding the plural/selectordinal keys, the spec is actually a bit weird on this, as it doesn't limit the keys, but does expect and require the input for the matching to be a number. Effectively, it's messageformat.js that's been incorrect here because we've not required the input to be a number. I checked a few of the other implementations, and it may just have been us that worked this way. I have now made the generated error more descriptive, and added a method While doing that, I also moved the make-plural Regarding the parser, I presume you mean this? I did take a look at it while refactoring our parser, but ended up doing things a bit differently; the version I ended up with is IMHO much simpler. Changing the yahoo/intl-messageformat compiler doesn't look trivial, but I agree that there may be use cases for our parser to be used by itself. I'll have a try at extracting it from this repo, and see how it looks. Given the scope of the changes in this PR, it might make sense to push out a |
|
Go for it. Looking solid.
|
|
That was decently painless. I extracted the full history of edits to the parser, and constructed a new repo around that at messageformat/parser. That's now published to npm with a "latest" release of npm install messageformat-parserI've subsequently removed the parser code from messageformat.js, messed around a bit, and got it released on bower and npm: bower install messageformat#1.0.0-rc.2
npm install messageformat@prereleaseI think despite my fixes, the bower release may still be missing the main jsdoc style file. I'll look at it later. I've left this branch on my own account for now, as github won't let the base branch of an existing PR to be changed. There is, however, the github prerelease tag |
|
@eemeli @SlexAxton Any ETA on this? Anecdotally, I've tried 1.0.0-rc.2 in a very large project and it seems to be working fine, but I'm hesitant to push it to production in case there are known issues that I've just missed. |
|
I feel pretty confident that the RC2 is pretty close to what will be released. Usually it's docs and stuff that are holding back releases, the code seems to be pretty solid. |
|
@SlexAxton @eemeli Sorry to keep pestering -- just take it as meaning somebody really appreciates your work :) What's left to be done for the 1.0.0 release? Anything I can help with? |
|
I totally understand. Thanks again for the amazing work! |
|
I merged the branch to |
So, I may have ended up going down a bit of a rabbit hole when I fixed #134 while thinking of #132, and put together this little proposed set of changes. It includes changes to, well, nearly everything except for the parser. The source code documents itself pretty well, but here's an overview of the changes:
Constructor
Takes in a single
localeparameter, which can be a string, array or object; the last form effectively includes the functionality of the previous second parameterpluralFunc. The semantics oflocaleare also a little different, as the concept of fallback locales is dropped, and instead having multiple entries creates a fully multi-lingualMessageFormatobject. The formatters are dropped from the constructor; their addition is now with a chainableaddFormattersmethod. They're also much better documented.compile()With object input, the output is no longer a function, but an object with a similar structure as the input, with each messageformatted string replaced by a corresponding function. The top-level object has a
toStringmethod that works a bit like previously, except better -- it defaults to an UMD wrapper, and can output e.g. ES6 module code. When used with multiple locales, the locale is auto-detected from the object keys. The second optional parameterlocalecan be used to force a single locale, or to select one if the constructor was originally called with no parameters.Runtime
The included runtime methods are flattened, and only included if actually used. See the updated example for the new default output, and note that it's missing the
selectfunction as that's not included in any of the compiled functions. The flattening does mean that some locale names need to be fiddled with to make them valid non-reserved JS function names.bin/messageformat.js
Effectively completely rewritten and simplified, given the new
compile().toString()output and options.Altogether, this is a whole pile of breaking changes, and will need a new major version. Perhaps it'd be time to consider a 1.0 release?