Skip to content

Commit 86055ee

Browse files
committed
Move translations source path to config
1 parent 8eec135 commit 86055ee

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

web/pandas/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ roadmap:
207207
translations:
208208
url: https://github.com/Scientific-Python-Translations/pandas-translations/archive/refs/heads/main.tar.gz
209209
folder: translations
210+
source_path: pandas-translations-main/web/pandas/
210211
default_language: 'en'
211212
ignore:
212213
- docs/

web/pandas_web.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,26 +480,24 @@ def get_languages(source_path: str):
480480
"""
481481
Get the list of languages available in the translations directory.
482482
"""
483-
languages_path = f"{source_path}/pandas-translations-main/web/pandas/"
484-
en_path = f"{languages_path}/en/"
483+
en_path = f"{source_path}/en/"
485484
if os.path.exists(en_path):
486485
shutil.rmtree(en_path)
487486

488-
paths = os.listdir(languages_path)
489-
return [path for path in paths if os.path.isdir(f"{languages_path}/{path}")]
487+
paths = os.listdir(source_path)
488+
return [path for path in paths if os.path.isdir(f"{source_path}/{path}")]
490489

491490

492491
def copy_translations(source_path: str, target_path: str, languages: list[str]):
493492
"""
494493
Copy the translations to the appropriate directory.
495494
"""
496-
languages_path = f"{source_path}/pandas-translations-main/web/pandas/"
497495
for lang in languages:
498496
cmds = [
499497
"rsync",
500498
"-av",
501499
"--delete",
502-
f"{languages_path}/{lang}/",
500+
f"{source_path}/{lang}/",
503501
f"{target_path}/{lang}/",
504502
]
505503
p = Popen(cmds, stdout=PIPE, stderr=PIPE)
@@ -527,9 +525,14 @@ def main(
527525
translations_path = os.path.join(base_folder, f"{config['translations']['folder']}")
528526

529527
sys.stderr.write("Downloading and extracting translations...\n")
530-
download_and_extract_translations(config["translations"]["url"], translations_path)
528+
translations_source_path = os.path.join(
529+
translations_path, config["translations"]["source_path"]
530+
)
531+
download_and_extract_translations(
532+
config["translations"]["url"], translations_source_path
533+
)
531534

532-
translated_languages = get_languages(translations_path)
535+
translated_languages = get_languages(translations_source_path)
533536
default_language = config["translations"]["default_language"]
534537
languages = [default_language] + translated_languages
535538

0 commit comments

Comments
 (0)