TnmsLocalizationPlatform.Shared 0.0.2

dotnet add package TnmsLocalizationPlatform.Shared --version 0.0.2
                    
NuGet\Install-Package TnmsLocalizationPlatform.Shared -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TnmsLocalizationPlatform.Shared" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TnmsLocalizationPlatform.Shared" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="TnmsLocalizationPlatform.Shared" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TnmsLocalizationPlatform.Shared --version 0.0.2
                    
#r "nuget: TnmsLocalizationPlatform.Shared, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TnmsLocalizationPlatform.Shared@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TnmsLocalizationPlatform.Shared&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=TnmsLocalizationPlatform.Shared&version=0.0.2
                    
Install as a Cake Tool

TnmsLocalizationPlatform

What is this?

This is a common platform for managing player language settings and enabling each plugin to easily support multiple languages.

On the first connection, the player's cl_language setting is automatically retrieved and saved.

Features

Automatic Management of Player Language Settings

When a player connects to the server, their cl_language setting is automatically retrieved and saved to the database. On subsequent connections, the saved language setting is used.

Localizer for Multilingual Support

Provides multilingual support based on Microsoft.Extensions.Localization through the ITnmsLocalizer interface.

Usage

Adding Dependencies

Install TnmsLocalizationPlatform.Shared from NuGet.

dotnet add package TnmsLocalizationPlatform.Shared

Plugin Development

Getting an Instance
private ITnmsLocalizationPlatform? _localizationPlatform;

public void OnAllModulesLoaded()
{
    _localizationPlatform = SharedSystem.GetSharpModuleManager()
        .GetRequiredSharpModuleInterface<ITnmsLocalizationPlatform>(
            ITnmsLocalizationPlatform.ModSharpModuleIdentity).Instance;
}
Implementing ILocalizableModule

Implement ILocalizableModule in your plugin.

public class YourPlugin : IModSharpModule, ILocalizableModule
{
    public string ModuleDirectory => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
    
    // ...other implementations
}
Creating and Using a Localizer
private ITnmsLocalizer _localizer = null!;

// Creating a Localizer
public void OnAllModulesLoaded()
{
    _localizer = _localizationPlatform.CreateStringLocalizer(this);
}

// Usage example
public void SendLocalizedMessage(IGameClient client, string key, params object[] args)
{
    var localizedString = _localizer.ForClient(client, key, args);
    client.PrintToChat(localizedString.Value);
}

// Getting a string for a specific culture
public string GetLocalizedString(string key, CultureInfo culture, params object[] args)
{
    if (_localizer != null)
    {
        return _localizer[key, culture, args].Value;
    }
    return key;
}
Getting Player Language Settings
public void CheckPlayerLanguage(IGameClient client)
{
    var playerCulture = _localizer.GetClientCulture(client);
    Console.WriteLine($"Player {client.PlayerName} uses language: {playerCulture.Name}");
}

Placing Language Files

modules/yourmodle/lang/

Another develop info

For more details, please refer to the code documentation.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TnmsLocalizationPlatform.Shared:

Package Downloads
TnmsPluginFoundation

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 376 11/17/2025
0.0.1 312 10/28/2025
0.0.0 207 10/9/2025