jshmrtn / vue3-gettext

Translate Vue 3 applications with gettext.
https://jshmrtn.github.io/vue3-gettext/
MIT License
66 stars 23 forks source link

Running vue-gettext-extract produces *.po, *.pot but no translations.json file? #47

Closed calicoder77 closed 12 months ago

calicoder77 commented 12 months ago

Good day,

Not sure if I found a bug for the latest version or not. Like the title states I get the required po and pot files created but the translations.json file remains empty. Naturally running the vue-gettext-compile command fails with an error: no language headers found.

Here's my gettext.config.js file:

module.exports = {
    input: {
        path: './src',
        include: ['**/*.js', '**/*.vue'],
    },
    output: {
        locales: ['en', 'fr'],
        splitJson: true,
        path: './src/languages',
        potPath: './messages.pot',
        jsonPath: './',
        flat: false,
        linguas: true,
   },
}

Thanks in advance for any tips/help

lzurbriggen commented 12 months ago

@calicoder77 i can't quite reproduce this (at least not in v3.0.0-beta.1), but maybe we can figure this out with some more info. the error indicates that there's no line like "Language: fr\n" in e.g. src/languages/fr/app.po, is that the case?

but the translations.json file remains empty

the extract command should not do anything with the translations.json file. also, you have splitJson: true enabled, so the compile command should not create a translations.json file but instead two files: en.json and fr.json.

maybe also check what gettext version you're running, e.g. msginit --version, in my case this outputs msginit (GNU gettext-tools) 0.21.1.

calicoder77 commented 12 months ago

Hi @lzurbriggen, that language line was the cause afterall. I changed the split to false and now can see my translations.json file.

Thank you for the help.