smhg / gettext-parser

Parse and compile gettext po and mo files, nothing more, nothing less
MIT License
160 stars 44 forks source link

fix context #10

Closed Riim closed 9 years ago

BYK commented 9 years ago

Mind explaining the issue and how your change is fixing it?

Riim commented 9 years ago

In _drawBlock there is a line msgctxt = override.msgctxt || block.msgctxt, without my patch block.msgctxt is always undefined.

The result:

var gettextParser = require('gettext-parser');

var po = 'msgid ""\n\
msgstr ""\n\
"Project-Id-Version: \n"\n\
"Report-Msgid-Bugs-To: \n"\n\
"POT-Creation-Date: 2015-08-21 07:05+0000\n"\n\
"PO-Revision-Date: 2015-08-19 13:49+0600\n"\n\
"Language-Team: LANGUAGE <ll@li.org>\n"\n\
"Language: cs_CZ\n"\n\
"MIME-Version: 1.0\n"\n\
"Content-Type: text/plain; charset=utf-8\n"\n\
"Content-Transfer-Encoding: 8bit\n"\n\
"Last-Translator: \n"\n\
"X-Generator: Poedit 1.8.4\n"\n\
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"\n\
\n\
#: App/View/modules/MovementCard/index.js:5\n\
msgcntx "MovementCard"\n\
msgid "Укажите на карте остановку, на которой вы садитесь в транспорт ..."\n\
msgstr "Označte na mapě zastávku, na které nastupujete do dopravního prostředku …"'

console.log(gettextParser.po.compile(gettextParser.po.parse(po)).toString());

print:

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-08-21 07:05+0000\n"
"PO-Revision-Date: 2015-08-19 13:49+0600\n"
"Language-Team: LANGUAGE <ll@li.org>\n"
"Language: cs_CZ\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"X-Generator: Poedit 1.8.4\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"

msgid "Укажите на карте остановку, на которой вы садитесь в транспорт ..."
msgstr "Označte na mapě zastávku, na které nastupujete do dopravního prostředku …"

msgcntx disappeared.

Comment #: App/View/modules/MovementCard/index.js:5 disappeared the same.

andris9 commented 9 years ago

You are using msgcntx in your example PO while it should be msgctxt instead. If you use msgctxt then the current code already works.