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

New feature - Add format for NGX-Translate (used in Ionic and Angular projects) #720

Merged
merged 14 commits into from Aug 22, 2017

Conversation

Projects
None yet
3 participants
@SVANNER
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@ocean90

ocean90 May 22, 2017

Member

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?

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

This comment has been minimized.

Show comment
Hide comment
@SVANNER

SVANNER May 22, 2017

Contributor

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,

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@toolstack

toolstack May 23, 2017

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.

Contributor

toolstack commented May 23, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@SVANNER

SVANNER May 23, 2017

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@SVANNER

SVANNER May 23, 2017

Contributor

@toolstack Test Cases added for NGX-Translate.

Kind Regards

Contributor

SVANNER commented May 23, 2017

@toolstack Test Cases added for NGX-Translate.

Kind Regards

@toolstack

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 feature label Jun 28, 2017

@SVANNER

This comment has been minimized.

Show comment
Hide comment
@SVANNER

SVANNER Jul 4, 2017

Contributor

Hi, @toolstack, @since changed to 2.4.

Kind Regards,

Contributor

SVANNER commented Jul 4, 2017

Hi, @toolstack, @since changed to 2.4.

Kind Regards,

@toolstack

This comment has been minimized.

Show comment
Hide comment
@toolstack

toolstack Jul 4, 2017

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.

Contributor

toolstack commented Jul 4, 2017

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

This comment has been minimized.

Show comment
Hide comment
@SVANNER

SVANNER Jul 5, 2017

Contributor

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

Kind Regards

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@toolstack

toolstack Jul 5, 2017

Contributor

Thanks @SVANNER, looks good.

Contributor

toolstack commented Jul 5, 2017

Thanks @SVANNER, looks good.

@ocean90 ocean90 self-requested a review Jul 11, 2017

@toolstack

👍

@toolstack toolstack modified the milestones: 3.0, 2.4 Aug 15, 2017

@ocean90 ocean90 merged commit 9dcd348 into GlotPress:develop Aug 22, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment