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

Structure of languages and resources #21

Closed
Evanion opened this issue Oct 17, 2014 · 7 comments
Closed

Structure of languages and resources #21

Evanion opened this issue Oct 17, 2014 · 7 comments

Comments

@Evanion
Copy link

Evanion commented Oct 17, 2014

Hello
I found this project when I was looking to integrate Transifex in the build process for our Ionic based app.

Since Ionic uses Angular.js internally, We will be using Angular-translate.
I have a few questions on how to best setup your module:

  • How can we define the correct file format (ie; KEYVALUEJSON)?
  • Our files are structured ´/assets/lang/{lang tag}/{resourcename}.json´. How can we structure the gulp task to process this correctly?
@kevinmartin
Copy link
Contributor

Give me about 30 minutes to get to my office and either @marcoslhc or
myself will help you and try to put up some documentation and samples.
On Oct 17, 2014 9:22 AM, "Mikael Pettersson" notifications@github.com
wrote:

Hello
I found this project when I was looking to integrate Transifex in the
build process for our Ionic based app.

Since Ionic uses Angular.js internally, We will be using Angular-translate.
I have a few questions on how to best setup your module:

  • How can we define the correct file format (ie; KEYVALUEJSON)?
  • Our files are structured ´/assets/lang/{lang
    tag}/{resourcename}.json´. How can we structure the gulp task to process
    this correctly?


Reply to this email directly or view it on GitHub
#21.

@Evanion
Copy link
Author

Evanion commented Oct 17, 2014

Wow, that was a quick reply. Sounds great, I will await your magic :)
Some more questions:

  • Do we need to duplicate the source and target files? Or is it built so that if developers add new translation keys to the source language, It will automatically update the languages in transifex, before pulling the new version of the languages? (I noticed they are separate methods, but they should be able to combine in to a single task).
  • What happens if a string key have been removed? Will it automatically update transifex?

@marcoslhc
Copy link
Contributor

Hi @Evanion.

How can we define the correct file format (ie; KEYVALUEJSON)?

Right now, the plugin does work for po files only, see for example: https://github.com/NEURS/gulp-transifex/blob/master/index.js#L469. But it shouldn't be too difficult to add support for other file formats. I hope to invest some time in that feature in a medium term. Basically we need to do:

Like I said, I hope to add it sometime in the next two weeks. Right now I'm in no place to do it. But if you guys are up to do it earlier it would be high and gladly appreciated.

Our files are structured ´/assets/lang/{lang tag}/{resourcename}.json´. How can we structure the gulp task to process this correctly?

In our own gulpfile we use it like this:

transifex: {
        local_path: 'www/locale/*/LC_MESSAGES',
        project: process.env.TRANSIFEX_PROJECT,
        user: process.env.TRANSIFEX_USER,
        password: process.env.TRANSIFEX_PASSWORD,
        custom_language_codes: {
            "es": "spa",
            "it": "ita",
            "de": "deu",
            "pt": "por"
        },
        language_codes_as_objects: true,
        use_custom_language_codes: true
    }

notice the glob in local_path: 'www/locale/*/LC_MESSAGES'. that would go to every language folder, look for the LC_MESSAGES subfolder and process all the po files in that directory; so I'm guessing that yours should be: ´/assets/lang/´, no need for the glob since you store the translation file directly in the language folder. The language paths are resolved here: https://github.com/NEURS/gulp-transifex/blob/master/index.js#L496

@Evanion
Copy link
Author

Evanion commented Oct 17, 2014

I doubt our developers will have any time faster than you guys ...
We won't even go into beta until a month from now, so we can keep the process manual for the time being.

@marcoslhc
Copy link
Contributor

It's fixed: 3c2902e
Use gulp-transifex 0.1.11

@Evanion
Copy link
Author

Evanion commented Oct 24, 2014

Can you update the documentation to reflect the new API?

@kevinmartin
Copy link
Contributor

Documentation is the same, but here is a second example from another project:

gulp.task('transifex:push', function() {
    var transifexClient = transifex.createClient({
        local_path: '/locale/*/LC_MESSAGES',
        project: 'abc-project,
        user: process.env.TRANSIFEX_USER,
        password: process.env.TRANSIFEX_PASSWORD
    });

    // Your source files
    return gulp.src('./locale/*.pot')
        .pipe(transifexClient.pushResource());
});

gulp.task('transifex:pull', ['locale:extract'], function() {
    var transifexClient = transifex.createClient({
        local_path: '/locale/*/LC_MESSAGES',
        project: 'abc-project',
        user: process.env.TRANSIFEX_USER,
        password: process.env.TRANSIFEX_PASSWORD
    });

    // Path of your source files, not destination. For destination, set `local_path`
    return gulp.src('./locale/*.pot')
        .pipe(transifexClient.pullResource());
});

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

No branches or pull requests

3 participants