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:
23
Tools/_CP14/LocalizationHelper/ftl_parser/ftl_parser.py
Normal file
23
Tools/_CP14/LocalizationHelper/ftl_parser/ftl_parser.py
Normal 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
|
||||
Reference in New Issue
Block a user