├── .gitattributes ├── .gitignore ├── LICENSE ├── MAT.py ├── MAT.spec └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Example of a `.gitattributes` file which reclassifies `.rb` files as Java: 2 | *.rb linguist-language=Python 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 105 | __pypackages__/ 106 | 107 | # Celery stuff 108 | celerybeat-schedule 109 | celerybeat.pid 110 | 111 | # SageMath parsed files 112 | *.sage.py 113 | 114 | # Environments 115 | .env 116 | .venv 117 | env/ 118 | venv/ 119 | ENV/ 120 | env.bak/ 121 | venv.bak/ 122 | 123 | # Spyder project settings 124 | .spyderproject 125 | .spyproject 126 | 127 | # Rope project settings 128 | .ropeproject 129 | 130 | # mkdocs documentation 131 | /site 132 | 133 | # mypy 134 | .mypy_cache/ 135 | .dmypy.json 136 | dmypy.json 137 | 138 | # Pyre type checker 139 | .pyre/ 140 | 141 | # pytype static type analyzer 142 | .pytype/ 143 | 144 | # Cython debug symbols 145 | cython_debug/ 146 | 147 | # PyCharm 148 | # JetBrains specific template is maintainted in a separate JetBrains.gitignore that can 149 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 150 | # and can be added to the global gitignore or merged into this file. For a more nuclear 151 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 152 | #.idea/ 153 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /MAT.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | import aiohttp 4 | import asyncio 5 | from tqdm import tqdm 6 | from collections import OrderedDict 7 | from aiogoogletrans import Translator 8 | 9 | async def translate_single(key, value, target_lang='ru'): 10 | try: 11 | # Проверяем, является ли строка уже переведенной 12 | if value.strip().startswith("Translated:"): 13 | return key, value 14 | 15 | # Если строка уже на русском, пропускаем ее 16 | if value.strip().startswith("$(br)"): 17 | return key, value 18 | 19 | # Разделяем ключ и значение символом "=" 20 | key_parts = key.split("=") 21 | if len(key_parts) > 1: 22 | translated_key = key_parts[0].strip() 23 | untranslated_value = "=".join(key_parts[1:]).strip() 24 | else: 25 | translated_key = key.strip() 26 | untranslated_value = value.strip() 27 | 28 | translator = Translator() 29 | translated_value = await translator.translate(untranslated_value, target_lang) 30 | return translated_key, translated_value.text 31 | except Exception as e: 32 | print(f"Ошибка при переводе строки: {str(e)}") 33 | print(f"Строка, вызвавшая ошибку: {key}: {value}") 34 | return key, value 35 | 36 | async def translate_json(filename, output_folder, target_lang='ru'): 37 | try: 38 | print("Начало перевода...") 39 | if not os.path.exists(output_folder): 40 | os.makedirs(output_folder) 41 | 42 | output_filename = os.path.join(output_folder, f"translated_{filename}") 43 | 44 | print(f"Загрузка файла {filename}...") 45 | with open(filename, 'r', encoding='utf-8') as file: 46 | data = json.load(file, object_pairs_hook=OrderedDict) 47 | 48 | translated_data = OrderedDict() 49 | tasks = [] 50 | for key, value in data.items(): 51 | tasks.append(translate_single(key, value, target_lang)) 52 | 53 | with tqdm(total=len(tasks), position=0, leave=False) as progress_bar: 54 | for task in asyncio.as_completed(tasks): 55 | key, translated_value = await task 56 | translated_data[key] = translated_value 57 | progress_bar.update(1) 58 | 59 | print("Запись в файл...") 60 | with open(output_filename, 'w', encoding='utf-8') as output_file: 61 | json.dump(translated_data, output_file, ensure_ascii=False, indent=4) 62 | 63 | print("Перевод завершен.") 64 | return output_filename 65 | except FileNotFoundError: 66 | print(f"Файл '{filename}' не найден.") 67 | return None 68 | except Exception as e: 69 | print(f"Произошла ошибка при переводе: {str(e)}") 70 | return None 71 | 72 | # Пример использования 73 | filename = input("Введите имя файла: ") 74 | output_folder = input("Введите имя папки для сохранения переведенного файла: ") 75 | 76 | asyncio.run(translate_json(filename, output_folder)) 77 | -------------------------------------------------------------------------------- /MAT.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | 3 | 4 | a = Analysis( 5 | ['MAT.py'], 6 | pathex=[], 7 | binaries=[], 8 | datas=[], 9 | hiddenimports=[], 10 | hookspath=[], 11 | hooksconfig={}, 12 | runtime_hooks=[], 13 | excludes=[], 14 | noarchive=False, 15 | ) 16 | pyz = PYZ(a.pure) 17 | 18 | exe = EXE( 19 | pyz, 20 | a.scripts, 21 | a.binaries, 22 | a.datas, 23 | [], 24 | name='MAT', 25 | debug=False, 26 | bootloader_ignore_signals=False, 27 | strip=False, 28 | upx=True, 29 | upx_exclude=[], 30 | runtime_tmpdir=None, 31 | console=True, 32 | disable_windowed_traceback=False, 33 | argv_emulation=False, 34 | target_arch=None, 35 | codesign_identity=None, 36 | entitlements_file=None, 37 | ) 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MAT переводчик 2 | Minecraft Automatic Translator - это программа для автоматического перевода модов в minecraft. 3 | Для того чтобы использовать эту программу, вам необходимо получить файл локализации из мода. 4 | # ❗ПРОГРАММА НЕ ПЕРЕВОДИТ ИДЕАЛЬНО❗ 5 | MAT не может переводит всё и правильно она может допускать ошибки и не переводить некоторые части текста. Из-за того что эта программа не идеальна, как и всё в этом мире. 6 | 7 | # 💢Проблема и её решение💢 8 | 9 | Может быть проблема с лицензией на библиотеку которую я использую для интерфейса 2 версии MAT. 10 | 11 | Вот видео которое поможет её решить: 12 | 13 | https://github.com/HackerMan33106/MAT-translator/assets/138781082/d3ace472-03e3-41a5-af07-8c6a5abbdc9b 14 | --------------------------------------------------------------------------------