Skip to content

Issue when trying to get from more than one po file #7

@renoirb

Description

@renoirb

When you have a folder that has more than one po file for the same data, the final file overwrites on the same key making a JSON file with only one translation.

Reproduce

Files:

  • foo/fr_CA.po
  • foo/en_UK.po

Config block:

    grunt.initConfig({
        po2json: {
            files: {
                options: {},
                files: {
                    'assets/i18n/foo.json': [ 'foo/*.po' ]
                }
            }
    });

Expected outcome

In file assets/i18n/foo.json

exports.I18N = {
    "fr_CA": {
        "Untrash": "Sortir de la Corbeille"
    },
    "en_UK": {
        "Untrash": "Untrash"
    }
}

Solution path

Read from the file name. Use it as a key

// file tasks/po2json.js, line 48
var locale = filepath.substr(filepath.lastIndexOf('/') + 1).replace(/\.[^/.]+$/,'');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions