[Feat] Translates + translate tools (#260)
* autotranslate python script * 8/52 translated * autotranslate finished * updated autotranslate script * fixes * updated tool * once more updated tool * more translates * more translates * fixes
This commit is contained in:
37
Tools/ss14_ru/fluentformatter.py
Normal file
37
Tools/ss14_ru/fluentformatter.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Форматтер, приводящий fluent-файлы (.ftl) в соответствие стайлгайду
|
||||
# path - путь к папке, содержащий форматируемые файлы. Для форматирования всего проекта, необходимо заменить значение на root_dir_path
|
||||
import typing
|
||||
|
||||
from file import FluentFile
|
||||
from project import Project
|
||||
from fluent.syntax import ast, FluentParser, FluentSerializer
|
||||
|
||||
|
||||
######################################### Class defifitions ############################################################
|
||||
|
||||
class FluentFormatter:
|
||||
@classmethod
|
||||
def format(cls, fluent_files: typing.List[FluentFile]):
|
||||
for file in fluent_files:
|
||||
file_data = file.read_data()
|
||||
parsed_file_data = file.parse_data(file_data)
|
||||
serialized_file_data = file.serialize_data(parsed_file_data)
|
||||
file.save_data(serialized_file_data)
|
||||
|
||||
@classmethod
|
||||
def format_serialized_file_data(cls, file_data: typing.AnyStr):
|
||||
parsed_data = FluentParser().parse(file_data)
|
||||
|
||||
return FluentSerializer(with_junk=True).serialize(parsed_data)
|
||||
|
||||
|
||||
|
||||
######################################## Var definitions ###############################################################
|
||||
project = Project()
|
||||
fluent_files = project.get_fluent_files_by_dir(project.ru_locale_dir_path)
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
FluentFormatter.format(fluent_files)
|
||||
Reference in New Issue
Block a user