LanguageProvider 1.0.1
dotnet add package LanguageProvider --version 1.0.1
NuGet\Install-Package LanguageProvider -Version 1.0.1
<PackageReference Include="LanguageProvider" Version="1.0.1" />
paket add LanguageProvider --version 1.0.1
#r "nuget: LanguageProvider, 1.0.1"
// Install LanguageProvider as a Cake Addin #addin nuget:?package=LanguageProvider&version=1.0.1 // Install LanguageProvider as a Cake Tool #tool nuget:?package=LanguageProvider&version=1.0.1
LanguageProvider
1 Introduction
The LanguageProvider
offers the possibility to manage available json-language-files. It allows the centralized access to the configured languages and an automatic update of registered components whenever the language is changed.
2 API
2.1 LanguageProvider (static class)
Offers string loading mechanisms for an automatic update of the GUI.
For the configuration of the
LanguageProvider
callConfigureLanguages(Dictionary{string, byte[]}, string)
. Hand in the existing language files of the application to configure the available languages and select a default language.The language files must be a valid json-file containing a single root node. Cross-references of template strings can be assembled using the
${json.path.to.string}
-pattern within a value.
LanguageProvider.ConfigureLanguages(new Dictionary<string, byte[]> {{ "English", Properties.Resources.EnglishLanguageFile }}, "English");
To automatically update components that need strings in their GUI implement the
UpdatedLanguageUser
interface accordingly and useRegisterUnique(UpdatedLanguageUser)
orRegister(UpdatedLanguageUser)
andUnregister(UpdatedLanguageUser)
to receive automatic updates.
Register(UpdatedLanguageUser)
andUnregister(UpdatedLanguageUser)
should normally be used for all user controls in applications as they could be instantiated several times.
RegisterUnique(UpdatedLanguageUser)
should normally be used for different windows in applications that can only be instantiated once.The configured languages can be retrieved using
LanguageList
as well asDefaultLanguage
andCurrentLanguage
.
Accessible Interface:
public static void ConfigureLanguages(Dictionary<string, byte[]> languages, string defaultLanguage)
public static string CurrentLanguage
public static string DefaultLanguage
public static List<string> LanguageList
public static void Register(UpdatedLanguageUser languageUser)
public static void Unregister(UpdatedLanguageUser languageUser)
public static void RegisterUnique(UpdatedLanguageUser languageUser)
public static void UpdateAllSubcribers()
public static string getString(string path)
public static string getString(string language, string path)
2.2 LanguageUser (interface)
A component that needs access to string resources.
Should be used for all user controls or windows, that are updated prorammatically so the <see cref="LanguageProvider"/> does not need to perform the update itself (e.g. dialogs).
Accessible Interface:
void LoadTexts(string language)
2.3 UpdatedLanguageUser (interface)
A component that needs access to string resources and will automatically be updated by the
LanguageProvider
.Should be used for all user controls or windows, that must be updated automatically whenever the language changes.
Accessible Interface:
void RegisterAtLanguageProvider()
Extends
LanguageUser
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 149 | 6/25/2023 |