luanti-org / luanti-org/modtools
mod_translation_updater.py: Parses escape codes in .tr files incorrectly
- Dominant language
- Python
- Stars
- 17
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
### Minetest version
```true
Minetest 5.9.0-dev
```
### Summary
The script uses regex to parse translation lines, which is incorrect. Take the following example:
```
Something@@= Something@@
```
The script will ignore this line as it thinks the `@` is escaping the `=`, but it is actually adding `@`. Another issue: **the script ignores invalid lines without warning!**
The script also assumes that a translation is only ever on one line. This is not the case, given `@\n`:
```
A @n newline = Une @
nouvelle ligne
```
### Steps to reproduce
I've written my own Python .tr file parser with unit tests [here](https://github.com/minetest/contentdb/pull/517). Unit tests should be added to mod_translation_updater.py, it's unacceptable to have a parser without tests.
My implemention throws a lot of information away (ie: comments) so couldn't be taken directly, but inspiration can be taken from the approach (which is based on the .cpp code)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with mod_translation_updater.py and inspect its current regex-based parsing of .tr files. Add unit tests for escaped @ characters, @n-based multiline translations, and invalid lines that should produce warnings, using the linked parser approach for comparison. Done means these cases parse correctly and the new tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- localization, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100