Skip to content

Commit 9e13d89

Browse files
committed
Fixes #20766: Prevent translation of code/commands in error templates
Use blocktrans 'with' clause to pass literal code/commands as variables, preventing them from being translated. This fixes issues where commands like 'manage.py collectstatic' were incorrectly translated to nonsensical strings in non-English locales. Updated templates: - media_failure.html: manage.py collectstatic - programming_error.html: python3 manage.py migrate, SELECT VERSION() - import_error.html: requirements.txt, local_requirements.txt, pip freeze
1 parent 4961b0d commit 9e13d89

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

netbox/templates/exceptions/import_error.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
<p>
99
<i class="mdi mdi-alert"></i>
1010
<strong>{% trans "Missing required packages" %}.</strong>
11-
{% blocktrans trimmed %}
11+
{% blocktrans trimmed with req_file="requirements.txt" local_req_file="local_requirements.txt" pip_cmd="pip freeze" %}
1212
This installation of NetBox might be missing one or more required Python packages. These packages are listed in
13-
<code>requirements.txt</code> and <code>local_requirements.txt</code>, and are normally installed as part of the
14-
installation or upgrade process. To verify installed packages, run <code>pip freeze</code> from the console and
13+
<code>{{ req_file }}</code> and <code>{{ local_req_file }}</code>, and are normally installed as part of the
14+
installation or upgrade process. To verify installed packages, run <code>{{ pip_cmd }}</code> from the console and
1515
compare the output to the list of required packages.
1616
{% endblocktrans %}
1717
</p>

netbox/templates/exceptions/programming_error.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
<p>
99
<i class="mdi mdi-alert"></i>
1010
<strong>{% trans "Database migrations missing" %}.</strong>
11-
{% blocktrans trimmed %}
11+
{% blocktrans trimmed with command="python3 manage.py migrate" %}
1212
When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You
13-
can run migrations manually by executing <code>python3 manage.py migrate</code> from the command line.
13+
can run migrations manually by executing <code>{{ command }}</code> from the command line.
1414
{% endblocktrans %}
1515
</p>
1616
<p>
1717
<i class="mdi mdi-alert"></i>
1818
<strong>{% trans "Unsupported PostgreSQL version" %}.</strong>
19-
{% blocktrans trimmed %}
19+
{% blocktrans trimmed with sql_query="SELECT VERSION()" %}
2020
Ensure that PostgreSQL version 14 or later is in use. You can check this by connecting to the database using
21-
NetBox's credentials and issuing a query for <code>SELECT VERSION()</code>.
21+
NetBox's credentials and issuing a query for <code>{{ sql_query }}</code>.
2222
{% endblocktrans %}
2323
</p>
2424
{% endblock message %}

netbox/templates/media_failure.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ <h3>
2626
<p>{% trans "Check the following" %}:</p>
2727
<ul>
2828
<li class="tip">
29-
{% blocktrans trimmed %}
30-
<code>manage.py collectstatic</code> was run during the most recent upgrade. This installs the most
29+
{% blocktrans trimmed with command="manage.py collectstatic" %}
30+
<code>{{ command }}</code> was run during the most recent upgrade. This installs the most
3131
recent iteration of each static file into the static root path.
3232
{% endblocktrans %}
3333
</li>

0 commit comments

Comments
 (0)