mirror of
https://github.com/Gurkengewuerz/nitro-docker.git
synced 2024-11-22 16:10:52 +01:00
feat: add more translation of missing badges
This commit is contained in:
parent
5b90f1a3b9
commit
cf02ca2519
@ -179,7 +179,8 @@ cd ../.. && \
|
|||||||
docker compose up assets-build --build && \
|
docker compose up assets-build --build && \
|
||||||
cd ./assets/translation && \
|
cd ./assets/translation && \
|
||||||
python FurnitureDataTranslator.py && \
|
python FurnitureDataTranslator.py && \
|
||||||
python SQLGenerator.py
|
python SQLGenerator.py && \
|
||||||
|
python external_text.py --domain com
|
||||||
```
|
```
|
||||||
|
|
||||||
* run SQL file
|
* run SQL file
|
||||||
|
56
assets/translation/external_text.py
Normal file
56
assets/translation/external_text.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import argparse
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
domains = ["com.br", "com.tr", "com", "de", "es", "fi", "fr", "it", "nl"]
|
||||||
|
|
||||||
|
def fetch_external_flash_texts(domain):
|
||||||
|
url = f"https://www.habbo.{domain}/gamedata/external_flash_texts/0"
|
||||||
|
response = requests.get(url)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
return response.text.split('\n')
|
||||||
|
else:
|
||||||
|
print(f"Failed to fetch data from {url}. Status code: {response.status_code}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
def parse_flash_texts(lines):
|
||||||
|
flash_texts_dict = {}
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if '=' in line:
|
||||||
|
key, value = line.split('=', 1)
|
||||||
|
flash_texts_dict[key.strip()] = value.strip()
|
||||||
|
|
||||||
|
return flash_texts_dict
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Fetch and parse external flash texts for a given domain.")
|
||||||
|
parser.add_argument("--domain", help="Specify the top-level domain (TLD) for fetching external flash texts.", choices=domains)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.domain:
|
||||||
|
domain = args.domain
|
||||||
|
else:
|
||||||
|
print("Please provide a valid domain using the --domain argument.")
|
||||||
|
return
|
||||||
|
|
||||||
|
domains.remove(domain)
|
||||||
|
domains.append(domain)
|
||||||
|
|
||||||
|
all_flash_texts = {}
|
||||||
|
with open("../assets/gamedata/ExternalTexts.json", "r", encoding="utf-8") as f:
|
||||||
|
all_flash_texts = json.load(f)
|
||||||
|
|
||||||
|
for d in domains:
|
||||||
|
flash_texts_lines = fetch_external_flash_texts(d)
|
||||||
|
flash_texts_dict = parse_flash_texts(flash_texts_lines)
|
||||||
|
all_flash_texts = all_flash_texts | flash_texts_dict
|
||||||
|
|
||||||
|
with open("../assets/gamedata/ExternalTexts.json", "w", encoding="utf-8") as f:
|
||||||
|
json.dump(all_flash_texts, f, separators=(',', ':'), sort_keys=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user