Files
crystall-punk-14/Tools/_CP14/LocalizationHelper/ftl_parser/ftl_parser.py
comasqw 8e27ef22ed Local helper update (#420)
* local helper update

* Delete entities.ftl

* Helper Refactor

* Revert "Helper Refactor"

This reverts commit 4aca315593.

* Helper Refactor

* Жееесть, я не знал про setdefault у словарей

* Update localization_helper.py

* Ревёрт "Жееесть, я не знал про setdefault у словарей"

Лучше бы я продолжал не знать о них

* чтооооо

* Update yml_parser.py

* Update entities.ftl

---------

Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
2024-09-23 15:43:02 +03:00

27 lines
779 B
Python

from fluent import ftl_reader
from base_parser import BaseParser
class FTLParser(BaseParser):
"""
The class inherits from the "BaseParser" class, parses ftl files of localization.
"""
def ftl_parser(self) -> 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 path in self._get_files_paths():
if not self._check_file_extension(path, ".ftl"):
continue
file = ftl_reader.read_ftl((path, self.errors_path))
prototypes.update(file)
return prototypes