-
Notifications
You must be signed in to change notification settings - Fork 2
Localisation
Localization is a crucial aspect of mod development, allowing your mod to reach a broader audience by supporting multiple languages. In the Gooee framework for Cities Skylines 2, you can implement localization by defining the IGooeeLanguages interface and using embedded resource YAML files for language translations.
Your plugin class needs to implement the IGooeeLanguages interface, along with the IGooeePluginWithControllers interface. This setup allows your plugin to support multiple languages. Here's an example of how to define your plugin class for localization:
[ControllerTypes(typeof(ExampleController))]
public class ExamplePlugin : IGooeePluginWithControllers, IGooeeLanguages
{
public string Name => "Example";
public string ScriptResource => "MyAssembly.Resources.ui.js";
public string LanguageResourceFolder => "MyAssembly.Resources.lang";
public IController[] Controllers { get; set; }
}The LanguageResourceFolder property in your plugin class should point to the folder within your assembly where your language YAML files are located. This folder will contain all the necessary translations for your mod.
Localization files should be created as embedded resources within the "lang" folder in your assembly. Each file corresponds to a specific locale and is named after the locale's code (e.g., "en-US"). The file format is YAML, and the structure is straightforward:
lang:
Key: "Translated Text String"lang:
WelcomeMessage: "Welcome to the Example mod!"
SettingsTitle: "Settings"
EnableFeature: "Enable Feature"Once you have set up your localization files, you can use the game's built-in localization methods to retrieve and display the translated strings in your mod's UI. These methods will be documented separately, detailing how to fetch and apply these translations dynamically based on the user's language settings.
It's important to test your mod with different language settings to ensure that the localization works correctly and that all text is displayed properly in the selected language.
By implementing the IGooeeLanguages interface and setting up localized YAML files in your Cities Skylines 2 mod, you can easily support multiple languages, making your mod more accessible and user-friendly for a global audience. Stay tuned for additional documentation on using the game's built-in localization methods.