https://github.com/fmglib/fmglib.localization
This package serves to integrate your system into multiple languages.
https://github.com/fmglib/fmglib.localization
Last synced: 2 months ago
JSON representation
This package serves to integrate your system into multiple languages.
- Host: GitHub
- URL: https://github.com/fmglib/fmglib.localization
- Owner: FmgLib
- License: mit
- Created: 2024-01-21T12:23:07.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-08T11:21:28.000Z (about 2 years ago)
- Last Synced: 2025-05-08T00:46:45.250Z (about 1 year ago)
- Language: C#
- Size: 228 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
To access related services, simply add `using FmgLib.Localization;` statement.
In the Program.cs file,
```CSharp
builder.Services.AddFmgLibLocalization();
```
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 (
```CSharp
builder.Services.AddFmgLibLocalization();
builder.Services.AddFmgLibLocalization(defaultLang:"en-US");
builder.Services.AddFmgLibLocalization(defaultLang:"en-US", "Loc1.json", "Loc2.json");
```
), will look for a json file named `Localization.json` in the home directory.
if you give one or more parameters like
```CSharp
builder.Services.AddFmgLibLocalization("Localization1.json", "Localization2.json", "/Languages/Temp1.json");
```
it will read json files in given file paths.
Proper json format:
```json
{
"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
```CSharp
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
```CSharp
Console.WriteLine("keyWord 1".ToTranslate("tr-TR"));
```
.