Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 localization with Gettext ( .po files)

I have old legacy site translated of 4 different languages with Gettext and .po files.

Now I am starting rebuilding of the site, and trying to use those files in new Angular2 site.

Is there any way I could directly use .po files?

I have tried https://github.com/ocombe/ng2-translate with https://www.npmjs.com/package/@biesbjerg/ng2-translate-po-loader but It's not working properly when passing params to string.

Then I tried some converters, to convert .po to JSON, but they are adding some nulls and arrays...

For example converting:

msgid "meta:Reporting"
msgstr "Reporting"

I get:

"meta:Reporting": [
    null,
    "Reporting"
]

Instead of

"meta:Reporting" : "Reporting"

Is there way to use directly .po files in Angular2?

like image 568
Nutic Avatar asked Jan 31 '17 18:01

Nutic


1 Answers

I use ngx-translate together with ngx-translate-po-http-loader. I use them together with ngx-translate-extract to extract text from my .ts-fies to one or more .pot-files

like image 88
Challe Avatar answered Oct 28 '22 21:10

Challe