Skip to content

Commit

Permalink
changed few errors into warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
piterson05 committed Sep 13, 2023
1 parent c860a08 commit 701204f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 3 additions & 3 deletions specialitems.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
<String xml:lang="es-ES">~r~No puedes usar ~s~un ~b~{0} ~s~cuando estás dentro de un vehículo.</String>
<String xml:lang="tr-TR">Sen ~r~kullanamazsın ~b~{0} ~s~bir aracın içindeyken.</String>
<String xml:lang="pl-PL">~r~Nie możesz użyć ~s~a ~b~{0} ~s~w środku pojazdu.</String>
<String xml:lang="pt-BR">você não pode usar ~s~a ~b~{0} ~s~ quando estiver dentro de um veículo.</String>
<String xml:lang="pt-BR">você não pode usar ~s~a ~b~{0} ~s~quando estiver dentro de um veículo.</String>
</Entry>

<Entry Id="specialitem_repairkit_vehicle_close">
Expand Down Expand Up @@ -440,7 +440,7 @@
<String xml:lang="pl-PL">Znalazłeś 20 kolejnych ~o~dyń~s~! Sprawdź swój ekwipunek dla ~b~bonusów~s~.</String>
<String xml:lang="es-ES">¡Encontraste 20 ~o~calabazas~s~ más! Revisa tu inventario para encontrar tu ~b~objeto de bonificación~s~.</String>
<String xml:lang="de-DE">Du hast 20 weitere ~o~Kürbisse~s~ gefunden! Überprüfe dein Inventat für deinen ~b~Bonus-Gegenstand~s~.</String>
<String xml:lang="pt-BR">Você encontrou 20 ~o~abóboras~s~! Verifique seu inventário para encontrar o item de bônus ~b~.~s~.</String>
<String xml:lang="pt-BR">Você encontrou 20 ~o~abóboras~s~! Verifique seu inventário para encontrar o ~b~item de bônus~s~.</String>
</Entry>

<Entry Id="specialitem_hallooween_fifty_pumpkin">
Expand Down Expand Up @@ -483,7 +483,7 @@
<String xml:lang="pl-PL">~r~Uwaga: ~s~Nie dostałeś cukierka halloweenowego z powodu błędu 0x88-{0}.</String>
<String xml:lang="es-ES">~r~Advertencia: ~s~No pudiste recibir un dulce de Halloween debido a un error 0x88-{0}.</String>
<String xml:lang="de-DE">~r~Achtung: ~s~Du konntest keine Halloween-Süßigkeiten erhalten aufgrund eines Fehlers: 0x88-{0}.</String>
<String xml:lang="pt-BR">~r~Aviso: ~s~Não foi possível receber doces de Halloween devido ao erro 0x88-{0}. </String>
<String xml:lang="pt-BR">~r~Aviso: ~s~Não foi possível receber doces de Halloween devido ao erro 0x88-{0}.</String>
</Entry>

<!-- {0} = Player name -->
Expand Down
21 changes: 17 additions & 4 deletions validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ class Validator:
custom_xml_parser = None
preview_formatting = False
main_doc = None
warnings_as_errors = False

@staticmethod
def setup_xml_parser():
Expand Down Expand Up @@ -377,6 +378,7 @@ def print_error(error: str, location: list[str], custom_file_cursor: tuple[int]
print(f"{colorama.Fore.RED}{txt}{colorama.Fore.RESET}")
else:
print(txt)
print()


@staticmethod
Expand All @@ -395,11 +397,20 @@ def print_warning(warning: str, location: list[str], custom_file_cursor: tuple[i
print(f"{colorama.Fore.YELLOW}{txt}{colorama.Fore.RESET}")
else:
print(txt)
print()


@staticmethod
def print_warning_or_error(warning: str, location: list[str], custom_file_cursor: tuple[int] | None = None):
if Validator.warnings_as_errors:
Validator.print_error(warning, location, custom_file_cursor)
else:
Validator.print_warning(warning, location, custom_file_cursor)


@staticmethod
def entry_pretty_print(entry: xml.dom.minidom.Element) -> str:
return f"{entry.tagName}<Id:{repr(dict(entry.attributes.items()).get('Id'))}>"
return f"{entry.tagName}({repr(dict(entry.attributes.items()).get('Id'))})"


@staticmethod
Expand Down Expand Up @@ -613,12 +624,12 @@ def check_entries(entry: xml.dom.minidom.Element, path: list[str]):
if text_without_formatting.find("~") != -1:
Validator.print_error(f"Found invalid text formatting (~)", path1, string_entry.parse_position)
if re.findall(r"\s\s+", text_without_formatting):
Validator.print_error(f"Found too many spaces between words", path1, string_entry.parse_position)
Validator.print_warning_or_error(f"Found too many spaces between words", path1, string_entry.parse_position)
if re.findall(WRONG_PUNCTUATION_REGEX, text_without_formatting):
Validator.print_error(f"Found invalid punctuation mark placement", path1, string_entry.parse_position)
Validator.print_warning_or_error(f"Found invalid punctuation mark placement", path1, string_entry.parse_position)
if (Validator.show_lang is not None) and (Validator.show_lang not in found_langs):
if Validator.found_missing_lang <= Validator.display_limit:
Validator.print_warning(f"Missing translation for {repr(Validator.show_lang)}!", path, element_location)
Validator.print_warning_or_error(f"Missing translation for {repr(Validator.show_lang)}!", path, element_location)
Validator.found_missing_lang += 1


Expand All @@ -628,13 +639,15 @@ def check_entries(entry: xml.dom.minidom.Element, path: list[str]):
parser = argparse.ArgumentParser(description='Validates localization files')
parser.add_argument('--show_lang', type=str, help='Show missing language localizations', choices=Validator.supported_langs)
parser.add_argument('--preview_formatting', action='store_true', help='Show formatted localizations as HTML file')
parser.add_argument('--treat_warnings_as_errors', action='store_true', help='Treat warnings as errors')
parser.add_argument('--display_limit', type=int, default=10, help='Set display limit for missing translations')
args = parser.parse_args()
Validator.custom_xml_parser = Validator.setup_xml_parser()
if args.preview_formatting and DOMINATE_INSTALLED:
Validator.preview_formatting = True
Validator.setup_html_doc()
Validator.display_limit = args.display_limit
Validator.warnings_as_errors = args.treat_warnings_as_errors
Validator.show_lang = args.show_lang
with open("index.json", "r", encoding="utf-8") as index_file:
Validator.xml_files = json.load(index_file)
Expand Down

0 comments on commit 701204f

Please sign in to comment.