├── LICENSE ├── README.md └── loc8Converter.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 wukko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ubiart-loc8-converter 2 | UbiArt localisation file converter that lets you decompress, compress, and patch loc8 files easily. 3 | 4 | ## Why? 5 | `.loc8` files are used for localisation in UbiArt Framework games. This script lets you easily extract or modify those files. It has been used personally by me for many years to create mods for Just Dance. 6 | 7 | ## Supported games 8 | - Just Dance 2015 - 2022 on all platforms (probably Just Dance 2014 too, haven't tested it) 9 | - Rayman Legends 10 | - Rayman Origins 11 | - ...most likely any other UbiArt game in existence 12 | 13 | ## How to use it 14 | This script doesn't depend on any external modules. All you need is Python 3+. 15 | 16 | However, this script requires passing parameters when used standalone: 17 | 18 | ``` 19 | py loc8Converter.py 20 | 21 | Modes: 22 | -d --decompress Decompresses the loc8 file as JSON 23 | -c --compress Compresses the file back to loc8 from JSON 24 | -p --patch Patches the output JSON file with values in input JSON file 25 | 26 | Sample usage: 27 | py loc8Converter.py -d localisation.loc8 localisation.json 28 | ``` 29 | 30 | 31 | Step-by-step usage tutorial: 32 | 1. Download `loc8Converter.py` 33 | 2. Copy it to any desired work directory 34 | 3. Run it by opening command prompt or terminal in directory and running `py loc8Converter.py` with parameters listed above 35 | 36 | You can also use this script as a module (like I usually do). 37 | -------------------------------------------------------------------------------- /loc8Converter.py: -------------------------------------------------------------------------------- 1 | # 2 | # https://github.com/wukko/ubiart-loc8-converter 3 | # 4 | # UbiArt localisation file converter by https://github.com/wukko 5 | # Tested on Just Dance 2015 - 2022 games on PC, Wii, Wii U, Nintendo Switch (NX). 6 | # This script should work for Rayman Legends/Origins and other UbiArt games too. 7 | # 8 | # This script requires passing parameters when used standalone. 9 | # 10 | # Usage: 11 | # py loc8Converter.py 12 | # 13 | # Modes: 14 | # -d --decompress Decompresses the loc8 file as JSON 15 | # -c --compress Compresses the file back to loc8 from JSON 16 | # -p --patch Patches the output JSON file with values in input JSON file 17 | # 18 | # Credit to me (https://github.com/wukko) is required when this script is used in other projects. 19 | 20 | import json 21 | 22 | def decompress(input, output): 23 | with open(input, "rb") as f: 24 | j = {} 25 | f.seek(8) 26 | i = 0 27 | amountOfStrings = int.from_bytes(f.read(4), "big") 28 | while i != amountOfStrings: 29 | id = int.from_bytes(f.read(4), "big") 30 | j[id] = f.read(int.from_bytes(f.read(4), "big")).decode("utf-8").replace("\x0A", "\n").replace('"', '\\"') 31 | i = i + 1 32 | with open(output, "w", encoding="utf-8") as f: 33 | json.dump(j, f, ensure_ascii=False, separators=(',', ':')) 34 | 35 | def compress(input, output): 36 | with open(output, "wb") as f: 37 | j = json.load(open(input, "r", encoding="utf-8")) 38 | f.write(b'\x00\x00\x00\x01\x00\x00\x00\x00') 39 | f.write(len(j).to_bytes(4, "big")) 40 | for i in j: 41 | string = j[i].replace('\"', '"').replace("\n", "\x0A").encode("utf-8") 42 | f.write(int(i).to_bytes(4, "big")) 43 | f.write(len(string).to_bytes(4, "big")) 44 | f.write(string) 45 | f.write(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF') 46 | 47 | def patch(input, output): 48 | patchjson = json.load(open(input, 'r', encoding="utf-8")) 49 | originaljson = json.load(open(output, 'r', encoding="utf-8")) 50 | for i in patchjson: 51 | originaljson[i] = patchjson[i] 52 | with open(output, "w", encoding="utf-8") as f: 53 | json.dump(originaljson, f, ensure_ascii=False, separators=(',', ':')) 54 | 55 | if __name__ == "__main__": 56 | import sys 57 | 58 | if len(sys.argv) == 4: 59 | mode = sys.argv[1] 60 | inputFile = sys.argv[2] 61 | outputFile = sys.argv[3] 62 | 63 | if mode == "-d" or mode == "--decompress": 64 | decompress(inputFile, outputFile) 65 | 66 | if mode == "-c" or mode == "--compress": 67 | compress(inputFile, outputFile) 68 | 69 | if mode == "-p" or mode == "--patch": 70 | patch(inputFile, outputFile) 71 | else: 72 | print('') 73 | print("This script requires passing parameters when used standalone.") 74 | print('') 75 | print("Usage:") 76 | print("py loc8Converter.py ") 77 | print('') 78 | print("Modes:") 79 | print("-d --decompress Decompresses the loc8 file as JSON") 80 | print("-c --compress Compresses the file back to loc8 from JSON") 81 | print("-p --patch Patches the output JSON file with values in input JSON file") --------------------------------------------------------------------------------