SatsuiLocalization is a library containing a translation system i created for my own WPF projects.
You can change the language on the fly.
It's easy, fast to use and free.
The Nuget package is available here : https://www.nuget.org/packages/Messatsu.SatsuiLocalization/
PM> Install-Package Messatsu.SatsuiLocalization
When the Nuget package is installed, instantiate a Translation object then load a XML file or an embed resource containing the language definition :
Translation myLang = new Translation();
myLang.LoadFile("path-to-the-xml-file.xml");
// Or myLang.LoadResource("MyProject.Folder.XmlFile.xml");
// Don't forget to set your resource as an embed resource !
You can also use statics functions of the Translation class :
Translation myLang = Translation.FromFile("path-to-the-xml-file.xml");
Translation myLang = Translation.FromResource("MyProject.Folder.XmlFile.xml");
Example of a basic language definition file :
<?xml version="1.0" encoding="utf-8" ?>
<lang name="English" author="SatsuiBird">
<general>
<copy>Copy</copy>
<paste>Paste</paste>
<exit>Exit</exit>
</general>
<main-window>
<tb-test>Im a text $ln with a newline !</tb-text>
<btn-test>Im a test button</btn-test>
</main-window>
<messages>
<test-parameter>Your parameter is : $p</test-parameter>
<test-variable>My variable is : $myvar</test-variable>
</messages>
</lang>
Now the language is loaded, you just have to call the Translate function, giving it the control to translate and a XML root element :
// Called from the code-behind of MainWindow.xaml
myLang.Translate(this, "main-window");
So, in the XMAL definition of MainWindow, i just have to set properties as id:
<TextBlock Text="id:tb-test"/>
<Button Content="id:btn-test"/>
Here, tb-test and btn-test are found because we passed main-window as the root element.
But you can access parents elements if you use a slash before the node name :
<TextBlock Text="id:/general/copy"/>
You can access it with the function GetString givint it the path and an optional parameter :
string result = myLang.GetString("messages/test-parameter", "my parameter");
In the language file, the node test-parameter is defined as "Your parameter is : $p".
So, SatsuiLocalization will replace $p by the parameter passed to GetString and will return "Your parameter is : my parameter".
As we have seen, SatsuiLocalization use $p and $ln variables, but you can add your own variables.
It's useful when you need to show informations which are not language related, like application name, version, ...
You can do it with the static function AddVar of the Translation class.
Translation.AddVar("myvar", "hello world");
In the language file, the node test-variable is defined as "My variable is : $myvar" :
// Will return : My variable is : hello world
string reuslt = myLang.GetString("messages/test-variable");
If you created your own control with custom properties which are not managed by SatsuiLocalization, you can use the function AddCustomControl. There is an example in DemoWPF.
myLang.AddCustomControl(typeof(YourControlClass), "CustomProperty1", "CustomProperty2", ...);
SatsuiUi
Set of controls and skins for WPF applications
https://github.com/SatsuiBird/SatsuiUiDemo
SatsuiMemory
Read and edit applications memory easily
https://github.com/SatsuiBird/SatsuiMemoryDemo
SatsuiOverlay
Create customizable HTTP widgets
https://github.com/SatsuiBird/SatsuiOverlayDemo
