@@ -467,6 +467,7 @@ def download_and_extract_translations(url: str, dir_name: str):
467
467
"""
468
468
Download the translations from the GitHub repository.
469
469
"""
470
+ shutil .rmtree (dir_name , ignore_errors = True )
470
471
response = requests .get (url )
471
472
if response .status_code == 200 :
472
473
doc = io .BytesIO (response .content )
@@ -480,26 +481,24 @@ def get_languages(source_path: str):
480
481
"""
481
482
Get the list of languages available in the translations directory.
482
483
"""
483
- languages_path = f"{ source_path } /pandas-translations-main/web/pandas/"
484
- en_path = f"{ languages_path } /en/"
484
+ en_path = f"{ source_path } /en/"
485
485
if os .path .exists (en_path ):
486
486
shutil .rmtree (en_path )
487
487
488
- paths = os .listdir (languages_path )
489
- return [path for path in paths if os .path .isdir (f"{ languages_path } /{ path } " )]
488
+ paths = os .listdir (source_path )
489
+ return [path for path in paths if os .path .isdir (f"{ source_path } /{ path } " )]
490
490
491
491
492
492
def copy_translations (source_path : str , target_path : str , languages : list [str ]):
493
493
"""
494
494
Copy the translations to the appropriate directory.
495
495
"""
496
- languages_path = f"{ source_path } /pandas-translations-main/web/pandas/"
497
496
for lang in languages :
498
497
cmds = [
499
498
"rsync" ,
500
499
"-av" ,
501
500
"--delete" ,
502
- f"{ languages_path } /{ lang } /" ,
501
+ f"{ source_path } /{ lang } /" ,
503
502
f"{ target_path } /{ lang } /" ,
504
503
]
505
504
p = Popen (cmds , stdout = PIPE , stderr = PIPE )
@@ -527,14 +526,21 @@ def main(
527
526
translations_path = os .path .join (base_folder , f"{ config ['translations' ]['folder' ]} " )
528
527
529
528
sys .stderr .write ("Downloading and extracting translations...\n " )
530
- download_and_extract_translations (config ["translations" ]["url" ], translations_path )
529
+ translations_extract_path = translations_path
530
+ translations_source_path = os .path .join (
531
+ translations_path , config ["translations" ]["source_path" ]
532
+ )
533
+
534
+ download_and_extract_translations (
535
+ config ["translations" ]["url" ], translations_extract_path
536
+ )
531
537
532
- translated_languages = get_languages (translations_path )
538
+ translated_languages = get_languages (translations_source_path )
533
539
default_language = config ["translations" ]["default_language" ]
534
540
languages = [default_language ] + translated_languages
535
541
536
542
sys .stderr .write ("Copying translations...\n " )
537
- copy_translations (translations_path , source_path , translated_languages )
543
+ copy_translations (translations_source_path , source_path , translated_languages )
538
544
539
545
for language in languages :
540
546
sys .stderr .write (f"\n Processing language: { language } ...\n \n " )
@@ -596,7 +602,6 @@ def main(
596
602
shutil .copy (
597
603
os .path .join (source_path , fname ), os .path .join (target_path , dirname )
598
604
)
599
- return 0
600
605
601
606
602
607
if __name__ == "__main__" :
0 commit comments