Hash based multi language solution

UpvoteUpvote 2 DownvoteDownvote

Index

Features on these Courses

Attached Files

The following files have been attached to this tutorial:

.c3p

multi-language-using-hash.c3p

Download now 170.6 KB

Stats

208 visits, 321 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 1 May, 2025. Last updated 2 May, 2025

First, let me talk about my solution.

The header line contains the locale code. such as:

en-US, pt-BR, es-ES, zh-CN, zh-TW, ja-JP, ko-KR, fr-FR, de-DE, ru-RU, vi-VN, th-TH, it-IT, tr-TR, ar-SA ...

Instead of translation Key

Compared with the general multi-language solution, I did not use the translation Key/ID method in the first column.

ID en-US zh-CN
menu.title Menu 游戏菜单
menu.start New Game 新游戏
menu.continue Continue 继续游戏
menu.options Options 选项设置
menu.quit Quit Game 退出游戏

Instead, I used the original language directly in the eventsheet. So, when I want to translate "title",

I don't need to use menu.title to refer to the string. Instead, I can use the raw string function("Menu") to refer to other languages.

Hash

How it works is, I will pre-generate a string Hash value for each term in the original language and store it in the corresponding language object.

en-US.json

{
    "a57c2164c662bd61": "New Game",
    "007c2164badcb1d4": "Continue",
    "452b3f0c8d451a35": "Options",
    "55ecbcecac6b18a0": "Quit Game",
    "0b7c21642684e942": "Let's go"
}

zh-CN.json

{
    "a57c2164c662bd61": "新游戏",
    "007c2164badcb1d4": "继续",
    "452b3f0c8d451a35": "选项",
    "55ecbcecac6b18a0": "退出游戏",
    "0b7c21642684e942": "出发吧!"
}

This part of the work is done completely internally. We only need to maintain the original table file above. These hashes will be automatically generated during initialization.

Therefore, you don’t need to care about what their Hash values are. When you need their translation, you only need to get it through function("Menu") expression.

  • 0 Comments

Want to leave a comment? Login or Register an account!