Skip to content

Conversation

@SVANNER
Copy link
Contributor

@SVANNER SVANNER commented May 22, 2017

Hi, i tried to use the json format to be able to import/export json files for NGX-Translate (used in Ionic and Angular mobile application development).
Unfortunately, the json format produced is not exactly the same for NGX-translate.
I wrote the format class to be able to manage NGX-Translate json files.
It should be useful to include this format for the growing Ionic/Angular developers population

Thanks a lot !

@ocean90
Copy link
Member

ocean90 commented May 22, 2017

Hello @SVANNER, thanks for your PR.

Could you provide some links about the NGX format? A document where the standard is documented would be great.

Would you be able to extend your PR with some unit tests?

@SVANNER
Copy link
Contributor Author

SVANNER commented May 22, 2017

Hi, @ocean90 ,
The documentation about NGX-Translate is here: https://github.com/ngx-translate/core
The format is in fact a simple list of key / value pairs. like:
"PGESTGTITLE": "Settings"
Note the two supplied json formats return translations as an array while we need single strings for NGX Translate.
Another feature used is array translations (mainly used for quick fill of translated lists or comboboxes) like:

"PGESTGDYLST": [{ "key": "0", "translation": "by categories" },
                                { "key": "1", "translation": "by experiences" },
                                { "key": "2", "translation": "by date" }
                                ]

Here is the json file i used to test the import of originals:

{
    "APPTITLE": "Meditation helper",
    "CAMERAFLASH": [{ "key": "auto", "translation": "auto" },
        { "key": "on", "translation": "on" },
        { "key": "off", "translation": "off" },
        { "key": "torch", "translation": "torch" }
    ],
    "CAMERAACCEP": "Accept",
    "CAMERACROP": "Crop",
    "CAMERAREJEC": "Reject",
    "GENWAIT": "Please wait...",
    "GENOK": "Ok",
    "GENCANCEL": "Cancel",
    "GENMOREOPTS": "More...",
    "GENOPTIONS": "Options",
    "GENEXPANDAL": "Expand all",
    "GENCOLAPSAL": "Collapse all",
    "GENLANGUAGE": [{ "key": "  ", "translation": "of the device" },
        { "key": "en", "translation": "English" },
        { "key": "fr", "translation": "French" }
    ],
    "GENEXPERIEN": "My experience",
    "GENSERCHEXP": "Search experience",
    "PGESTGDYLST": [{ "key": "0", "translation": "by categories" },
        { "key": "1", "translation": "by experiences" },
        { "key": "2", "translation": "by date" }
    ],
    "PGESTGTITLE": "Settings",
    "PGESTGLANGL": "Language",
    "PGESTGDYVEW": "Diary",
    "PGEUPDCATAD": "Add new category",
    "PGEUPDCATUP": "Update category",
    "TABDRYTITLE": "Diary",
    "TABSNDTITLE": "Soudtracks",
    "TABAGDTITLE": "Agenda",
    "HELLO": "hello {{value}}"
}

I also imported the french translations using:

{
    "APPTITLE": "Aide à la méditation",
    "CAMERAFLASH": [{ "key": "auto", "translation": "auto" },
        { "key": "on", "translation": "on" },
        { "key": "off", "translation": "off" },
        { "key": "torch", "translation": "torche" }
    ],
    "CAMERAACCEP": "Accepter",
    "CAMERACROP": "Réduire",
    "CAMERAREJEC": "Rejeter",
    "GENWAIT": "Patientez...",
    "GENOK": "Ok",
    "GENCANCEL": "Annuler",
    "GENMOREOPTS": "Plus...",
    "GENOPTIONS": "Options",
    "GENEXPANDAL": "Développer tout",
    "GENCOLAPSAL": "Contracter tout",
    "GENLANGUAGE": [{ "key": "  ", "translation": "de l'appareil" },
        { "key": "en", "translation": "Anglais" },
        { "key": "fr", "translation": "Français" }
    ],
    "GENEXPERIEN": "Mon vécu",
    "GENSERCHEXP": "Chercher une expérience",
    "PGESTGDYLST": [{ "key": "0", "translation": "par catégorie" },
        { "key": "1", "translation": "par expérience" },
        { "key": "2", "translation": "par date" }
    ],
    "PGESTGTITLE": "Paramètres",
    "PGESTGLANGL": "Langue",
    "PGESTGDYVEW": "Journal",
    "PGEUPDCATAD": "Ajouter une catégore",
    "PGEUPDCATUP": "Modifier une catégorie",
    "TABDRYTITLE": "Journal",
    "TABSNDTITLE": "Pistes sonores",
    "TABAGDTITLE": "Agenda",
    "HELLO": "Bonjour {{value}}"
}

