1
1
# Rasyidf Localization
2
- ![ Nuget] ( https://img.shields.io/nuget/dt/Rasyidf.Localization?style=flat-square )
2
+ ![ Nuget] ( https://img.shields.io/nuget/dt/Rasyidf.Localization )
3
3
4
4
Fast and simple localization framework for wpf. allow dynamic loading and multiple language pack.
5
5
@@ -28,9 +28,9 @@ Then register the the services on App.cs
28
28
29
29
### Usage
30
30
31
- then add namespace in the xaml
31
+ after installing and loading th assembly , add namespace in the xaml
32
32
``` xml
33
- xmlns:rf= " clr-namespace:Rasyidf.Localization;assembly=Rasyidf.Localization"
33
+ xmlns :rf = " clr-namespace:Rasyidf.Localization;assembly=Rasyidf.Localization"
34
34
```
35
35
All set , now you can implement Binding in any XAML like this :
36
36
@@ -44,31 +44,30 @@ Or this
44
44
``` xml
45
45
< TextBlock Text = " {rf:Tr Default='Default Hello World', Uid=11}" / >
46
46
< TextBlock Text = " {rf:Tr FallBackText, Uid=12}" / >
47
- Or this , with Format String
48
47
```
49
-
48
+ Or this , with Format String
50
49
``` xml
51
50
<TextBlock >
52
- <Run >
53
- <rf :Tr Uid = " 24" Default = " Language : {0}, Count : {1} " >
54
- < Binding FallbackValue = " en-US" Mode = " OneWay"
55
- Path = " CurrentLanguage" / >
56
- < Binding FallbackValue = " 0" Mode = " OneWay"
57
- Path = " LanguageCount" / >
58
- < / rf : Tr >
59
- < / Run >
51
+ <Run >
52
+ <rf :Tr Uid = " 24" Default = " Language : {0}, Count : {1} " >
53
+ < Binding FallbackValue = " en-US" Mode = " OneWay"
54
+ Path = " CurrentLanguage" / >
55
+ < Binding FallbackValue = " 0" Mode = " OneWay"
56
+ Path = " LanguageCount" / >
57
+ < / rf : Tr >
58
+ < / Run >
60
59
< / TextBlock >
61
60
```
62
61
63
62
in code , you can consume directly by using :
64
63
65
64
```csharp
66
- MessageBox .Show (LocalizationService .GetString ("511", "Text ", "Default Message "),LocalizationService .GetString ("511", "Header ","Default Title "));
65
+ MessageBox .Show (LocalizationService .GetString ("511", "Text ", "Default Message "),LocalizationService .GetString ("511", "Header ","Default Title "));
67
66
```
68
67
another way is to use String extension. `"[uid ],[vid ]".Localize ("[Default ]")`
69
68
70
69
```csharp
71
- MessageBox .Show ("511,Text".Localize("Default Message "),("511,Header").Localize ("Default Title "));
70
+ MessageBox .Show ("511,Text".Localize("Default Message "),("511,Header").Localize ("Default Title "));
72
71
```
73
72
74
73
### Language Packs
@@ -95,7 +94,7 @@ The Language Pack can be XML or JSON like below, put in the language folder:
95
94
96
95
> Version 0 . 5 Support Json Multilingual Package .
97
96
98
- ##### Multi Language Pack
97
+ ##### Single Language Pack
99
98
100
99
```json
101
100
{ " AppId" : " YourAppId" ,
@@ -119,12 +118,10 @@ The Language Pack can be XML or JSON like below, put in the language folder:
119
118
" Author" : " Rasyid" ,
120
119
" Languages" : [
121
120
{
122
- " CultureId" : " en-US" ,
123
- ....
121
+ " CultureId" : " en-US"
124
122
},
125
123
{
126
- " CultureId" : " de-DE" ,
127
- ....
124
+ " CultureId" : " de-DE"
128
125
}
129
126
],
130
127
@@ -139,6 +136,7 @@ The Language Pack can be XML or JSON like below, put in the language folder:
139
136
},
140
137
]
141
138
}
139
+ ]
142
140
}
143
141
}
144
142
```
0 commit comments