question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enforce the use of the trimmed option for blocktranslate

See original GitHub issue

Below 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   Spaces New lines are clearly identified. Spaces not so much.
New lines   Spaces_Missing Line Missing new lines produce an error
New lines   Spaces_Missing Spaces 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:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
thibaudcolascommented, Apr 28, 2021

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?

1reaction
lb-commented, Apr 1, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Translation | Django documentation
Another feature {% blocktranslate %} supports is the trimmed option. This option will remove newline characters from the beginning and the end of...
Read more >
How to make spaces and indentation insignificant in Django ...
Another feature {% blocktrans %} supports is the trimmed option. This option will remove newline characters from the beginning and the end ......
Read more >
blocktrans in django templates should use 'trimmed' option
Django templates support 'trimmed' option. it can remove newline characters from the beginning and the end of the content of the ...
Read more >
BENCHMAN VMC-2000 Machining Center User's Guide
Setting the Hardware Address . ... To achieve higher spindle speeds, the VMC-2500 uses a 1 hp high ... Soft limits are not...
Read more >
Django internationalization (i18n) tutorial - Localizely
We should not manually implement plural conditions in Python code, since plurals have different rules among different languages. Use plural ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found