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

Factor out data producing functions #24

Merged
merged 1 commit into from
Sep 29, 2015
Merged

Factor out data producing functions #24

merged 1 commit into from
Sep 29, 2015

Conversation

perrin4869
Copy link
Contributor

Hi, I made small changes to the converting functions to separate the data creating part from the part that writes the data to the files, and checked that the tests passed. This will help me use this repo to write a gulp plugin. Thanks!

@jamuhl
Copy link
Member

jamuhl commented Sep 28, 2015

will check and merge this asap.

@perrin4869
Copy link
Contributor Author

I thought it would be helpful if I made the changes I submitted more clear. I changed this bit of code inside i18nextToGettext:

        self.flattenI18nextJSON(source, options, function(err, flat) {
            self.parseGettext(domain, flat, options, function(err, gt) {

                var data = path.extname(target) === '.po' ? gt.compilePO(domain) : gt.compileMO(domain);

                self.writeFile(target, data, options, callback);
            });
        });

into:

self.i18nextToGettextData(domain, source, path.extname(target), options, function(err, data) {
            self.writeFile(target, data, options, callback);
});

where I defined a new function, i18nextToGettextData:

i18nextToGettextData: function(domain, source, target, options, callback) {
        if (typeof options === 'function') {
            callback = options;
            options = {};
        }

        var self = this;

        self.flattenI18nextJSON(source, options, function(err, flat) {
            self.parseGettext(domain, flat, options, function(err, gt) {
                var data = path.extname(target) === '.po' ? gt.compilePO(domain) : gt.compileMO(domain);
                callback(err, data);
            });
        });
}

The purpose of this change is to be able to use i18nextToGettextData on its own outside of the binary (in my case, as a gulp plugin). A similar change has been made to the gettextToI18next by adding a gettextToI18nextData.

@jamuhl jamuhl merged commit 8807e6d into i18next:master Sep 29, 2015
@jamuhl
Copy link
Member

jamuhl commented Sep 29, 2015

https://www.npmjs.com/package/i18next-conv

v0.1.5 deployed on npm.

@jamuhl
Copy link
Member

jamuhl commented Sep 29, 2015

would be nice if you keep me uptodate on the gulp plugin...

@perrin4869
Copy link
Contributor Author

Always been the plan :)
https://www.npmjs.com/package/gulp-i18next-conv
Need to write up a readme, examples, tests, and maybe small improvements. Let me know how I can share it in the main i18next repo if you're interested! Also, I'd like to help out with i18next version 2.0.0, I've taken a liking to the project, tell me how I can help! I do have a few improvements in mind too

@jamuhl
Copy link
Member

jamuhl commented Sep 29, 2015

if you want to add your repo to i18next organisation account i can add you there for transfer and later add needed rights to access it.

upcoming v2 is right now wip: https://github.com/jamuhl/i18next-playground

help there is more then welcome. right now i want to add the first draft for loading mechanism, so main parts are there and working. (plus adding some readme, with goals and basic structure of new project)

right now it would be great if you could share your ideas and have a look at new code base:

-> gulp tdd (will run new tests)
-> gulp test_compat (will run current state of compatibility to v1.x.x API and JSON Format)

(one of the biggest things on the list is generating some documentation like i18next.com - but want that to be generated out from markdown files (using https://github.com/millermedeiros/mdoc or something similar) for easier contribution.)

@perrin4869
Copy link
Contributor Author

Will be looking at it later for sure then! Thanks!
BTW, how is the Mongoose team generating their documentation? I find it rather useful, they even have a button where you can look at the source for function and object definitions and stuff

@jamuhl
Copy link
Member

jamuhl commented Sep 30, 2015

looks like they take a lot of effort to build that: https://github.com/Automattic/mongoose/tree/gh-2462

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

Successfully merging this pull request may close these issues.

None yet

2 participants