Appsilon/shiny.i18n

extract_key_expressions regexp appears to not being able to handle parantheses.

Closed this issue · 7 comments

I use shiny.i18n to create multilang PDFs using knitr and LaTeX.

To extract the translation keys I use preproc::create_translation_file().

When looking at the generated file, strings which include parentheses ")" are cut off directly after the closing parenthesis.

My guess is that some regexp in extract_key_expressions() just checks for the first closing parenthesis it encounters, instead of balancing them.

In my case actually it would suffice to ignore parentheses inside quotation marks, since all my translations look like this i18n$t("").

Thanks @fkroener for reporting that. Could you give a specific example of the string that gets misread?

@dokato sure:

i18n$t("In this document we will first give you a brief overview over the sample composition (section \\ref{sec:composition}), followed by ...")

results in

en,de
"In this document we will first give you a brief overview over the sample composition (section \\ref{sec:composition})",""

Thanks @fkroener . Could you test from fix-preproc and see if this works any better now?

Sure, I can gladly test this.

I just need a pointer how to replace that function locally.

Something like:

devtools::install_github("Appsilon/fix-preproc")

@dokato according to my tests #58 fixes this issue.

Thanks for your instant reply and fix. I should've reported earlier than adding some \parentheses{} command to my LaTeX code. :-)

Great, thanks for spotting this problem!