NOTE: This is only for mod developers who want to add custom translations (i'm so tired of copy-pasting this to every api)
API requested by Nevernamed
Github repository, where you can look at TranslationAPI's code and download it: https://github.com/SpecialAPI/TranslationAPI
An API that allows you to add custom translations.
To use this API, just
- Add it's files except files from Examples folder, TranslationAPI.csproj and TranslationAPI.sln, README.md, .gitignore and .gitattributes and everything from the Properties folder to your project.
- Call
TranslationManager.Init()
in your module'sStart()
method. - If you're using APIs like SaveAPI or SynergyAPI, make sure to init TranslationAPI AFTER initing the other APIs or otherwise some translations might not work.
TranslationAPI Guide
Various TranslationAPI classes and enums
Spoiler!
CustomStringDBTable
- needed for synergy and UI translations.StringTableType
- types of string tables.Translation
- saves all translated strings for one specific string table of one specific language.TranslationManager
- core class that can add new translations.
Adding custom translations
Spoiler!
To add custom item translations, use item.TranslateItemName
(for item name), item.TranslateItemShortDescription
(for item pickup quote) and item.TranslateItemLongDescription
(for item ammonomicon description)
They all have the same arguments:
language
- the language the translation will be applied to. All languages that don't have translations tied to them will default to english.translation
- the translated text for that language.
To add custom enemy translations use enemy.TranslateEnemyName
(for enemy name), enemy.TranslateEnemyShortDescription
(for enemy ammonomicon short description) and enemy.TranslateEnemyLongDescription
(for enemy ammonomicon description)
They have the same arguments as the methods for item translation.
You can also translate individual strings using TranslationManager.AddTranslation
. Arguments:
language
- the language the translation will be applied to.key
- the key to the string.value
- translated string for that languagetableType
- type of the table the translation will be applied to.Core
- the core table,Items
- the item table (for item names and descriptions),Enemies
- the enemy table (for enemy names and descriptions),UI
- the UI table (for UI-related stuff, which is, weirdly enough, never used in the base game),Intro
- the intro table (for the intro sequence),Synergy
- the synergy table (for synergy names)
Examples
Spoiler!
There's a file in the Examples folder called ExampleModule.cs. It shows how to use various TranslationAPI methods and their arguments. You shouldn't add it to your project, but you can look at it when you need an example of how to use a method or it's argument.