Show / Hide Table of Contents

Class LocalizationManager

Manager for handling localizations for all custom content added to the game.
Inheritance
System.Object
LocalizationManager
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Jotunn.Managers
Assembly: Jotunn.dll
Syntax
public class LocalizationManager : IManager

Fields

| Improve this Doc View Source

CommunityTranslationFileName

Name of the community translation files that will be the first custom languages files loaded before any others.
Declaration
public const string CommunityTranslationFileName = "community_translation.json"
Field Value
Type Description
System.String
| Improve this Doc View Source

DefaultLanguage

Default language of the game.
Declaration
public const string DefaultLanguage = "English"
Field Value
Type Description
System.String
| Improve this Doc View Source

TokenFirstChar

Your token must start with this character.
Declaration
public const char TokenFirstChar = '$'
Field Value
Type Description
System.Char
| Improve this Doc View Source

TranslationsFolderName

Name of the folder that will hold the custom .json translations files.
Declaration
public const string TranslationsFolderName = "Translations"
Field Value
Type Description
System.String

Properties

| Improve this Doc View Source

Instance

The singleton instance of this manager.
Declaration
public static LocalizationManager Instance { get; }
Property Value
Type Description
LocalizationManager

Methods

| Improve this Doc View Source

AddJson(String, String)

Add a json language file (match crowdin format).
Declaration
[Obsolete("Use AddLocalization(CustomLocalization) instead")]
public void AddJson(string language, string fileContent)
Parameters
Type Name Description
System.String language Language for the json file, for example, "English"
System.String fileContent Entire file as string
| Improve this Doc View Source

AddLanguageFile(String)

Add a language file that matches Valheim's language format.
Declaration
[Obsolete("Use AddLocalization(CustomLocalization) instead")]
public void AddLanguageFile(string fileContent)
Parameters
Type Name Description
System.String fileContent Entire file as string
| Improve this Doc View Source

AddLocalization(LocalizationConfig)

Registers a new Localization for a language.
Declaration
[Obsolete("Use AddLocalization(CustomLocalization) instead")]
public void AddLocalization(LocalizationConfig config)
Parameters
Type Name Description
LocalizationConfig config Wrapper which contains a language and a Token-Value dictionary.
| Improve this Doc View Source

AddLocalization(CustomLocalization)

Add your mod's custom localization. Only one CustomLocalization can be added per mod.
Declaration
public bool AddLocalization(CustomLocalization customLocalization)
Parameters
Type Name Description
CustomLocalization customLocalization The localization to add.
Returns
Type Description
System.Boolean true if the custom localization was added to the manager.
| Improve this Doc View Source

AddLocalization(String, Dictionary<String, String>)

Registers a new Localization for a language.
Declaration
[Obsolete("Use AddLocalization(CustomLocalization) instead")]
public void AddLocalization(string language, Dictionary<string, string> localization)
Parameters
Type Name Description
System.String language The language being added.
System.Collections.Generic.Dictionary<System.String, System.String> localization Token-Value dictionary.
| Improve this Doc View Source

AddPath(String, Boolean)

Add a file via absolute path.
Declaration
[Obsolete("Use AddLocalization(CustomLocalization) instead")]
public void AddPath(string path, bool isJson = false)
Parameters
Type Name Description
System.String path Absolute path to file.
System.Boolean isJson Is the language file a json file.
| Improve this Doc View Source

AddToken(String, String, Boolean)

Add a token and its value to the "English" language.
Declaration
[Obsolete("Use AddLocalization(CustomLocalization) instead")]
public void AddToken(string token, string value, bool forceReplace = false)
Parameters
Type Name Description
System.String token Token
System.String value Translation.
System.Boolean forceReplace Replace the token if it already exists
| Improve this Doc View Source

AddToken(String, String, String, Boolean)

Add a token and its value to the specified language (default to "English").
Declaration
[Obsolete("Use AddLocalization(CustomLocalization) instead")]
public void AddToken(string token, string value, string language, bool forceReplace = false)
Parameters
Type Name Description
System.String token Token
System.String value Translation.
System.String language Language ID for this token.
System.Boolean forceReplace Replace the token if it already exists
| Improve this Doc View Source

GetLocalization()

Get the CustomLocalization for your mod. Creates a new CustomLocalization if no localization was added before.
Declaration
public CustomLocalization GetLocalization()
Returns
Type Description
CustomLocalization Existing or newly created CustomLocalization.
| Improve this Doc View Source

Init()

Initialize localization manager.
Declaration
public void Init()
| Improve this Doc View Source

TryTranslate(String)

Retrieve a translation if it's found in any CustomLocalization or .
Declaration
public string TryTranslate(string word)
Parameters
Type Name Description
System.String word Word to translate.
Returns
Type Description
System.String Translated word in player language or english as a fallback.

Events

| Improve this Doc View Source

OnLocalizationAdded

Event that gets fired after all custom localization has been added to the game. Use this event if you need to translate strings using the vanilla class. Your code will execute every time the localization gets reset (on every menu start). If you want to execute just once you will need to unregister from the event after execution.
Declaration
public static event Action OnLocalizationAdded
Event Type
Type Description
System.Action

Extension Methods

PrefabExtension.FixReferences(Object)
  • Improve this Doc
  • View Source
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