HaemmerElectronics.SeppPenner.Language 1.0.0.9

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package HaemmerElectronics.SeppPenner.Language --version 1.0.0.9                
NuGet\Install-Package HaemmerElectronics.SeppPenner.Language -Version 1.0.0.9                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HaemmerElectronics.SeppPenner.Language" Version="1.0.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HaemmerElectronics.SeppPenner.Language --version 1.0.0.9                
#r "nuget: HaemmerElectronics.SeppPenner.Language, 1.0.0.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HaemmerElectronics.SeppPenner.Language as a Cake Addin
#addin nuget:?package=HaemmerElectronics.SeppPenner.Language&version=1.0.0.9

// Install HaemmerElectronics.SeppPenner.Language as a Cake Tool
#tool nuget:?package=HaemmerElectronics.SeppPenner.Language&version=1.0.0.9                

CSharpLanguageManager

CSharpLanguageManager is an assembly/ library to build multilingual programms in .Net. The assembly was written and tested in .Net 4.7.

Build status GitHub issues GitHub forks GitHub stars GitHub license Nuget NuGet Downloads

Basic usage:

If you just have one language loaded, you don't need to set the current language as the language manager uses the only language as default.

public void Test()
{
	ILanguageManager _lm = new LanguageManager();
	var test = _lm.GetCurrentLanguage().GetWord("YourKey");
}

If you have more than one language loaded, you need to set the current (wanted) language. The language identifiers are taken from https://msdn.microsoft.com/de-de/library/ee825488(v=cs.20).aspx.

public void Test()
{
	ILanguageManager _lm = new LanguageManager();
	_lm.SetCurrentLanguage("de-DE"); //Version 1.0.0.0 to Version 1.0.0.3
	_lm.SetCurrentLanguageFromName("German"); //Version 1.0.0.4 and above
	var test = _lm.GetCurrentLanguage().GetWord("YourKey");
}

Subscription to OnLanguageChanged Version 1.0.0.4 and above:

You can "subscribe" to the EventHandler OnLanguageChanged to update your GUI whenever the language is changed. This can be done like the following: (For more information see the example project)

namespace TestLanguage
{
    public partial class Main : Form
    {
        private readonly ILanguageManager _lm = new LanguageManager();
        private ILanguage _lang;

        public Main()
        {
            InitializeComponent();
            InitializeLanguageManager();
            LoadLanguagesToCombo();
        }

        private void InitializeLanguageManager()
        {
            _lm.SetCurrentLanguage("de-DE");
            _lm.OnLanguageChanged += OnLanguageChanged;
        }

        private void LoadLanguagesToCombo()
        {
            foreach (var lang in _lm.GetLanguages())
                comboBoxLanguage.Items.Add(lang.Name);
            comboBoxLanguage.SelectedIndex = 0;
        }

        private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            _lm.SetCurrentLanguageFromName(comboBoxLanguage.SelectedItem.ToString());
        }

        private void OnLanguageChanged(object sender, EventArgs eventArgs)
        {
            _lang = _lm.GetCurrentLanguage();
            labelSelectLanguage.Text = _lang.GetWord("SelectLanguage");
        }
    }
}

where the basic change is that the _lm.SetCurrentLanguage() handling was simplified by setting it via the language name, too:

_lm.SetCurrentLanguageFromName(comboBoxLanguage.SelectedItem.ToString());

Subscription to OnLanguageChanged Version 1.0.0.0 to 1.0.0.3:

You can "subscribe" to the EventHandler OnLanguageChanged to update your GUI whenever the language is changed. This can be done like the following: (For more information see the example project)

using System;
using System.Windows.Forms;
using Languages.Implementation;
using Languages.Interfaces;

namespace TestLanguage
{
    public partial class Main : Form
    {
        private readonly ILanguageManager _lm = new LanguageManager();
        private ILanguage _lang;

        public Main()
        {
            InitializeComponent();
            InitializeLanguageManager();
            LoadLanguagesToCombo();
        }

        private void InitializeLanguageManager()
        {
            _lm.SetCurrentLanguage("de-DE");
            _lm.OnLanguageChanged += OnLanguageChanged;
        }

