LazyApiPack.Localization.Manager 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LazyApiPack.Localization.Manager --version 0.2.0                
NuGet\Install-Package LazyApiPack.Localization.Manager -Version 0.2.0                
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="LazyApiPack.Localization.Manager" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LazyApiPack.Localization.Manager --version 0.2.0                
#r "nuget: LazyApiPack.Localization.Manager, 0.2.0"                
#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 LazyApiPack.Localization.Manager as a Cake Addin
#addin nuget:?package=LazyApiPack.Localization.Manager&version=0.2.0

// Install LazyApiPack.Localization.Manager as a Cake Tool
#tool nuget:?package=LazyApiPack.Localization.Manager&version=0.2.0                

About this project

This library provides a way to localize applications. It uses the JSON format to store the localizations. Please refer to the LazyApiPack.Localization library documentation to learn, how to use the localization functionality and the file format.

How to use this library

This library can be uses as a service in an MVVM pattern, since it uses the interface from the LazyApiPack.Localization library.

LocalizationService

This service implements a Read-Only service for localizations To create an instance, just use DependencyInjection with the LazyApiPack.Localization library or create the instance with

new LocalizationService();

after the instantiation, you need to initialize the service (AddLocalizations).

Function AddLocalizations (Files)

This method is used to initialize the localization resources. To add localizations, use the "AddLocalizations" function and pass it a list of file pathes to the localization files. To use a localization, set the "CurrentLocalization" property to a localization found in AvailableLocalizations eg. _localizationService.CurrentLocalization = _localizationService.AvailableLocalizations.First(l => l.LanguageCode == "en");

Use localization

To use a localized value, use _localizationService.GetLocalization("Group", "Id") If you need information about the localization attributes like "IsRightToLeft", use the CurrentLocalization.IsRightToLeft attribute.

Remove localization

If you unload a module, you should remove the localizations with the module name _localizationManager.RemoveLocalization("MyModule"); Note, that this also removes overridden translations with the same module name. Important: Make sure, that the currently selected language is still in one of the dictionaries. If not, all localizations revert to the default localization files.

if (!_localizationService.AvailableLocalizations.Any(l => _localizationService.CurrentLocalization?.LanguageCode == l.LanguageCode)`) 
{
	_localizationService.CurrentLocalization = 
		_localizationService.AvailableLocalizations.FirstOrDefault(l => l.LanguageCode == "en") ?? 
			_localizationService.AvailableLocalizations.FirstOrDefault();

}
Product 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. 
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
0.2.1 252 11/19/2023
0.2.0 147 10/22/2023
0.1.0 185 7/16/2023
0.0.5 227 3/16/2023
0.0.4 218 3/13/2023
0.0.3 234 3/3/2023
0.0.2 229 3/3/2023
0.0.1 229 3/3/2023

Support added for language files as Embedded Resources from Assemblies.