Is the #: (file, line number) line in a wordpress .po file necessary

WordPress translation calls for a [theme name].po file, in which are your key value mapping for your translations, such as:

#: ../single-con_book_reviews.php:197
msgid "Author: "
msgstr ""

However, putting the file and line number of every occurrence of the word “Author: ” is arduous and silly. Is it required? Or can I just use the saner:

Read More
msgid "Author: "
msgstr ""

OR, am I just missing something here?

See, the problem with putting the file & line number is it would discourage you from ever writing any new or removing any old code. If you add a line at the beginning of a 1200 line php file you’ve suddenly ruined all of your translation mappings. Surely these are more of just comments… right?

Related posts

Leave a Reply

2 comments

  1. Its a comment and its not required. Its there mostly for historical reason, where it were more difficult to find out, where a specific string occurs. Additional this is usually (then and now) added automatically by a parser, that creates the translate-templates right from the source, and not manually by hand.

  2. All lines starting with # are optionals in .po files. Still, this does not mean that they are unnecessary or useless.

    For example the lines with #: do specify location of the strings in source code, something very useful when you try to solve internationalization issues.

    Also, I would not recommend you to write your own parser for .po files because even it this format may seam simple to read, it is not so simple to parse – it has lots of features that are not obvious. You will end up wasting time on improving your partial parser. Instead go for an existing one.