Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ex-exe/stringlocalizationgenerator
Generate C# source for localization from json file.
https://github.com/ex-exe/stringlocalizationgenerator
csharp generator localization wpf
Last synced: about 2 months ago
JSON representation
Generate C# source for localization from json file.
- Host: GitHub
- URL: https://github.com/ex-exe/stringlocalizationgenerator
- Owner: EX-EXE
- License: mit
- Created: 2023-11-04T08:15:09.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-24T13:35:46.000Z (12 months ago)
- Last Synced: 2024-04-26T15:47:06.955Z (9 months ago)
- Topics: csharp, generator, localization, wpf
- Language: C#
- Homepage:
- Size: 1.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![NuGet version](https://badge.fury.io/nu/StringLocalizationGenerator.svg)](https://badge.fury.io/nu/StringLocalizationGenerator)
# StringLocalizationGenerator
Generate C# source for localization from json file.| | |
|---|---|
| ![preview](https://user-images.githubusercontent.com/114784289/280459762-728222c9-7fa1-45a4-ab21-3e1bd90c8f88.gif) | ![source](https://user-images.githubusercontent.com/114784289/280459845-4d635ad1-7385-4144-b5f9-be71906cb02f.png) ![source](https://user-images.githubusercontent.com/114784289/280460029-613b3a3c-8f27-4690-ad60-00eb34de636c.png) |# How To Use
## Install by nuget
PM> Install-Package [StringLocalizationGenerator](https://www.nuget.org/packages/StringLocalizationGenerator)## Create Json File(StringLocalization.json)
```json
# Configuration
{
"[STRING_ID]": {
"[LANGUAGE1]": "[TEXT1]",
"[LANGUAGE2]": "[TEXT2]",
"[LANGUAGE3]": "[TEXT3]",
"[LANGUAGE...]": "[TEXT...]",
"[default(Options)]": "[Text(if Language does not exist)]"
},
"[STRING_ID2]": {
"[LANGUAGE1]": "[TEXT1]",
"[LANGUAGE...]": "[TEXT...]"
}
}
```
```json
# Sample
{
"ID_YES": {
"EN": "yes",
"JP": "はい"
},
"ID_NO": {
"EN": "no",
"JP": "いいえ"
},
"ID_TEST": {
"JP": "テスト",
"default": "test"
}
}
```## Add \ to .csproj
```xml
```
## (WPF Only) Add DefineConstants to .csproj
```xml
$(DefineConstans);WITH_STRING_LOCALIZATION_WPF_MARKUP
```
## (Avalonia Only) Add DefineConstants to .csproj And
Create StringLocalizationGenerator.BindingExtension.cs File
```xml
$(DefineConstans);WITH_STRING_LOCALIZATION_AVALONIA_MARKUP
```
```csharp
namespace StringLocalizationGenerator;
public partial class BindingExtension
{
}
```## Use xaml Or axaml
```xaml
```
## Change Language
```csharp
StringLocalizationManager.ChangeLanguage(languageName);
// ex. StringLocalizationManager.ChangeLanguage("en");
```# Previous Versions
Version 1
# How To Use
## Install by nuget
PM> Install-Package [StringLocalizationGenerator](https://www.nuget.org/packages/StringLocalizationGenerator)## Create Languages Json File(StringLocalization.json)
```json
# Configuration
{
"[STRING_ID]": {
"[LANGUAGE1]": "[TEXT1]",
"[LANGUAGE2]": "[TEXT2]",
"[LANGUAGE3]": "[TEXT3]",
"[LANGUAGE...]": "[TEXT...]",
"[default(Options)]": "[Text(if Language does not exist)]"
},
"[STRING_ID2]": {
"[LANGUAGE1]": "[TEXT1]",
"[LANGUAGE...]": "[TEXT...]"
}
}
```
```json
# Sample
{
"ID_YES": {
"EN": "yes",
"JP": "はい"
},
"ID_NO": {
"EN": "no",
"JP": "いいえ"
},
"ID_TEST": {
"JP": "テスト",
"default": "test"
}
}
```
## (WPF Only) Add OutputWpfMarkupExtension to .csproj
```xml
Enable
```
## (Avalonia Only) Add OutputAvaloniaMarkupExtension to .csproj And
Create StringLocalizationGenerator.BindingExtension.cs File
```xml
Enable
```
```csharp
namespace StringLocalizationGenerator;
public partial class BindingExtension
{
}
```## Use xaml Or axaml
```xaml
```
## Change Language
```csharp
StringLocalizationManager.ChangeLanguage(languageName);
// ex. StringLocalizationManager.ChangeLanguage("en");
```