* cargo product loc * first cargo product translate * second cargoproduct translate * roadmap has optional localization * upd * 2024 roadmap translate * full ru roadmap goals translate moved to russian loc * translate some roadmap 2025 * roadmap fully translate * holidays translate * donation plinks rework * translate categories * translate planet prison objective * translate evil twin objectives * translate fugitive objectives * fix planet prisoner dir * upd * no more planet prison dir * partial toys translate * fully translate toys * lockbox loc fix * fix Suntick loc * fix tape loc * borg modules translate * translate borg tools and nanopaste * upd * boombox translate * translate pda's and hand_teleporter * reinforcement radio translate * donation plinks translate * barber items translate * tape player translate * ID cards translate * computers translate * translate corporate laws * pepper spray translate * flippo lighter translate * magistrat's rubber stamp translate * translate some ammunition * clear no need desc * translate SMGS * fix * Finaly guns translating * translate clocks * translate misc * some cloaks translate * fully cloaks translate * belts translate * translate all masks * translate boots * all backpacks translate * glasses translate * gloves translate * bras translate * fix rsi validator * translate jumpskirt's * jumpsuits translate * security pilot's jumpsuit translate * translate hardsuit helmets * translate hood * hats translate * helmets translate * men's underpants translate * translate women's pants * hardsuits translate * fix pant desc * translate armor * translate coats * translate captain's overcoat * socks translate * big boxes translate * translate lockers * power translate * translate barber pole * poster translate * translate chairs * translate vending_machines * translate pacificator * translate computers * clowns ghost role translate * translate eviltwin ghost role * translate predator name * another player species translate * translate foliant * translate borg chassis * shuttle markers translate * translate job spawners * ghost roles spawners translate * actions translate * stacks translate * some fixes * uplink catalog fully translate * return hypo on uplink * sponsor uplink catalog translate start * new sponsor uplink translation * fully translate sponsor uplink catalog * translate lockers * translate kits * translate syndicate boombox bundle * predator organs translate * body prototypes translate * humanoid xeno organs translate * predator body parts translate * xenomorph body parts translate * tajaran body parts translate * translate disease * species translate * translate speech emotes * upd * translate frontier rules * translate lust rules * translate default rules * crafting translate * holy shit, last fixes * no checks if you not changes prototypes * fix * fix linter * fix sponsor uplink catalog * second fix * fix socks * last fix * xd * fix * upd locale, ALL En-US prototypes translated * upd * upd locale validator, checks for non lokalized strings in ru-RU * some translations * clear * gaaaaaaaaaay pin * upd * upd * fix * fix linter * translate toys * translate * upd * fix * upd * fix * fix linter * upd * fix * better construction graph translation * start reworking construction menu translation * some new translations * fix * upd translations * пу-пу-пу * fix * upd * upd, sunrise strings in en-us * upd * translate voice-mask * translate guns * energy gun translate * server info translate * bar signs translate * translate ui tabs * translate reagent effect * translate revenant-catalog * translate categories * general translate * friends translate * Sponsor uplink fixes|Translate * some fixes * translate Security, Hos, QM sponsor uplink
53 lines
2.1 KiB
Python
53 lines
2.1 KiB
Python
#!/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 = cls.format_serialized_file_data(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)
|
|
|
|
serialized_data = FluentSerializer(with_junk=True).serialize(parsed_data)
|
|
|
|
lines = serialized_data.split('\n')
|
|
formatted_lines = []
|
|
for line in lines:
|
|
if (line.strip().startswith('[color=') or
|
|
line.strip().startswith('[bold]') or
|
|
line.strip().startswith('[font=') or
|
|
line.strip().startswith('**')):
|
|
if formatted_lines:
|
|
formatted_lines[-1] += ' ' + line.strip()
|
|
else:
|
|
formatted_lines.append(line)
|
|
else:
|
|
formatted_lines.append(line)
|
|
|
|
return '\n'.join(formatted_lines)
|
|
|
|
|
|
|
|
######################################## Var definitions ###############################################################
|
|
project = Project()
|
|
fluent_files = project.get_fluent_files_by_dir(project.ru_locale_dir_path)
|
|
|
|
########################################################################################################################
|
|
|
|
FluentFormatter.format(fluent_files)
|