Skip to content

Commit 2914ea5

Browse files
authored
refactor: Localize more contents in templates
PR-321: #321
1 parent 9219ed4 commit 2914ea5

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Context:
1919
{{ log.debug("Rendering children of " + obj.path) }}
2020
{% endblock logs %}
2121

22+
{% import "language.html.jinja" as lang with context %}
23+
{#- Language module providing the `t` translation method. -#}
24+
2225
<div class="doc doc-children">
2326

2427
{% if root_members %}
@@ -45,7 +48,7 @@ Context:
4548
) %}
4649
{% if attributes %}
4750
{% if config.show_category_heading %}
48-
{% filter heading(heading_level, id=html_id ~ "-attributes", skip_inventory=config.skip_local_inventory) %}Attributes{% endfilter %}
51+
{% filter heading(heading_level, id=html_id ~ "-attributes", skip_inventory=config.skip_local_inventory) %}{{ lang.t("Attributes") }}{% endfilter %}
4952
{% endif %}
5053
{% with heading_level = heading_level + extra_level %}
5154
{% for attribute in attributes|order_members(config.members_order, members_list) %}
@@ -65,7 +68,7 @@ Context:
6568
) %}
6669
{% if type_aliases %}
6770
{% if config.show_category_heading %}
68-
{% filter heading(heading_level, id=html_id ~ "-type_aliases") %}Type Aliases{% endfilter %}
71+
{% filter heading(heading_level, id=html_id ~ "-type_aliases") %}{{ lang.t("Type Aliases") }}{% endfilter %}
6972
{% endif %}
7073
{% with heading_level = heading_level + extra_level %}
7174
{% for type_alias in type_aliases|order_members(config.members_order, members_list) %}
@@ -85,7 +88,7 @@ Context:
8588
) %}
8689
{% if classes %}
8790
{% if config.show_category_heading %}
88-
{% filter heading(heading_level, id=html_id ~ "-classes", skip_inventory=config.skip_local_inventory) %}Classes{% endfilter %}
91+
{% filter heading(heading_level, id=html_id ~ "-classes", skip_inventory=config.skip_local_inventory) %}{{ lang.t("Classes") }}{% endfilter %}
8992
{% endif %}
9093
{% with heading_level = heading_level + extra_level %}
9194
{% for class in classes|order_members(config.members_order, members_list) %}
@@ -105,7 +108,7 @@ Context:
105108
) %}
106109
{% if functions %}
107110
{% if config.show_category_heading %}
108-
{% filter heading(heading_level, id=html_id ~ "-functions", skip_inventory=config.skip_local_inventory) %}Functions{% endfilter %}
111+
{% filter heading(heading_level, id=html_id ~ "-functions", skip_inventory=config.skip_local_inventory) %}{{ lang.t("Functions") }}{% endfilter %}
109112
{% endif %}
110113
{% with heading_level = heading_level + extra_level %}
111114
{% for function in functions|order_members(config.members_order, members_list) %}
@@ -128,7 +131,7 @@ Context:
128131
) %}
129132
{% if modules %}
130133
{% if config.show_category_heading %}
131-
{% filter heading(heading_level, id=html_id ~ "-modules", skip_inventory=config.skip_local_inventory) %}Modules{% endfilter %}
134+
{% filter heading(heading_level, id=html_id ~ "-modules", skip_inventory=config.skip_local_inventory) %}{{ lang.t("Modules") }}{% endfilter %}
132135
{% endif %}
133136
{% with heading_level = heading_level + extra_level %}
134137
{% for module in modules|order_members("alphabetical", members_list) %}

src/mkdocstrings_handlers/python/templates/material/_base/class.html.jinja

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Context:
1717
{{ log.debug("Rendering " + class.path) }}
1818
{% endblock logs %}
1919

