-
Notifications
You must be signed in to change notification settings - Fork 0
/
Language.cs
47 lines (40 loc) · 1.34 KB
/
Language.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Copyright (c) 2018-2020 Daniel Strayker Nowak
All rights reserved
*/
using ChangeLog_Generator.Properties;
namespace ChangeLog_Generator
{
// Simple class for language support,
public class Language
{
// Name can contain "en" or "pl", another strings won't work,
private string Name;
private readonly string[] SupportedLanguages = { "en", "pl" };
// Constructor, reads saved language:
public Language()
{
Name = Settings.Default.lang;
}
// Method for saving language setting to setting.settings in Properties of project:
public void SaveLang()
{
Settings.Default.lang = Name;
Settings.Default.Save();
}
// Method for setting new language, returns true if operation is complete, false if there's error with lang code:
public bool SetLang(string langchar)
{
// Checks supported languages:
for (int i = 0; i < SupportedLanguages.Length; i++)
{
if (langchar == SupportedLanguages[i]) break;
}
Name = langchar;
SaveLang();
return true;
}
// Method for returning actual language:
public string GetLang() { return Name; }
}
}