H073.Local
1.1.0
Prefix Reserved
See the version list below for details.
dotnet add package H073.Local --version 1.1.0
NuGet\Install-Package H073.Local -Version 1.1.0
<PackageReference Include="H073.Local" Version="1.1.0" />
paket add H073.Local --version 1.1.0
#r "nuget: H073.Local, 1.1.0"
// Install H073.Local as a Cake Addin #addin nuget:?package=H073.Local&version=1.1.0 // Install H073.Local as a Cake Tool #tool nuget:?package=H073.Local&version=1.1.0
HxLocal API Documentation
Introduction
The Localisation
class provides functions to manage and access translations based on language JSON files.
Setup
By default, translations are expected to be stored in a folder named "Lingos", containing JSON files named with their respective language codes, e.g., "en.json", "de.json".
Changing the Default Folder:
If you want to use a different folder, you can change the FilePath
property. However, it's crucial to ensure that you set this folder before loading any languages or accessing translations:
Localisation.FilePath = "YourFolderPathHere";
⚠️ Note: Always change the folder path before loading a language or using the API to fetch translations. The order is crucial to ensure the API looks in the correct directory.
Using the API
1. Loading a Language:
To load a specific language, call the LoadLanguage
method:
Localisation.LoadLanguage("en");
Where "en"
is the language code.
2. Retrieving a String:
To retrieve a translated string, use the GetString
method:
var welcomeMessage = Localisation.GetString("welcomeMessage");
If the key contains nested objects, use a dot notation:
var nestedMessage = Localisation.GetString("parent.child.message");
3. Using Format Strings:
You can use string formats and pass arguments to the GetString
method:
var formattedMessage = Localisation.GetString("welcomeWithName", "John");
Assuming the translation is something like: "welcomeWithName": "Welcome, {0}!"
4. List Available Languages:
To get a list of available languages:
var languages = Localisation.ListAvailableLanguages();
foreach(var lang in languages)
{
Console.WriteLine(lang);
}
This will list the names of the JSON files without their extensions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.