An open API service indexing awesome lists of open source software.

https://github.com/rasyidf/rasyidf.localization

Universal Localization Framework for WPF
https://github.com/rasyidf/rasyidf.localization

extension framework localization localization-kit localization-using-json-files wpf-platform wpf-ui

Last synced: 11 months ago
JSON representation

Universal Localization Framework for WPF

Awesome Lists containing this project

README

          

# Rasyidf Localization
![Nuget](https://img.shields.io/nuget/dt/Rasyidf.Localization)

Fast and simple localization framework for wpf. allow dynamic loading and multiple language pack.

## Getting Started

### Installation
To use this framework. add nuget package:

```powershell
Install-Package Rasyidf.Localization
```

Then register the the services on App.cs

```csharp
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// set the language packs folder and default language
LocalizationService.Current.Initialize("Assets", "en-US");
}
...
```

### Usage

after installing and loading th assembly, add namespace in the xaml
``` xml
xmlns:rf="https://rasyidf.github.io/Rasyidf.Localization"
```
All set, now you can implement Binding in any XAML like this:

Bind like this
``` xml

```

Or this

``` xml

```
Or this, with Format String
``` xml






```

in code, you can consume directly by using :

```csharp
MessageBox.Show(LocalizationService.GetString("511", "Text", "Default Message"),LocalizationService.GetString("511", "Header","Default Title"));
```
another way is to use String extension. `"[uid],[vid]".Localize("[Default]")`

```csharp
MessageBox.Show("511,Text".Localize("Default Message"),("511,Header").Localize("Default Title"));
```

### Language Packs

The Language Pack can be XML or JSON like below, put in the language folder:

> Version 0.5 support some additional metadata (AppId, Author, Type, Version) planned for future version.

#### XML Language Pack

```xml




...

```

#### JSON Language Pack

> Version 0.5 Support Json Multilingual Package.

##### Single Language Pack

```json
{ "AppId" : "YourAppId",
"Version" : "0.5", "Type" : "Single",
"EnglishName": "Indonesian", "CultureName": "Bahasa Indonesia",
"Culture": "id-ID",
"Data": [
{ "Id": 0, "Header": "Judul Jendela" },
{ "Id": 11, "Header": "Berkas" },
{ "Id": 110, "Header": "Keluar" }
]
}
```

##### Multi Language Pack
```json
{
"AppId": "",
"Version": "0.5",
"Type": "Multi",
"Author": "Rasyid",
"Languages": [
{
"CultureId": "en-US"
},
{
"CultureId": "de-DE"
}
],

"Data": [
{
"data": [
{
"Id": 0,
"Text": {
"en-US": "Hello", "de-DE": "Hallo"
}
},
]
}
]
}
}
```

All Done :)

## What is new

0.5.3
* Add Localized String - thanks to [SKProCH](https://github.com/SKProCH)
* Fixed Missing Assets location.

0.5.2
* Now rf:Tr will automatically find Uid and Property name based on markup.
* Fixed json stream error when loading metadata.
* Recreate Demo.WPF because of corrupted file.

0.5.0
* Translation string extension use `"UID, VID".Translate()` to get localized string.
* Multiple Language pack in single file.
* Decouple LanguageStream with Language Item.

0.4.0
* Raw support for xml
* initial json support

## Authors

* **Rasyid, Muhammad Fahmi** - *Initial work* - [Rasyidf](https://github.com/rasyidf)

See also the list of [contributors](https://github.com/rasyidf/rasyidf.Localization/contributors) who participated in this project.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments

See list of third party components for [aditional acknowledgements](https://github.com/rasyidf/rasyidf.Localization/wiki/List-of-Contributors)