-
Notifications
You must be signed in to change notification settings - Fork 57
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
project overlap / parser separation #82
Comments
This was exactly what I was planning for a big major release, I just didn't have time. The current way we do things for different languages are very hacky and it also doesn't make sense to increase the size of the core project to support every new language/template language. So in short, the answer is a big YES. How can we collaborate? :) I'd be hesitant to let go of the current JS part because in the past year we have fixed many things and I think it is quite solid. Not the same for other parts tho. |
/cc @zaach |
Good to hear! :) |
Awesome, looking forward to this. 😲 |
Ok, I found a bit of time to think about this. This is all a proposition (don't read it in any other way): One assumption (as mentioned earlier): the preferred way to parse is to use the template language's parser/lexer if possible. Like you did for Jade and gettext-handlebars does. If not, then resort to regex (Swig, EJS?). Would you be able to give gettext-handlebars a try to replace your Handlebars parser? Not because it is "much wow", but to see if it's input-output would work for you. If we can find a good "standard" for this, you could then split up your other parsers using the agreed structure. Generally, I think a parser needs to accept a keyword spec (see xgettext's --keyword parameter) and a (multiline) template string. Turning a file path into a template string isn't a job for the parser. One issue I have with this approach is the dependency management in the CLI package. You have any ideas how to handle this? Updating the CLI package every time a new parser is added or a new version is released, feels so troublesome. |
I just started diving into this project have a bit to add:
👍
There's already an implicit API for how a parser is interfaced, two arguments are sent:
I think this is a good starting point for CLI > Parser communication. As for the response, this is where this project needs some improvement: Currently the response is:
I propose that the I think this would yield significant cleanup, including:
True, but it is not too bad. If all are in agreement about proposed changes, then focus should be on refactoring and developing the internal API. Once that's done, then focus can be on user extensibility with installable parsers. |
Yup. Moreover we can add some hooks for new parsers to attach themselves (or make them discoverable) dynamically.
Heh, I wrote the thing above before reading this. Yeah I think this sounds like a good path forward. |
Good suggestion about using gettext-parser's structure. poEdit calls will probably always be for one (template) language so no aggregation should be performed across languages. But you could have calls where the language is derived from the file extension and thus have cases where you need to aggregate the results of multiple parsers. Not common for poEdit, but it might make more sense for something like grunt. In that light, you could argue a parser just needs to focus on parsing one input string. The result would of course resemble gettext-parser's structure as close as possible. |
I agree with this one.
Sort of disagree. I think we should always do aggregation but should not expect it from individual parsers. May be unless it is in the same file? Not sure. I want to make parsers as simple as possible and gettext-parser's structure has a bit more than that. On the flip side, if we do not enforce this structure we would end up inventing our own structure which would be quite similar to this one I think. |
👍 |
Great. Let's agree on parsers' use and its output format then. var parser = new Parser({
_: [0],
gettext: [0],
ngettext: [0, 1]
});
parser.parse(contentOfOneFile);
Please adapt the above as you see fit and feel free to add a sample return value format. |
I would prefer that parsers be instantiated with convention > configuration. For example, if the handlebars are already using Question: why is the argument array necessary? Are there cases where a keyword func would get anything other than one argument (simple translation) or three (plural)? If one needs to override/extend the agreed-upon convention, (say the handlebars use I think the parser should be provided all options (so when something like var parser = new Parser(options);
var translations = parser.parse(contentOfOneFile); |
I'm definitely in favour of providing I'm not entirely sure about the defaults though. It is definitely true About the argument position array for every keyword: parsers need to accept these. Yes, people (including myself) use others than the defaults. In general: I would always try to offer full xgettext compatibility. |
This is an issue that should be resolved after: zaach#82 (comment)
This is an issue that should be resolved after: zaach#82 (comment)
This is an issue that should be resolved after: zaach#82 (comment)
Not much I can help here, but just for the sake of at least some support — I think it will be great feature. Hope to see it in nearby future. |
This is an issue that should be resolved after: zaach#82 (comment)
I've been working on xgettext-template for a while, which seems to be very similar to this project.
I haven't looked into things enough to see what's different (besides language support), so I'm avoiding the overlap-subject for now.
I came here with this question: since I was working on Swig-parsing, I wondered if you would consider splitting up the parser(s) into (a) different sub-project(s)?
xgettext-template was recently restructured with that in mind: the Handlebars parser is a separate project that can be used independently from the main project (basically the CLI interface). Definitely feel free to use it (it doesn't rely on regex's, but on the Handlebars lib itself).
The text was updated successfully, but these errors were encountered: