FmgLib.LocalizationMaui 1.0.1-prev1

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

// Install FmgLib.LocalizationMaui as a Cake Tool
#tool nuget:?package=FmgLib.LocalizationMaui&version=1.0.1-prev1&prerelease                

To access related services, simply add using FmgLib.LocalizationMaui; statement.

In the Program.cs file,

builder
    .UseMauiApp<App>()
    .AddFmgLibLocalizationMaui();

should be added.

In your main project you should have a language file of type json. The translation will be read from this file and imported. If you do not specify the path to the file(s) in the parameter (

builder
    .UseMauiApp<App>()
    .AddFmgLibLocalizationMaui();
  //.AddFmgLibLocalizationMaui(defaultLang:"en-US"); // or
  //.AddFmgLibLocalizationMaui(defaultLang:"en-US", "Loc1.json", "Loc2.json"); // or

), will look for a json file named Localization.json in the home directory.

if you give one or more parameters like

builder
    .UseMauiApp<App>()
    .AddFmgLibLocalizationMaui("Localization1.json", "Localization2.json", "/Languages/Temp1.json");

it will read json files in given file paths.

The critical point here is to select Build Action: MauiAsset for json files.

Proper json format:

{
  "Hello": {
    "tr-TR": "Merhaba Dünya!",
    "en-US": "Hello World!"
  },
  "Msg": {
    "tr-TR": "Deneme amaçlı yapılmıştır.",
    "en-US": "It was made for testing purposes."
  }
}

Instead of 'keyWord' keywords, you can use any word or phrase(s) you want. You don't have any Regex limitations.

You can also change the 'tr-TR' and 'en-US' language keys with words or sentences as you wish. But it is recommended to use expressions such as 'en-US', 'tr-TR', 'fr-FR'.

You can simply use

Console.WriteLine("keyWord 1".ToTranslate());

in the code.

If you do not specify a parameter, it will translate according to the language expression registered in Culture (language keys such as 'en-US', 'tr-TR' will appear).

You can easily obtain the translation by specifying the language key as

Console.WriteLine("keyWord 1".ToTranslate("tr-TR"));

.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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
1.0.2 113 6/8/2024
1.0.1 134 3/3/2024
1.0.1-prev1 124 1/23/2024
1.0.0 146 1/21/2024