openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Update `i18n` warn regex and escape relevant files

Open rebecca-shoptaw opened this issue 8 months ago • 0 comments

Sub-task of #9486.

Fix. Adjusts the i18n WARN syntax to only flag text wrapped in $(' ') or $(" "), the chosen syntax for intentionally untranslated text. This way, we avoid flagging Python insertions wrapped in parentheses, and can remove a number of files from the exclude list.

Technical

Also involved adding the skip_directive to escape a few last Python lines still accidentally caught by the script.

Testing

  1. Add a new line of Python into an HTML file wrapping it in the following: $( )
  2. Run the script with pre-commit run detect-missing-i18n --all-files, you should not see a warning appear
  3. Change existing i18n syntax or add a new line you think shouldn't be translated, using the preferred warning syntax, i.e. $('https://www.google.com')
  4. Run the script again, the script should still pass but a warning will appear

Screenshot

Stakeholders

@mekarpeles @pidgezero-one

rebecca-shoptaw avatar Jun 28 '24 19:06 rebecca-shoptaw