Jump to content

Recommended Posts

The main idea is that a mod can determine the existence of the language pack on the client side. Then the mod can translate phrases and names of items only for that user (client-side).

The difficulty lies in the fact that the phrase is sent entirely over the network. Therefore, as a solution we should create a lookup table. A string in English comes from the server, and it is replaced by the phrase from the table.

Names of items and descriptions of recipes can be safely changed locally. But we want a nice unified solution to make our translations of items, recipes, phrases etc. I think one file for each language is nice enough, isn't it?

Here is the mini code. You should copy&paste it into your modmain. Then you should change it for your mod:

  • LANG_FILE_PREFIX - is the prefix of your language files, e.g. yourmod_en.lua where prefix is "yourmod_"
  • SUPPORTED_LANGS - list of supported language signs. Each sign is defined by language pack. You can find it in modmain of any language pack in line with "LoadPOFile" function.
  • TEST_LANG - uncomment this line if you want to test some language file without installing specific language pack.

After that make files for translations including English language, i.e. yourmod_en.lua file. Use aliases for initialization string values:

  • nm - for names of items (instead of STRINGS.NAMES)
  • desc - for description phrases of items and other objects (by prefab name as usual)
  • rec - description for recipe in recipe tab (instead of STRINGS.RECIPE_DESC)
  • actf - special alias for action fail strings (instead of STRINGS.CHARACTERS.GENERIC.ACTIONFAIL)
  • ch - for personal phrases by character (e.g. ch.WILLOW.DESCRIBE.SOMEITEM = "...")
  • Also you can use the function AddPhrase() directly (only for phrases).

Example mod: Kindling Fire (v0.24+).

Examples of language files:

translate_example.png

Edited by Maris

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...