The results can be found here: http://translate.gvngroup.be/projects/zenmade/fr/default/?page=1.

I then exported the translations french translations having the results:

{"CAMERAACCEP":"Accepter","PGEUPDCATAD":"Ajouter une cat\u00e9gore","TABAGDTITLE":"Agenda","CAMERAFLASH":[{"key":"auto","translation":"auto"},{"key":"off","translation":"off"},{"key":"on","translation":"on"},{"key":"torch","translation":"torche"}],"PGESTGDYLST":[{"key":"0","translation":"par cat\u00e9gorie"},{"key":"2","translation":"par date"},{"key":"1","translation":"par exp\u00e9rience"}],"GENCANCEL":"Annuler","GENCOLAPSAL":"Contracter tout","CAMERACROP":"R\u00e9duire","TABDRYTITLE":"Journal","PGESTGDYVEW":"Journal","GENLANGUAGE":[{"key":"en","translation":"Anglais"},{"key":"fr","translation":"Fran\u00e7ais"},{"key":" ","translation":"de l'appareil"}],"GENEXPANDAL":"D\u00e9velopper tout","HELLO":"Bonjour {{value}}","PGESTGLANGL":"Langue","APPTITLE":"Aide \u00e0 la m\u00e9ditation","GENMOREOPTS":"Plus...","GENEXPERIEN":"Mon v\u00e9cu","GENOK":"Ok","GENOPTIONS":"Options","GENWAIT":"Patientez...","CAMERAREJEC":"Rejeter","GENSERCHEXP":"Chercher une exp\u00e9rience","PGESTGTITLE":"Param\u00e8tres","TABSNDTITLE":"Pistes sonores","PGEUPDCATUP":"Modifier une cat\u00e9gorie"}

If you need more, let me know.

Kind Regards,

@toolstack
Copy link
Contributor

@SVANNER Looks good, you might want to check out the phpunit test cases we use for the other formats to build test cases for this new format.

@SVANNER
Copy link
Contributor Author

SVANNER commented May 23, 2017

@toolstack Ok i'll take a look to the test cases of the other formats and come back with the testcase.

@SVANNER
Copy link
Contributor Author

SVANNER commented May 23, 2017

@toolstack Test Cases added for NGX-Translate.

Kind Regards

Copy link
Contributor

@toolstack toolstack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good @SVANNER, just one minor change, could you update your @since lines from 2.3 to 2.4?

Thanks.

@toolstack toolstack added this to the 2.4 milestone Jun 28, 2017
@toolstack toolstack added the [Type] Feature New feature to highlight in changelog. label Jun 28, 2017
@SVANNER
Copy link
Contributor Author

SVANNER commented Jul 4, 2017

Hi, @toolstack, @since changed to 2.4.

Kind Regards,

@toolstack
Copy link
Contributor

Thanks @SVANNER, could you also take a look at some of the formatting errors that travis is reporting?

Mostly the blanks and extra spaces. Ignore the file name and file_get_contents() warning.

@SVANNER
Copy link
Contributor Author

SVANNER commented Jul 5, 2017

Hi @toolstack, have performed corrections. 1 error still remaining about file names and warnings about file_get_contents()

Kind Regards

@toolstack
Copy link
Contributor

Thanks @SVANNER, looks good.

@ocean90 ocean90 self-requested a review July 11, 2017 17:33
Copy link
Contributor

@toolstack toolstack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@toolstack toolstack modified the milestones: 3.0, 2.4 Aug 15, 2017
@ocean90 ocean90 merged commit 9dcd348 into GlotPress:develop Aug 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Feature New feature to highlight in changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants