mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-06-06 22:15:22 -04:00
Use the translations for language names from the iso-codes project
This commit is contained in:
+16
-1
@@ -1,10 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from setup import download_securely
|
||||
import fnmatch
|
||||
import os
|
||||
import shutil, time
|
||||
import zipfile
|
||||
from io import BytesIO
|
||||
|
||||
from setup import download_securely
|
||||
|
||||
|
||||
class ISOData:
|
||||
URL = 'https://salsa.debian.org/iso-codes-team/iso-codes/-/archive/main/iso-codes-main.zip'
|
||||
@@ -23,5 +27,16 @@ class ISOData:
|
||||
with zf.open(f'iso-codes-main/data/{name}') as f:
|
||||
return f.read()
|
||||
|
||||
def extract_po_files(self, name: str, output_dir: str) -> None:
|
||||
name = name.split('.', 1)[0]
|
||||
pat = f'iso-codes-main/{name}/*.po'
|
||||
with zipfile.ZipFile(self.zip_data) as zf:
|
||||
for name in fnmatch.filter(zf.namelist(), pat):
|
||||
dest = os.path.join(output_dir, name.split('/')[-1])
|
||||
zi = zf.getinfo(name)
|
||||
with zf.open(zi) as src, open(dest, 'wb') as d:
|
||||
shutil.copyfileobj(src, d)
|
||||
date_time = time.mktime(zi.date_time + (0, 0, -1))
|
||||
os.utime(dest, (date_time, date_time))
|
||||
|
||||
iso_data = ISOData()
|
||||
|
||||
Reference in New Issue
Block a user