PHP gettext: not all strings becomes translated

2019-06-17 20:57发布

问题:

I have these two adjacent lines of code:

<td><?php echo __('Product', 'wpsc'); ?>:</td>
<td><?php echo __('Quantity', 'wpsc'); ?>:</td>

And these translations in the .po file

msgid "Product"   // Translates
msgstr "Produkt"

msgid "Quantity"  // does not translate
msgstr "Antall"

One string shows up translated on the webpage, the other not. And, yes I have tried to change the translation of the first one and confirmed that the translation changes accordingly, so I know the server reads the correct .mo file. This is on an up to date Ubuntu server. Any idea about what may be the problem?

回答1:

As Mark mentioned in his comment, check for the line #, fuzzy above the Quantity definition. gettext won't translate fuzzy strings.

(I'm adding this as an answer so it can get up voted, so that this question gets out of the unanswered queue)



标签: php gettext