-
Notifications
You must be signed in to change notification settings - Fork 22
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
Extract plugin #265
base: v2
Are you sure you want to change the base?
Extract plugin #265
Conversation
I have a fairly large project which uses JS (ecmascript 5), es6, JSX, TS and TSX -- Is there some way I can test running the extractor and report the status? |
@fermuch sure thing, just link to our fork from your package dir:
Then it should just work but of course it won't. If it fails I'd be interested to know the shape of |
For those who also want to try: Follow @sbalmer instructions, but after cloning run: I've ran with the fork, restarted the project several times, and As far as I understand, you're using the build system, so it should be generated after each run. Am I right, or do I need to call it manually? |
Welp, I'm an idiot. I was using the Here's the generated extracts.msgfmt~ (built with Meteor 1.6-rc.3) |
Oups, thanks for complementing my instructions. Amended. Your extracts.msgfmt~ is encouraging. I see .jade and .jsx had some strings extracted. Thanks for giving it a whirl. Does it actually add the strings too? So that when you add a new mf-string and save, the translation interface shows it? Do you use |
I use
It does work if I add new strings! I haven't tested doing a deploy yet, and staging is recreated each time a new commit is made, so there's no much sense in using staging to try this. I noticed two things:
|
For extraction of strings, the directory tree is traversed independently of the build system. The Meteor build system calls only one handler per file so the plugin can't make use of it. Maybe the linter stage could be abused for extraction. That might be faster too. For now I just kept the old
I thought it would ignore dotfiles and dot-dirs. I'll have a look at this. We have some email templates in
I'd prefer not adding unrelated patches even if they are trivial. |
Turns out contents of dot-dirs were already being ignored. I've added another check to ignore dot-files. |
Thank you! I'll try to take a look tomorrow to check if it's solved for me.
It's not really a problem, it's just bothersome. But I can imagine some use cases where it might be a bother, like having git's submodules inside the private dir for private packages. How hard would it be to add an env or meteor setting to append values to |
It seems Meteor settings are not available at build-time. I think the easiest solution would be to allow configuring filter settings in Another option would be to only run extraction in dirs that have a trigger file like In any case I'd prefer not meddling with the filter logic on this branch. |
Hei @gadicc, hope you are fine. What are your thoughts on this? |
Hey all. Sorry for my lack of input now. The last few months have been the most busy in my life, but lots of fun stuff is happening too. Firstly, @sbalmer, thank you yet again for your continued contributions to the project. I'm so happy you've gotten so much use out of it and are always so ready to give back to the community and other users here! And, @fermuch gets a special mention too :) Thanks for being so involved in an early stage PR, giving sbalmer so much feedback and advice to other potential users too. I have to be honest, I haven't touched or thought about this part of msgfmt in so long. If I understood correctly, this doesn't break the existing behaviour (in any scenario) but makes the project substantially more useful in others (CI, etc). Can you confirm (to the best of your knowledge)? I have only two concerns...
(on that note, v3 solves this problem via a babel plugin. it makes the project relevant outside of Meteor, of course solves all the edge cases the regex fails at, and automatically handles any language that's compiled to javascript. I had wanted to link to an early example but can't seem to recall which branch of which repo I put it in. also, don't recall 100% where babel fits in Meteor w.r.t. to Let me know your thoughts and thanks again :) |
@gadicc Thanks for your feedback.
Yes, this patch should mirror the functionality of the old process. It doesn't update the
In my view this would complicate matters. Keeping two codepaths active in parallel would increase complexity of both. I'd opt for more testing in any case. We'll want to use it do simplify our deployment process "soon". I haven't looked into other modes of testing though.
First of all, thanks for considering the option. It would simplify matters being able to commit directly. At the same time I'm afraid that my interests might be too limited in scope. I'd be mostly interested in amending the v2 branch for our use-case. Hard for me to tell how that would work out for other people :-) I like the long-term vision of properly parsing the template files. But I don't see this as a priority from our side. |
Hey :) Ok that sounds good. I'm a bit hazy on all the logic and don't have time to review the current code now. The only thing that comes to mind is we used the I'm happy to skip supporting both code paths as indeed it's a lot of work and does not seem necessary. I'm also happy for you to come on-board as solely responsible for your own work. But that would include responsibility if it affects other users. At this point in time, I can't take responsibility for PRs and related (if albeit unexpected) consequences for them. If that's the case I'd rather you maintained a separate branch until a time when I'd be able to do that (which would be early next year, at the earliest). But otherwise, sure, you'd have no responsibility for general bugs/features/issues that are unrelated. What do you think? Thanks also for the feedback re template parsing. |
The way I think it works:
How the process proposed here works: Steps 1-3 are the same as before. This process does not access any collections on the dev system and is thus oblivious to |
I've just added the last piece that was missing to recreate the old functionality: tracking removed strings. Given the positive reactions I intend to complete the process by
I'm unsure about the things to test, and how to go about that. |
Ooh, yay, awesome!! Thanks for the rundown... super helpful for me having not looked at the code in so long and being under time constraints now. Actually, I think it makes more sense to get rid of the mfExtracts collection so I'm very happy we're going this route. Thanks! To help move things along, as I'm also in a seminar for Wed-Sun + travel:
Alas, I don't think I had any built in tests for this (beyond parsing). I guess we can put down in writing now some ideal things for users to report back on. Maybe when one of has time we can write some integration tests, but probably dev efforts might be better put on v3.
a. meteor deploy I think that's it roughly, right? |
Thanks @gadicc for the invitation! Having automated integration tests would be very valuable. I think it's quite complicated though, the build step is not usually repeated during tests so would would have to hack that. Maybe an easier route would be to just replay a sequence of I'm less worried about the extraction process because there we can just examine the output. But automating this would still add some confidence. |
This patch rewrites extraction to become part of the build process. (Rationale: We've switched our deploy process to use a pristine copy of the repo rather than our working copies. In these copies
extracts.msgfmt
is not generated and deploys don't get their strings updated.)There are a few things which need to be addressed before this patch can be merged. At the moment it's a "works for us" proposition. Some things that need fixing:
process.cwd()
to find the root dir which can be wrong (when meteor is run from a subdir)I've decided to create this pull request to discuss the state of the thing before continuing to invest time in it.