Spaces:
Running on Zero
Running on Zero
feat: integrate Cloudflare R2 Quran translations, add translation endpoints and edge caching
3c6e2f1 Download scripts/make_dart_maps.py from sahihislam/superadmin: direct link, hf CLI and curl.
- Browser
- Download file 911 Bytes
-
https://huggingface.co/spaces/sahihislam/superadmin/resolve/main/scripts/make_dart_maps.py
- Command line
-
hf download hf://spaces/sahihislam/superadmin/scripts/make_dart_maps.py
-
curl -L -o make_dart_maps.py https://huggingface.co/spaces/sahihislam/superadmin/resolve/main/scripts/make_dart_maps.py
911 Bytes
| import json | |
| with open("BACKEND/scripts/archive_surah_audio_mappings.json", "r", encoding="utf-8") as f: | |
| mappings = json.load(f) | |
| def generate_dart_map(map_name, data): | |
| lines = [f" static const Map<int, String> {map_name} = {{"] | |
| for i in range(1, 115): | |
| val = data.get(str(i), "").replace('"', '\\"') | |
| lines.append(f' {i}: "{val}",') | |
| lines.append(" };") | |
| return "\n".join(lines) | |
| code_maududi_ur = generate_dart_map("kMaududiUrduFilenames", mappings["Maududi_Urdu"]) | |
| code_maududi_en = generate_dart_map("kMaududiEnglishFilenames", mappings["Maududi_English"]) | |
| code_ibn_kathir_ur = generate_dart_map("kIbnKathirUrduFilenames", mappings["Ibn_Kathir_Urdu"]) | |
| with open("BACKEND/scripts/generated_dart_maps.dart", "w", encoding="utf-8") as out: | |
| out.write(code_maududi_ur + "\n\n" + code_maududi_en + "\n\n" + code_ibn_kathir_ur) | |
| print("Generated Dart maps successfully.") | |