LanguageProvider 1.0.1

dotnet add package LanguageProvider --version 1.0.1                
NuGet\Install-Package LanguageProvider -Version 1.0.1                
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="LanguageProvider" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LanguageProvider --version 1.0.1                
#r "nuget: LanguageProvider, 1.0.1"                
#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.
// 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 call ConfigureLanguages(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 use RegisterUnique(UpdatedLanguageUser) or Register(UpdatedLanguageUser) and Unregister(UpdatedLanguageUser) to receive automatic updates.

Register(UpdatedLanguageUser) and Unregister(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 as DefaultLanguage and CurrentLanguage.

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 Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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