Translation strings cannot have any special-characters used in regular expressions
Closed this issue · 0 comments
clemenskol commented
Describe the bug
If the input string for a translation contains a character with special meaning in regular expressions (e.g., [
), this usually breaks the import of the translations. If the string happens to be a valid regular expression, it breaks matching of the text to translate.
To Reproduce
Steps to reproduce the behavior:
- Create a translation containing
[
inside the text - Load the translations
- Loader crashes
Steps to reproduce the behavior (alternative):
- Create a translation containing a valid regexp expression
[a]
inside the text - Load translations
- Attempt to translate a string
- Translation lookup fails, returning un-translated string
Environment
- OS: [e.g. Linux / Windows / macOS]: any
- pydantic-i18n version: current
main
(e.g., 0.4.0)
To know the pydantic-i18n version use:
python -c "import pydantic_i18n; print(pydantic_i18n.__version__)"
- Python version:
any (e.g., 3.11.8)
Additional context
Will submit a pull-request shortly