Appsilon / shiny.i18n

Shiny applications internationalization made easy
https://appsilon.github.io/shiny.i18n/
Other
168 stars 38 forks source link

extract_key_expressions regexp appears to not being able to handle parantheses. #57

Closed fkroener closed 3 years ago

fkroener commented 3 years ago

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("").

dokato commented 3 years ago

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

fkroener commented 3 years ago

@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})",""
dokato commented 3 years ago

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

fkroener commented 3 years ago

Sure, I can gladly test this.

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

dokato commented 3 years ago

Something like:

devtools::install_github("Appsilon/fix-preproc")
fkroener commented 3 years ago

@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. :-)

dokato commented 3 years ago

Great, thanks for spotting this problem!