        private void LoadLanguagesToCombo()
        {
            foreach (var lang in _lm.GetLanguages())
                comboBoxLanguage.Items.Add(lang.Name);
            comboBoxLanguage.SelectedIndex = 0;
        }

        private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBoxLanguage.SelectedItem.ToString())
            {
                case "German":
                    _lm.SetCurrentLanguage("de-DE");
                    break;
                case "English (US)":
                    _lm.SetCurrentLanguage("en-US");
                    break;
            }
        }

        private void OnLanguageChanged(object sender, EventArgs eventArgs)
        {
            _lang = _lm.GetCurrentLanguage();
            labelSelectLanguage.Text = _lang.GetWord("SelectLanguage");
        }
    }
}

How do the language files need to look like:

The file's naming is not important but should be something like "de-DE.xml". All language files need to be included into the "languages" folder in your application folder.

<?xml version="1.0" encoding="UTF-8" ?>
<Language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    
    <Identifier>de-DE</Identifier> 
	<Name>German<Name>
	<Words>
		<Word>
			<Key>YourKey</Key>
			<Value>TestString</Value>
		</Word>
	</Words>
</Language>

An example project can be found here. The project can be found on nuget.

Change history

  • Version 1.0.0.9 (2018-02-11) : Updated the .Net 4.5 and .Net 4.6.2 dll files, too.
  • Version 1.0.0.8 (2018-01-22) : Added .Net 4.7. dll.
  • Version 1.0.0.7 (2017-08-16) : Adjusted ReloadLanguages() method to work properly.
  • Version 1.0.0.6 (2017-08-16) : Added ReloadLanguages() method to ILanguageManager.
  • Version 1.0.0.5 (2017-05-14) : Added documentation.
  • Version 1.0.0.4 (2017-03-24) : Again simplified the usage of languages.
  • Version 1.0.0.3 (2017-03-21) : Simplified the usage of languages.
  • Version 1.0.0.2 (2017-02-17) : Code review.
  • Version 1.0.0.1 (2016-12-06) : Added EventHandler to subscribe to Event.
  • Version 1.0.0.0 (2016-12-06) : 1.0 release.
Product Compatible and additional computed target framework versions.
.NET Framework net2045 is compatible.  net2046 is compatible.  net2047 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.5 94 5/16/2024
1.1.4 249 12/7/2023
1.1.3 116 11/13/2023
1.1.2 435 11/10/2022
1.1.1 336 10/30/2022
1.1.0 508 2/8/2022
1.0.11 315 11/11/2021
1.0.10 320 8/9/2021
1.0.9 339 7/25/2021
1.0.8 357 2/21/2021
1.0.7 550 11/11/2020
1.0.6 515 6/5/2020
1.0.5 533 11/8/2019
1.0.4.1 541 10/28/2019
1.0.4 632 10/13/2019
1.0.3 557 9/29/2019
1.0.2 551 9/29/2019
1.0.1 592 6/23/2019
1.0.0.12 623 5/5/2019
1.0.0.11 1,083 3/15/2018
1.0.0.10 1,061 3/12/2018
1.0.0.9 1,058 2/11/2018
1.0.0.8 1,135 1/22/2018
1.0.0.7 1,156 8/18/2017
1.0.0.6 954 8/16/2017
1.0.0.5 1,020 8/10/2017

Version 1.0.0.9 (2018-02-11) : Updated the .Net 4.5 and .Net 4.6.2 dll files, too.
Version 1.0.0.8 (2018-01-22) : Added .Net 4.7. dll.
Version 1.0.0.7 (2017-08-18) : Adjusted ReloadLanguages() method to work properly.
Version 1.0.0.6 (2017-08-16) : Added ReloadLanguages() method to ILanguageManager.
Version 1.0.0.5 (2017-05-14) : Added documentation.
Version 1.0.0.4 (2017-03-24) : Again simplified the usage of languages.
Version 1.0.0.3 (2017-03-21) : Simplified the usage of languages.
Version 1.0.0.2 (2017-02-17) : Code review.
Version 1.0.0.1 (2016-12-06) : Added EventHandler to subscribe to Event.
Version 1.0.0.0 (2016-12-06) : 1.0 release.