2024-06-25 19:02:02 +04:00
|
|
|
from fluent import ftl_reader
|
2024-06-27 23:07:25 +04:00
|
|
|
from base_parser import BaseParser
|
2024-06-25 19:02:02 +04:00
|
|
|
|
|
|
|
|
|
2024-06-27 23:07:25 +04:00
|
|
|
class FTLParser(BaseParser):
|
2024-06-25 19:02:02 +04:00
|
|
|
"""
|
2024-06-27 23:07:25 +04:00
|
|
|
The class inherits from the "BaseParser" class, parses ftl files of localization.
|
2024-06-25 19:02:02 +04:00
|
|
|
"""
|
|
|
|
|
|
2024-06-27 23:07:25 +04:00
|
|
|
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 = {}
|
2024-06-25 19:02:02 +04:00
|
|
|
|
2024-09-23 16:43:02 +04:00
|
|
|
for path in self._get_files_paths():
|
2024-06-27 23:07:25 +04:00
|
|
|
|
2024-09-23 16:43:02 +04:00
|
|
|
if not self._check_file_extension(path, ".ftl"):
|
2024-06-25 19:02:02 +04:00
|
|
|
continue
|
|
|
|
|
|
2024-06-27 23:07:25 +04:00
|
|
|
file = ftl_reader.read_ftl((path, self.errors_path))
|
2024-06-25 19:02:02 +04:00
|
|
|
prototypes.update(file)
|
|
|
|
|
|
2024-06-27 23:07:25 +04:00
|
|
|
return prototypes
|