potools
potools copied to clipboard
R source locations can contain duplicates
Just observed in data.table https://github.com/Rdatatable/data.table/commit/f9c2824b2ce1820c04713e10ba8d4d482cdc2e91
potools::po_extract(custom_translation_functions = list(R = c('catf:fmt|1', 'stopf:fmt|1', 'messagef:fmt|1', 'warningf:fmt|1')))
-#: AllS4.R:2
+#: AllS4.R:2 AllS4.R:2
#, c-format
msgid "data.table package loaded. When developing don't load package"
msgstr ""
-#: IDateTime.R:107
+#: IDateTime.R:107 IDateTime.R:107
#, c-format
msgid "binary + is not defined for \"IDate\" objects"
msgstr ""
-#: IDateTime.R:114
+#: IDateTime.R:114 IDateTime.R:114
#, c-format
msgid "can only subtract from \"IDate\" objects"
msgstr ""
-#: IDateTime.R:119
+#: IDateTime.R:119 IDateTime.R:119
It looks like this is partially due to the duplicate inclusion of stopf:fmt|1 since stopf is already translated like that, but it implies the need for a fix at both ends:
stopf("a"); stopf("b")
Would also presumably generate duplicates.
So we should fix this by dropping duplicates from custom_translation_functions up front (with warning()? message()? just in verbose=TRUE?), while also dropping organic dupes.
Another thing to look out for: if custom_translation_functions lists the same function twice, instead of as intended with one entry & comma-separated arguments, we get a combinatorial explosion of entries, e.g.
c('ngettext_no_ordinal:msg1|2', 'ngettext_no_ordinal:msg2|3')
# vs what is the "canonical" format:
'ngettext_no_ordinal:msg1|2,msg2|3'