0

I have recently started i18n my django project, and I have .po files. However in my templates, I have done things suboptimaly. I have just copied the local variable name for something that appears a lot. So I have near-duplicates in .po file, like %(num)s messages and %(num_messages)s messages and %d messages. I should have written them all the same way, so that there is only one translation.

Is there any way/software that can read my .po file and tell me these messages that I should merge?

Amandasaurus
  • 58,203
  • 71
  • 188
  • 248

1 Answers1

1

I am afraid I do not know any tool that has such functionality built in. What you could try to do instead is use your favourite reg-ex aware text editor and Excel:

1) Paste the content of your po file into column A of a new spreadsheet

2) Open the content of your po file in your favourite reg-ex aware text editor and try to reduce all long variables to their shortest variant: in your example you could replace %\([^\)]+\)s by %d. Or replace all variables by some string that does not occur anywhere else, like RORYS_PLACEHOLDER.

3) Paste the content of your po file with normalized or no more variables into column B of the spreadsheet.

4) Set a filter for strings that start with msgid, then let Excel highlight duplicate values in column B. (Home > Conditional Formatting > Highlight Cell Rules > Duplicate Values in Excel 2013)

Of course your po file may be too complex for this approach, but it is worth a try.

Jenszcz
  • 547
  • 3
  • 9