Skip to content

Commit b391f69

Browse files
committed
Update translations scripts
1 parent 54ccc6d commit b391f69

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

web/pandas/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,5 @@ translations:
208208
url: https://github.com/Scientific-Python-Translations/pandas-translations/archive/refs/heads/main.tar.gz
209209
folder: translations
210210
default_language: 'en'
211-
default_prefix: ''
212211
ignore:
213212
- docs/

web/pandas/static/js/language_switcher.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
window.addEventListener("DOMContentLoaded", function() {
22
var BASE_URL = location.protocol + "//" + location.hostname + ":" + location.port
3-
console.log("HOSTANME", BASE_URL);
43
var CURRENT_LANGUAGE = document.documentElement.lang;
4+
var PATHNAME = location.pathname.replace('/' + CURRENT_LANGUAGE + '/', '')
55
var languages = JSON.parse(document.getElementById("languages").getAttribute('data-lang').replace(/'/g, '"'));
6-
76
const language_names = {
87
'en': 'English',
98
'es': 'Español',
@@ -36,13 +35,12 @@ window.addEventListener("DOMContentLoaded", function() {
3635
dropdownItem.textContent = language_names[i] || i.toUpperCase();
3736
dropdownItem.setAttribute("href", "#");
3837
dropdownItem.addEventListener("click", function() {
39-
if (i == 'en') {
40-
URL_LANGUAGE = '/';
41-
} else {
42-
URL_LANGUAGE = '/' + i;
43-
}
44-
45-
var PATHNAME = location.pathname.replace('/' + CURRENT_LANGUAGE + '/', '')
38+
if (i == 'en') {
39+
URL_LANGUAGE = '';
40+
} else {
41+
URL_LANGUAGE = '/' + i;
42+
}
43+
var PATHNAME = location.pathname.replace('/' + CURRENT_LANGUAGE + '/', '/')
4644
var newUrl = BASE_URL + URL_LANGUAGE + PATHNAME
4745
window.location.href = newUrl;
4846
});

web/pandas_web.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ def navbar_add_info(context):
8787
``has_subitems`` that tells which one of them every element is. It
8888
also adds a ``slug`` field to be used as a CSS id.
8989
"""
90-
lang = context["language"]
91-
default_language = context["translations"]["default_language"]
92-
default_prefix = context["translations"]["default_prefix"]
93-
prefix = f"{lang}/" if lang != default_language else default_prefix
90+
ignore = context["translations"]["ignore"]
9491
for i, item in enumerate(context["navbar"]):
92+
if item["target"] in ignore:
93+
item["target"] = "/" + item["target"]
94+
9595
context["navbar"][i] = dict(
9696
item,
9797
has_subitems=isinstance(item["target"], list),
98-
slug=prefix + (item["name"].replace(" ", "-").lower()),
98+
slug=item["name"].replace(" ", "-").lower(),
9999
)
100100
return context
101101

@@ -414,7 +414,7 @@ def get_context(config_fname: str, **kwargs):
414414
context["source_path"] = os.path.dirname(config_fname)
415415
context.update(kwargs)
416416
context["languages"] = context.get("languages", ["en"])
417-
context["language"] = context.get("language", "en")
417+
context["selected_language"] = context.get("language", "en")
418418

419419
preprocessors = (
420420
get_callable(context_prep)

0 commit comments

Comments
 (0)