avast / vuei18n-po

transform gettext .po files for vue-i18n
BSD 3-Clause "New" or "Revised" License
14 stars 5 forks source link

Provide sample working .PO file #1

Closed Truemedia closed 4 years ago

Truemedia commented 4 years ago

Hi, I think this package is a great idea and would be massively useful for me as Vue and vue-i18n are must for me and don't like the idea of translations in a JSON file.

Iv'e yet to get this working though, using a sample PO file I took from online I either only get the first message in the generate.json will the key being null or an empty object.

Any change this could be provided or is this project still a work in progress?

Truemedia commented 4 years ago

Found a workaround for this, on line 71 inside the main function, by swapping

messages[item.msgctxt] = value;

With:

messages[item.msgctxt != undefined ? item.msgctxt : item.msgid] = value;

Thoughts? Would this be worth a pull request as could do with this change to at least have basic string to string translations

pavelstudeny commented 4 years ago

Hi @Truemedia , msgctxt is always expected to exists, this can be seen in the test data, e.g. https://github.com/avast/vuei18n-po/blob/master/spec/data/en.po

However, based on your inquiry, I have found some use cases where msgctxt can be omitted.

I'm not sure without a deeper look whether making msgctxt optional can be done just by the single line change. Does it work for you?

Truemedia commented 4 years ago

@pavelstudeny Yes that single line change works for me I made the change directly in the node_modules and worked for me. I will try the sample you provided but yeh just thinking to cover edge cases

Truemedia commented 4 years ago

@pavelstudeny Yeh the sample works for me, however still get this issue in a newer scenario where I'm using a gettext-extractor to generate a POT file from sources, then using the POT file to update PO files. Still get the original issue in that scenario unless I put the work around in

pavelstudeny commented 4 years ago

@Truemedia https://github.com/avast/vuei18n-po/commit/7419a00f9422b659269ed38a81bd162441785585 should work. Filtering (if used) should still go just by msgctxt, I believe. Agreed?

Truemedia commented 4 years ago

@pavelstudeny Thanks, yeh looks about right I'll give a try.

pavelstudeny commented 4 years ago

fixed in 1.2.0