Commit 2051a89
Add missing translated strings (#4789)
(This contribution was sponsored by
[DigitalHub.sh](https://digitalhub.sh/))
Fixes #4753
I've split this PR over several commits which are mostly independent of
each other. I'm happy to open separate PRs if you think that'd be easier
to review.
## Explanations of the separate commits
### Mark missing strings for translation
After a few unsuccessful attempts at scripting the identification of
untranslated strings, I ended up reviewing all Python files manually.
The command I used to identify the relevant files was:
```
git ls-files -z '**.py' ':!**/migrations/*.py' ':!**/urls.py' ':!hypha/settings/*.py' ':!docs/*' ':!**/test*.py' | find -files0-from - -not -empty
```
(That's all Python files, but excluding stuff like migrations, settings,
... (and empty files))
This change should have no impact for a site running the English version
of Hypha.
### Add missing strings for translations (templates)
Similar to the previous commit, I ended up reviewing all templates
manually (`git ls-files '*.html'`), adding `{% trans %}`, `{% blocktrans
%}`, or `_(...)` where needed.
Again, this change should have no impact.
### Add trimmed option to blocktranslate
This removes irrelevant whitespace in source strings, making it a bit
nicer.
I used `git grep blocktrans | grep -vw trimmed | grep -v endblocktrans`
to identify uses of `{% blocktrans %}` without the `trimmed` argument,
excluding lines that also included `{% endblocktrans %}` on the same
line.
This is technically a breaking change, but it only introduces whitespace
changes to HTML templates, which is irrelevant.
### Use `{% blocktranslate trimmed %}` to break down long lines
This one just makes templates a little bit more readable as it breaks
very long lines into more manageable pieces.
Again, it can introduce whitespace changes to the HTML, but should not
have any effect to the source strings.
### Added `verbose_name` and `verbose_name_plural` to all models
Some models already has a translated `verbose_name` or
`verbose_name_plural`, but it was inconsistent (and quite rare). This
change adds these attributes to all models.
I used `git ls-files '**/models/*.py'` and ` git ls-files
'**/models.py'` to find all models, then went through the files manually
to add the missing `verbose_name` and `verbose_name_plural`.
I decided to omit the plural form for model classes inheriting from
`BaseSiteSettings` since it didn't seem to make sense.
I also opted to use lower case (like `_("foo bar")` for model `FooBar`)
to match Django's own default behavior, but I used `Foo Bar` in a few
instances where the model already had a `verbose_name` that used
titlecase.
## Next steps
I ran out of time to complete all my objectives and I've still got some
translation-related tasks I wanted to get to. I'm happy to open issues
for these if you think they're relevant:
* #4752 Fix missing translations in javascript files: I found about 10
instances but fixing them would require either using the [Django
javascript translation
functions,](https://docs.djangoproject.com/en/6.0/topics/i18n/translation/#internationalization-in-javascript-code)
or moving the strings to the HTML (data attributes for example).
* #4753 Add explicit `verbose_name` to all declared model fields (and
maybe form fields as well). This can probably be scripted somewhat,
ideally with a linter that would catch the introducing of future
untranslated strings.
* Review cases where `gettext` is used at the module level instead of
`gettext_lazy` as this could indicate some possible bugs (visible in a
multi-language setup where the user is not using the default language).
* Fix translations that build up a sentence word by word, as this
doesn't really work in practice. Something like `{% trans "Application"
%} {{ application_id }} {% trans "updated on" %} {{ date }} {% trans
"by" %} {{ author.name }}` should be rewritten to have the whole
sentence in a single `blocktrans`, or when not possible small words like
`by` should be given a context because they're likely to be translated
differently for different sentences.
---------
Co-authored-by: Baptiste Mispelon <baptiste.mispelon@torchbox.com>1 parent 0af41e7 commit 2051a89
179 files changed
Lines changed: 2830 additions & 883 deletions
File tree
- hypha
- addressfield
- apply
- activity
- adapters
- migrations
- templates/activity
- include
- ui
- categories
- migrations
- dashboard/templates/dashboard/includes
- determinations
- migrations
- templates/determinations
- tests
- flags
- migrations
- templates/flags
- funds
- migrations
- models
- templates
- cotton
- funds
- admin
- includes
- modals
- submissions
- partials
- templatetags
- views
- workflows
- definitions
- models
- projects
- migrations
- models
- reports
- migrations
- templates/reports
- templates/application_projects
- includes
- modals
- partials
- tests
- views
- review
- migrations
- templates/review
- includes
- stream_forms
- templates/stream_forms/includes
- todo
- migrations
- templates/todo
- translate
- users
- migrations
- templates
- elevate
- two_factor
- core
- profile
- users
- activation
- email_change
- password_reset
- wagtailusers/users
- utils
- cookieconsent
- core
- models
- home
- migrations
- templates/home/includes
- images
- migrations
- templates
- cotton
- badge
- modal
- includes
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
195 | | - | |
196 | | - | |
| 196 | + | |
| 197 | + | |
197 | 198 | | |
198 | 199 | | |
199 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
200 | 203 | | |
201 | 204 | | |
202 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
| |||
175 | 172 | | |
176 | 173 | | |
177 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| |||
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
204 | | - | |
| 205 | + | |
205 | 206 | | |
206 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
207 | 211 | | |
208 | 212 | | |
209 | 213 | | |
| |||
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
| 239 | + | |
| 240 | + | |
235 | 241 | | |
236 | 242 | | |
237 | 243 | | |
| |||
330 | 336 | | |
331 | 337 | | |
332 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
333 | 343 | | |
334 | 344 | | |
335 | 345 | | |
| |||
365 | 375 | | |
366 | 376 | | |
367 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
368 | 382 | | |
369 | 383 | | |
370 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | | - | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
0 commit comments