Localization Helper (#275)

* Localization Helper

* Update main.py

* Update main.py

* adding comments to code and translating exceptions into English

* cringe fix

* Update yml_parser.py

* tweak

* Update main.py
This commit is contained in:
comasqw
2024-06-25 19:02:02 +04:00
committed by GitHub
parent e12f499594
commit fa86f705aa
14 changed files with 270 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
from fluent import ftl_reader
import os
def ftl_parser(path: str) -> dict:
"""
The function gets the path, then with the help of the os library
goes through each file,checks that the file extension is "ftl",
then reads it through the "ftl_reader" module of the "fluent" package.
"""
prototypes = {}
for dirpath, _, filenames in os.walk(path):
for filename in filenames:
path = f"{dirpath}\\{filename}"
if not filename.endswith(".ftl"):
continue
file = ftl_reader.read_ftl(path)
prototypes.update(file)
return prototypes