bmw-tech / arb-converter-cli

CLI to convert ARB (Application Resource Bundle) files to different formats, and vice versa
MIT License
35 stars 7 forks source link

Incorrect arb output from json with plurals #9

Open orestesgaolin opened 4 years ago

orestesgaolin commented 4 years ago

Consider following json file:

{
    "button_pressed": {
        "one": "You pressed button once",
        "other": "You have pressed button {count} times"
    },
    "hello_name": "Hello {name}!"
}

The converted arb via following command has wrong format:

arb-converter to-arb ~/Downloads/json --from-hierarchical-json ~/Downloads/arb/

Output arb:

{
    "@@last_modified": "2020-02-17T21:21:02.388Z",
    "@@author": "arb-converter-cli",
    "button_pressed": {
        "one": "You pressed button once",
        "other": "You have pressed button {count} times"
    },
    "hello_name": "Hello {name}!"
}

Whereas correct file should look more or less like follows:

{
    "@@last_modified": "2020-02-17T21:21:02.388Z",
    "@@author": "arb-converter-cli",
    "button_pressed": "{count, plural, one{You have pressed button once} other{You have pressed button {count} times}}",
    "hello_name": "Hello {name}!"
}

Is there any chance for such support?

orestesgaolin commented 4 years ago

Alternative form of json file could be as follows (exported from POEditor):

[
    {
        "term": "button_pressed",
        "definition": {
            "one": "You pressed button once",
            "other": "You have pressed button {count} times"
        },
        "context": "",
        "term_plural": "button_pressed_pl",
        "reference": "",
        "comment": ""
    },
    {
        "term": "hello_name",
        "definition": "Hello {name}!",
        "context": "",
        "term_plural": "",
        "reference": "",
        "comment": ""
    }
]
jorgecoca commented 4 years ago

Ooops totally missed that feature! Good catch @orestesgaolin !