init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
74
Framework/Util/LanguageUtil.cs
Normal file
74
Framework/Util/LanguageUtil.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Kreta.Framework.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// LCID alapján megmondja, hogy hanyadik indexű nyelv mezőt kell nézni.
|
||||
/// </summary>
|
||||
public class LanguageUtil
|
||||
{
|
||||
static Dictionary<string, int> m_LanguageIndexes = null;
|
||||
|
||||
private static LanguageUtil _instance;
|
||||
public static LanguageUtil Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new LanguageUtil();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private LanguageUtil()
|
||||
{
|
||||
InitializeLanguageIndexes();
|
||||
}
|
||||
|
||||
static void InitializeLanguageIndexes()
|
||||
{
|
||||
Dictionary<string, int> result = new Dictionary<string, int>();
|
||||
using (SDA.DataProvider.SDAConnection connection = SDAServer.Instance.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
using (SDA.DataProvider.SDACommand command = connection.CreateCommand())
|
||||
{
|
||||
command.CommandText = @"select C_VALUE from T_SYSTEMPARAMETER where C_NAME = 'LANGUAGES'";
|
||||
string temp = command.ExecuteScalar() as string;
|
||||
if (temp != null)
|
||||
{
|
||||
string[] languages = temp.Split(',', ';');
|
||||
for (int index = 0; index < languages.Length; index++)
|
||||
{
|
||||
result[languages[index].Trim().ToLower()] = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_LanguageIndexes = result;
|
||||
}
|
||||
|
||||
public int GetLanguageIndex(int LCID)
|
||||
{
|
||||
var cultureInfo = new CultureInfo(LCID);
|
||||
|
||||
string key = cultureInfo.Name.ToLower().Substring(0, 2);
|
||||
if (m_LanguageIndexes.TryGetValue(key, out int value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!cultureInfo.IsNeutralCulture)
|
||||
{
|
||||
return GetLanguageIndex(cultureInfo.Parent.LCID);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue