Skip to content

Commit 15f6196

Browse files
committed
fixed all proposed changes
1 parent dcbe5d5 commit 15f6196

File tree

4 files changed

+40
-30
lines changed

4 files changed

+40
-30
lines changed

DISCOVER/_static/languages.json

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
[
22
{
3-
"language": "en",
4-
"name": "English",
5-
"preferred": true,
6-
"url": "https://discover-cookbook.numfocus.org/2.0/en"
3+
"code": "en",
4+
"name_local": "English",
5+
"direction": "ltr"
76
},
8-
{
9-
"language": "hi",
10-
"name": "हिन्दी",
11-
"url": "https://discover-cookbook.numfocus.org/2.0/hi"
7+
{
8+
"code": "hi",
9+
"name_local": "हिन्दी",
10+
"direction": "ltr"
11+
},
12+
{
13+
"code": "es",
14+
"name_local": "Español",
15+
"direction": "ltr"
1216
},
1317
{
14-
"language": "es",
15-
"name": "Español",
16-
"url": "https://discover-cookbook.numfocus.org/2.0/es"
18+
"code": "fr",
19+
"name_local": "Français",
20+
"direction": "ltr"
1721
},
1822
{
19-
"language": "fr",
20-
"name": "Français",
21-
"url": "https://discover-cookbook.numfocus.org/2.0/fr"
23+
"code": "pt",
24+
"name_local": "Português",
25+
"direction": "ltr"
2226
},
2327
{
24-
"language": "pt",
25-
"name": "Português",
26-
"url": "https://discover-cookbook.numfocus.org/2.0/pt"
28+
"code": "ar",
29+
"name_local": "العربية",
30+
"direction": "rtl",
31+
"hidden": true
2732
}
2833
]

DISCOVER/_templates/language-switcher.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
</button>
66
<ul class="dropdown-menu" aria-labelledby="language-switcher-button">
77
{% for item in languages %}
8-
{% if item.language and item.url %}
98
<li>
10-
<a class="dropdown-item{% if current_language == item.language %}active{% endif %}"
11-
href="{{ item.url }}">
12-
{{ item.name }}
13-
9+
<a class="dropdown-item{% if current_language == item.code %}active{% endif %}"
10+
href="{{ baseurl }}/{{ current_version }}/{{ item.code }}/{{ pagename }}.html"
11+
{% if item.direction %}dir="{{ item.direction }}"{% endif %}>
12+
{{ item.name_local }}
1413
</a>
1514
</li>
16-
{% endif %}
1715
{% endfor %}
1816
</ul>
1917
</div>

DISCOVER/conf.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
version = '2.0'
1010
language = 'en'
11+
baseurl = 'https://discover-cookbook.numfocus.org'
1112

1213
import json
1314
import os
@@ -16,22 +17,28 @@
1617
language_json_path = os.path.join(os.path.dirname(__file__), '_static', 'languages.json')
1718
language_data = []
1819
if os.path.exists(language_json_path):
19-
with open(language_json_path, 'r',encoding='utf-8') as f:
20-
language_data = json.load(f)
20+
with open(language_json_path, 'r', encoding='utf-8') as f:
21+
all_languages = json.load(f)
22+
# Filter out hidden languages
23+
language_data = [lang for lang in all_languages if not lang.get('hidden', False)]
2124

25+
# Create a mapping of language codes to their localized names
2226
language_names = {}
2327
for lang in language_data:
24-
if "language" in lang and "name" in lang:
25-
language_names[lang["language"]] = lang["name"]
28+
if "code" in lang and "name_local" in lang:
29+
language_names[lang["code"]] = lang["name_local"]
2630

2731

2832
html_context = {
2933
"languages": language_data,
3034
"language_names": language_names,
3135
"current_language": language,
32-
"current_version": version
36+
"current_version": version,
37+
"baseurl": baseurl
3338
}
3439

40+
html_baseurl = baseurl
41+
3542
author = 'Community'
3643
comments_config = {'hypothesis': False, 'utterances': False}
3744
copyright = '2023'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ conda env create -f environment.yml
8484
```sh
8585
conda activate DISCOVER-Cookbook
8686
```
87-
3. Finally, to build the sphinx-build
87+
3. Finally, to build the Jupyter Book
8888
``` sh
8989
sphinx-build -b html DISCOVER/ DISCOVER/_build/html
9090
```
@@ -107,7 +107,7 @@ source .venv/bin/activate
107107
```sh
108108
pip install -r requirements.txt
109109
```
110-
4. Finally, to build the sphinx-build
110+
4. Finally, to build the Jupyter Book
111111
``` sh
112112
sphinx-build -b html DISCOVER/ DISCOVER/_build/html
113113
```

0 commit comments

Comments
 (0)