HamletDuFromage / aio-switch-updater

Update your CFW, cheat codes, firmwares and more directly from your Nintendo Switch!
GNU General Public License v3.0
1.27k stars 106 forks source link

localizer.py fails saving #268

Closed NotaInutilis closed 1 year ago

NotaInutilis commented 1 year ago

Hi, it's been a while! Wanted to do some update to translation and got an issue with localizer.py. I now use Windows 11 x64 with Python 3.11 installed from the Windows Store.

I'm translating what it throws at me then, when it reaches the end or when I type _exit, it gives me an error message AND deletes everything but 3 lines of the translated file.

Traceback (most recent call last):
  File "E:\Développement\Traductions\aio-switch-updater\localizer.py", line 78, in <module>
    loc.update_file()
  File "E:\Développement\Traductions\aio-switch-updater\localizer.py", line 64, in update_file
    json.dump(self.out_dict, working_file, indent=2, ensure_ascii=False)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\json\__init__.py", line 180, in dump
    fp.write(chunk)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u25c6' in position 1: character maps to <undefined>

Capture d’écran 2023-07-14 205846

NotaInutilis commented 1 year ago

Some googling later, changing line 64 to json.dump(self.out_dict, working_file, indent=2, ensure_ascii=True) fixes the error but outputs \uXXX characters everywhere.

NotaInutilis commented 1 year ago

Works on linux, python on windows got big encoding issues.