Commit 3cff491d LN

1

1 个父辈 ef8df7fc
......@@ -223,6 +223,7 @@ namespace OnlineStore.AutoInOutStore
ResourceCulture.SetCurrentCulture(ResourceCulture.China);
ConfigAppSettings.SaveValue(Setting_Init.Default_Language, ResourceCulture.China);
}
// ResourceCulture.LoaAllRes();
GetVersion();
LogUtil.logBox = this.richTextBox1;
this.ShowInTaskbar = true;
......
......@@ -2,8 +2,10 @@
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
......@@ -44,7 +46,53 @@ namespace OnlineStore.AutoInOutStore
CurrLanguage = name;
Thread.CurrentThread.CurrentCulture = new CultureInfo(name);
}
public static void LoaAllRes()
{
if (rm == null)
{
rm = new ResourceManager("OnlineStore.AutoInOutStore.Properties.Resource", assembly);
}
//CultureInfo ci = Thread.CurrentThread.CurrentCulture;
Dictionary<string, string> chinaMap = GetRMap(China);
Dictionary<string, string> englishMap = GetRMap(English);
List<string> resulList = new List<string>();
foreach(string key in chinaMap.Keys)
{
string china = chinaMap[key];
string english = "";
englishMap.TryGetValue(key, out english);
if (String.IsNullOrEmpty(english))
{
english = "";
}
resulList.Add(key + "," + china.Replace(',', '&') + "," + english.Replace(',', '&'));
}
File.WriteAllLines("D:\\storeResource.csv", resulList.ToArray());
}
private static Dictionary<string ,string > GetRMap(string lan)
{
Dictionary<string, string> chinaMap = new Dictionary<string, string>();
CultureInfo ci = new CultureInfo(lan);
ResourceSet resourceSet = rm.GetResourceSet(ci, true, true);
IDictionaryEnumerator dictNumerator = resourceSet.GetEnumerator();
// Get all string resources
while (dictNumerator.MoveNext())
{
// Only string resources
if (dictNumerator.Value is string)
{
var key = (string)dictNumerator.Key;
var value = (string)dictNumerator.Value;
// yield return new KeyValuePair<string, string>(key, value);
if (!chinaMap.ContainsKey(key))
{
chinaMap.Add(key, value);
}
}
}
return chinaMap;
}
private static string CodeResourceControl_GetLanguageEvent()
{
return CurrLanguage;
......@@ -67,13 +115,13 @@ namespace OnlineStore.AutoInOutStore
}
//CultureInfo ci = Thread.CurrentThread.CurrentCulture;
CultureInfo ci = new CultureInfo(CurrLanguage);
strCurLanguage = rm.GetString(id, ci).Trim();
strCurLanguage = rm.GetString(id, ci).Trim();
if (strCurLanguage.Equals("") && (!defaultStr.Equals("")))
{
strCurLanguage = defaultStr;
NoIdLog(id, defaultStr);
}
}
catch (Exception ex)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!