Enforce the use of the trimmed option for blocktranslate
See original GitHub issueBelow is the original issue which has been taken care of in #8226.
What remain is to enforce the use of the block option so we don’t end up back to square one.
Is your proposal related to a problem?
In most (all?) cases, new lines and spaces are irrelevant (they are ignored in HTML), but they aren’t handled consistently in Transifex.
As a result, it lowers the confidence of translators that they are doing the right thing.
Describe the solution you’d like
No leading or trailing whitespace characters (new lines, tabs and spaces) in source translation strings. This was done in #5633 by setting the trimmed
option on blocktrans
blocks, but we need some linting option to make sure it is enforced in the future.
Additional context
Screenshots | Notes |
---|---|
New lines are clearly identified. Spaces not so much. | |
Missing new lines produce an error | |
Missing new spaces do not produce any error or warning |
Next Steps
The proposed solution was discussed and agreed in Core Team meetings, however no changes will be made to the codebase until we have a way to enforce the style.
Therefore, the next step is to work on some sort of linter (run as either an actual linter or a test in the test suite) to enforce the use of the trimmed
option for blocktrans
.
Only then we can open a PR to fix the existing source strings.
WARNING
Removing whitespace would make old translation strings invalid. Therefore, we should wait for the beginning of a release cycle (maybe a week or two after a new release) and notify translators immediately in order to give them as much time as possible to go through the now broken/missing translations.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
I’ve been working on a linter for Django Templates (https://github.com/thibaudcolas/curlylint), I think it would be pretty straightforward to add a rule to it that checks
trimmed
is always used with blocktrans. Wagtail already uses the pre-existing linter I based mine on: https://github.com/wagtail/wagtail/blob/f8299885aa916becb9109c881f3ab28408af794e/.circleci/config.yml#L25, so switching over should be very straightforward.Otherwise – wouldn’t it be even simpler for us to have our custom
blocktrans_trimmed
block, and move all blocks over?A few updates.
I recommend we revise this issue to cover the linting enforcement and filling any gaps that are picked up in that process.