1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-24 14:54:18 +00:00

Add a json conversion

This commit is contained in:
Steffo 2020-05-03 13:36:01 +02:00
parent 6b3fb880cb
commit 12c70ac388

View file

@ -2,6 +2,7 @@ from typing import *
import importlib
import types
import logging
import json
log = logging.getLogger(__name__)
@ -45,3 +46,14 @@ class Localization:
def boolmoji(self, boolean: bool) -> str:
return self.get("emoji_yes") if boolean else self.get("emoji_no")
def create_json_localization_file_from_strings(language: str):
module: types.ModuleType = importlib.import_module(f"strings.{language}")
raw = module.__dict__
clean = {}
for key in raw:
if not (key.startswith("__") and key.endswith("__")):
clean[key] = raw[key]
with open(f"locale/{language}.json", "w") as file:
json.dump(clean, file)