20+
{% import "language.html.jinja" as lang with context %}
21+
{#- Language module providing the `t` translation method. -#}
22+
2023
<div class="doc doc-object doc-class">
2124
{% with obj = class, html_id = class.path, all_members = class.all_members %}
2225

@@ -246,7 +249,7 @@ Context:
246249
{% if "__init__" in all_members and all_members["__init__"].source %}
247250
{% with init = all_members["__init__"] %}
248251
<details class="mkdocstrings-source">
249-
<summary>Source code in <code>
252+
<summary>{{ lang.t("Source code in") }} <code>
250253
{%- if init.relative_filepath.is_absolute() -%}
251254
{{ init.relative_package_filepath }}
252255
{%- else -%}
@@ -259,7 +262,7 @@ Context:
259262
{% endif %}
260263
{% elif class.source %}
261264
<details class="mkdocstrings-source">
262-
<summary>Source code in <code>
265+
<summary>{{ lang.t("Source code in") }} <code>
263266
{%- if class.relative_filepath.is_absolute() -%}
264267
{{ class.relative_package_filepath }}
265268
{%- else -%}

src/mkdocstrings_handlers/python/templates/material/_base/docstring/attributes.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Context:
9393
<p>
9494
{% if attribute.annotation %}
9595
<span class="doc-attribute-annotation">
96-
<b>TYPE:</b>
96+
<b>{{ lang.t("TYPE:") }}</b>
9797
{% with expression = attribute.annotation %}
9898
<code>{% include "expression.html.jinja" with context %}</code>
9999
{% endwith %}

src/mkdocstrings_handlers/python/templates/material/_base/languages/en.html.jinja

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
{% macro t(key) %}{{ {
1111
"ATTRIBUTE": "ATTRIBUTE",
12+
"Attributes": "Attributes",
1213
"Attributes:": "Attributes:",
1314
"BOUND:": "BOUND:",
1415
"Bound or Constraints": "Bound or Constraints",
16+
"Classes": "Classes",
1517
"Classes:": "Classes:",
1618
"Class Type Parameters:": "Class Type Parameters:",
1719
"CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
@@ -23,12 +25,14 @@
2325
"DESCRIPTION": "DESCRIPTION",
2426
"Description": "Description",
2527
"Examples:": "Examples:",
28+
"Functions": "Functions",
2629
"Functions:": "Functions:",
2730
"FUNCTION": "FUNCTION",
2831
"Init Type Parameters:": "Init Type Parameters:",
2932
"INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
3033
"Methods:": "Methods:",
3134
"METHOD": "METHOD",
35+
"Modules": "Modules",
3236
"Modules:": "Modules:",
3337
"MODULE": "MODULE",
3438
"Name": "Name",
@@ -45,6 +49,7 @@
4549
"Source code in": "Source code in",
4650
"TYPE:": "TYPE:",
4751
"Type": "Type",
52+
"Type Aliases": "Type Aliases",
4853
"Type Aliases:": "Type Aliases:",
4954
"TYPE ALIAS": "TYPE ALIAS",
5055
"Type Parameters:": "Type Parameters:",

src/mkdocstrings_handlers/python/templates/material/_base/languages/ja.html.jinja

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
{% macro t(key) %}{{ {
1111
"ATTRIBUTE": "属性",
12+
"Attributes": "属性",
1213
"Attributes:": "属性:",
1314
"BOUND:": "境界:",
1415
"Bound or Constraints": "境界や制約",
16+
"Classes": "クラス",
1517
"Classes:": "クラス:",
1618
"Class Type Parameters:": "Class Type Parameters:",
1719
"CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
@@ -23,12 +25,14 @@
2325
"DESCRIPTION": "デスクリプション",
2426
"Description": "デスクリプション",
2527
"Examples:": "例:",
28+
"Functions": "関数",
2629
"Functions:": "関数:",
2730
"FUNCTION": "関数",
2831
"Init Type Parameters:": "Init Type Parameters:",
2932
"INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
3033
"Methods:": "メソッド:",
3134
"METHOD": "メソッド",
35+
"Modules": "モジュール",
3236
"Modules:": "モジュール:",
3337
"MODULE": "モジュール",
3438
"Name": "名前",
@@ -45,6 +49,7 @@
4549
"Source code in": "ソースコード位置:",
4650
"TYPE:": "タイプ:",
4751
"Type": "タイプ",
52+
"Type Aliases": "型エイリアス",
4853
"Type Aliases:": "型エイリアス:",
4954
"TYPE ALIAS": "型エイリアス",
5055
"Type Parameters:": "型パラメータ:",

src/mkdocstrings_handlers/python/templates/material/_base/languages/zh.html.jinja

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
{% macro t(key) %}{{ {
1111
"ATTRIBUTE": "属性",
12+
"Attributes": "属性",
1213
"Attributes:": "属性:",
1314
"BOUND:": "边界:",
1415
"Bound or Constraints": "边界或约束",
16+
"Classes": "类",
1517
"Classes:": "类:",
1618
"Class Type Parameters:": "Class Type Parameters:",
1719
"CLASS TYPE PARAMETER": "CLASS TYPE PARAMETER",
@@ -23,12 +25,14 @@
2325
"DESCRIPTION": "描述",
2426
"Description": "描述",
2527
"Examples:": "示例:",
28+
"Functions": "函数",
2629
"Functions:": "函数:",
2730
"FUNCTION": "函数",
2831
"Init Type Parameters:": "Init Type Parameters:",
2932
"INIT TYPE PARAMETER": "INIT TYPE PARAMETER",
3033
"Methods:": "方法:",
3134
"METHOD": "方法",
35+
"Modules": "模块",
3236
"Modules:": "模块:",
3337
"MODULE": "模块",
3438
"Name": "名称",
@@ -45,6 +49,7 @@
4549
"Source code in": "源代码位于:",
4650
"TYPE:": "类型:",
4751
"Type": "类型",
52+
"Type Aliases": "类型别名",
4853
"Type Aliases:": "类型别名:",
4954
"TYPE ALIAS": "类型别名",
5055
"Type Parameters:": "类型形参:",

0 commit comments

Comments
 (0)