Commit aa5e55a0 LN

中英文优化

1 个父辈 23b1e36c
...@@ -118,8 +118,8 @@ ...@@ -118,8 +118,8 @@
<Compile Include="manager\PTipSoundProcess.cs" /> <Compile Include="manager\PTipSoundProcess.cs" />
<Compile Include="deviceLibrary\led\LedManager.cs" /> <Compile Include="deviceLibrary\led\LedManager.cs" />
<Compile Include="manager\LineWidthManager.cs" /> <Compile Include="manager\LineWidthManager.cs" />
<Compile Include="manager\ResourceControl.cs" />
<Compile Include="deviceLibrary\ledLabel\ScanRequestLabel.cs" /> <Compile Include="deviceLibrary\ledLabel\ScanRequestLabel.cs" />
<Compile Include="manager\ResourceControl.cs" />
<Compile Include="manager\work\StockInfo.cs" /> <Compile Include="manager\work\StockInfo.cs" />
<Compile Include="manager\work\TSAVBean.cs" /> <Compile Include="manager\work\TSAVBean.cs" />
<Compile Include="manager\work\TSAVBean_Partial.cs" /> <Compile Include="manager\work\TSAVBean_Partial.cs" />
...@@ -132,10 +132,15 @@ ...@@ -132,10 +132,15 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="manager\AlarmType.cs" /> <Compile Include="manager\AlarmType.cs" />
<Compile Include="manager\BoardManager.cs" /> <Compile Include="manager\BoardManager.cs" />
<Compile Include="resource\BaseResourceControl.cs" />
<Compile Include="resource\NCsvResourceControl.cs" />
<Compile Include="resource\ResourceCulture.cs" />
<Compile Include="resource\SysResourceControl.cs" />
<Compile Include="smf\MyWebClient.cs"> <Compile Include="smf\MyWebClient.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="smf\ServerCommunication.cs" /> <Compile Include="smf\ServerCommunication.cs" />
<Compile Include="smf\SMF.cs" />
<Compile Include="SQLite.cs" /> <Compile Include="SQLite.cs" />
<Compile Include="tool\HandRecordManager.cs" /> <Compile Include="tool\HandRecordManager.cs" />
<Compile Include="tool\HVideoManager.cs" /> <Compile Include="tool\HVideoManager.cs" />
...@@ -202,6 +207,7 @@ ...@@ -202,6 +207,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.113.3\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.113.3\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" /> <Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.113.3\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.113.3\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
......
...@@ -26,18 +26,23 @@ namespace TSA_V ...@@ -26,18 +26,23 @@ namespace TSA_V
public static event GetLanDelegate GetLanEvent; public static event GetLanDelegate GetLanEvent;
public static string GetString(string id,string defaultStr) public static string GetString(string id,string defaultStr)
{ {
string result = GetStrEvent?.Invoke(id, defaultStr); return ResourceCulture.GetString(id, defaultStr);
return result;
//string result = GetStrEvent?.Invoke(id, defaultStr);
//return result;
} }
public static string GetString(string id, string defaultStr, params object[] param) public static string GetString(string id, string defaultStr, params object[] param)
{ {
string result = GetStringEvent?.Invoke(id, defaultStr,param); return ResourceCulture.GetString(id, defaultStr,param);
return result; //string result = GetStringEvent?.Invoke(id, defaultStr,param);
//return result;
} }
public static string GetLanguage( ) public static string GetLanguage()
{ {
string result = GetLanEvent?.Invoke(); return ResourceCulture.GetLanguage();
return result;
//string result = GetLanEvent?.Invoke();
//return result;
} }
/// <summary> /// <summary>
/// 宽度 /// 宽度
......
using log4net;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using TSA_V.Common;
namespace TSA_V
{
public class BaseResourceControl
{
public static readonly ILog LOG = LogManager.GetLogger("LngResource");
public Dictionary<string, Dictionary<string, string>> LangMap = new Dictionary<string, Dictionary<string, string>>();
public Dictionary<string, string> defaultMap = new Dictionary<string, string>();
public virtual void SetCurrentCulture(string name)
{
//ResourceControl.GetStrEvent += GetString;
//ResourceControl.GetStringEvent += GetString;
//ResourceControl.GetLanEvent += GetLanguage;
//UserFromControl.UserControlResource.GetStrEvent += GetString;
//UserFromControl.UserControlResource.GetStringEvent += GetString;
if (string.IsNullOrEmpty(name))
{
name = "en-US";
}
//CurrLanguage = name;
Thread.CurrentThread.CurrentCulture = new CultureInfo(name);
}
public virtual string GetString(string id, params object[] param)
{
return GetString(id, id, param);
}
public virtual string GetString(string id, string defaultStr)
{
string strCurLanguage = "";
try
{
// 使用入口程序集(EXE)来查找资源,避免在库(DeviceLibrary)程序集内找不到资源的问题
Assembly entryAsm = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly() ?? Assembly.GetExecutingAssembly();
ResourceManager rm = new ResourceManager("TSA_V.Properties.Resource", entryAsm);
CultureInfo ci = Thread.CurrentThread.CurrentCulture;
strCurLanguage = rm.GetString(id, ci).Trim();
if (strCurLanguage.Equals("") && (!defaultStr.Equals("")))
{
strCurLanguage = defaultStr;
NoIdLog(id, defaultStr);
}
}
catch (Exception ex)
{
if (defaultStr.Equals(""))
{
}
else
{
strCurLanguage = "No id:[" + id + "], please add.";
strCurLanguage = defaultStr;
NoIdLog(id, defaultStr);
}
}
return strCurLanguage;
}
public virtual string GetString(string id, string defaultStr, params object[] param)
{
string strCurLanguage = "";
try
{
// 使用入口程序集(EXE)来查找资源,避免在库(DeviceLibrary)程序集内找不到资源的问题
Assembly entryAsm = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly() ?? Assembly.GetExecutingAssembly();
ResourceManager rm = new ResourceManager("TSA_V.Properties.Resource", entryAsm);
CultureInfo ci = Thread.CurrentThread.CurrentCulture;
strCurLanguage = rm.GetString(id, ci).Trim();
if (strCurLanguage.Equals("") && (!defaultStr.Equals("")))
{
strCurLanguage = defaultStr;
NoIdLog(id, defaultStr);
}
}
catch (Exception ex)
{
if (defaultStr.Equals(""))
{
}
else
{
strCurLanguage = "No id:[" + id + "], please add.";
strCurLanguage = defaultStr;
NoIdLog(id, defaultStr);
}
}
return String.Format(strCurLanguage, param);
}
protected virtual void NoIdLog(string id, string defaultStr)
{
LogUtil.debug("No id:[" + id + "], please add,use default string :" + defaultStr);
if (!defaultMap.ContainsKey(id))
{
defaultMap.Add(id, defaultStr);
}
}
public virtual void LogDefaultMap()
{
if (defaultMap == null || defaultMap.Count <= 0)
{
return;
}
//LogUtil.info("开始打印缺少的文字配置" + defaultMap.Count);
StringBuilder builder = new StringBuilder();
builder.Append("开始打印缺少的文字配置" + defaultMap.Count + "\r\n");
foreach (string key in defaultMap.Keys)
{
string value = defaultMap[key];
builder.Append($"<data name = \"{key}\" xml:space = \"preserve\"> <value> {value} </value> </data> \r\n");
//LogUtil.info(" 缺少文字配置[" + key + "] 默认值[" + value + "]");
}
builder.Append("结束打印缺少的文字配置");
LogUtil.info(builder.ToString());
}
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using TSA_V.Common;
namespace TSA_V
{
public class SysResourceControl:BaseResourceControl
{
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSA_V.Common;
namespace TSA_V.Common
{
public class SMF
{
public static string DeviceType = "20117";
static string _server = Setting_NInit.App_Server;
static string server
{
get
{
//_server = "http://192.168.1.243/smf-core";
if (_server.EndsWith("/"))
{
return _server.Remove(_server.Length - 1, 1);
}
else
return _server;
}
}
public static bool UploadLangJsonData(string json, out SmfResult smfResult)
{
var insertindex = json.IndexOf("{");
json = json.Insert(insertindex + 1, "\"type\": \"" + DeviceType + "\",");
return UploadJsonData("/api/translation/resource", json, out smfResult);
}
public static bool UploadJsonData(string api, string json, out SmfResult smfResult)
{
smfResult = new SmfResult();
if (string.IsNullOrEmpty(server))
return false;
try
{
MyWebClient wc = new MyWebClient(10 * 1000);
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
var resp = wc.UploadData(server + api, Encoding.UTF8.GetBytes(json));
smfResult = JsonHelper.DeserializeJsonToObject<SmfResult>(Encoding.UTF8.GetString(resp));
}
catch (Exception e)
{
LogUtil.info($"UploadJsonData:{api}" + e.ToString());
}
return smfResult.okResult;
}
public static List<SmfLangData> DownloadLngData()
{
string api = "/api/translation/resource?type=" + DeviceType;
try
{
MyWebClient wc = new MyWebClient(10 * 1000);
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
var resp = wc.DownloadData(server + api);
var jsondata = Encoding.UTF8.GetString(resp);
return JsonConvert.DeserializeObject<List<SmfLangData>>(jsondata);
}
catch (Exception e)
{
LogUtil.info($"DownloadLngData:{api}" + e.ToString());
}
return new List<SmfLangData>();
}
}
//{"code":0,"data":"ok","msg":"ok","msgKey":"smfcore.ok","okResult":true}
public class SmfResult
{
public int code;
public string data;
public string msg;
public string msgKey;
public bool okResult;
}
public class SmfLangData
{
public string lanCode;
public Dictionary<string, string> resourceMap;
}
}
...@@ -104,6 +104,16 @@ ...@@ -104,6 +104,16 @@
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n" />
</layout> </layout>
</appender> </appender>
<appender name="LngResource" type="log4net.Appender.RollingFileAppender">
<file value="logs/LngResource.log" />
<param name="Encoding" value="UTF-8" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<appender name="MetcalLogAppender" type="log4net.Appender.RollingFileAppender"> <appender name="MetcalLogAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/metcal/NW_revicedata.log" /> <file value="logs/metcal/NW_revicedata.log" />
<param name="Encoding" value="UTF-8" /> <param name="Encoding" value="UTF-8" />
...@@ -122,6 +132,10 @@ ...@@ -122,6 +132,10 @@
<level value="Info" /> <level value="Info" />
<appender-ref ref="MetcalLogAppender" /> <appender-ref ref="MetcalLogAppender" />
</logger> </logger>
<logger name="LngResource">
<level value="Info" />
<appender-ref ref="LngResource" />
</logger>
</log4net> </log4net>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
......
...@@ -55,8 +55,11 @@ namespace TSA_V ...@@ -55,8 +55,11 @@ namespace TSA_V
{ {
Setting_NInit.Data_LastOpenImagePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); Setting_NInit.Data_LastOpenImagePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
} }
}
UserFromControl.UserControlResource.GetStrEvent += ResourceCulture.GetString;
UserFromControl.UserControlResource.GetStringEvent += ResourceCulture.GetString;
}
private void AGerberController_ErrorLogEvent(Exception ex) private void AGerberController_ErrorLogEvent(Exception ex)
{ {
LogUtil.error("AGerberController_ErrorLogEvent: " + ex.ToString()); LogUtil.error("AGerberController_ErrorLogEvent: " + ex.ToString());
......
...@@ -368,7 +368,6 @@ ...@@ -368,7 +368,6 @@
<DependentUpon>FrmCodeInPut.cs</DependentUpon> <DependentUpon>FrmCodeInPut.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="workForm\PointDisplay.cs" /> <Compile Include="workForm\PointDisplay.cs" />
<Compile Include="ResourceCulture.cs" />
<Compile Include="workForm\FrmSolderingMsg.cs"> <Compile Include="workForm\FrmSolderingMsg.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
...@@ -629,6 +628,9 @@ ...@@ -629,6 +628,9 @@
<Content Include="hands\config.ini"> <Content Include="hands\config.ini">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<None Include="languageResources\resourcesAll.lngres">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\app.manifest" /> <None Include="Properties\app.manifest" />
<Content Include="image\form\NS.ico"> <Content Include="image\form\NS.ico">
......
...@@ -133,19 +133,18 @@ namespace TSA_V ...@@ -133,19 +133,18 @@ namespace TSA_V
int pcbRowValue = FormUtil.GetIntValue(txtRowS); int pcbRowValue = FormUtil.GetIntValue(txtRowS);
int pcbColValue = FormUtil.GetIntValue(txtColS); int pcbColValue = FormUtil.GetIntValue(txtColS);
if (pcbRow < 1) if (pcbRow < 1 || pcbCol < 1)
{ {
MessageBox.Show(ResourceCulture.GetString("PcbRowInvalid", "行数必须大于等于1!"), MessageBox.Show(ResourceCulture.GetString("PcbRowColInvalid", "行列数必须都大于等于1!"),
ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning); ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
if (pcbRow < 1)
{
numRow.Focus(); numRow.Focus();
return;
} }
if(pcbCol < 1)
if (pcbCol < 1)
{ {
MessageBox.Show(ResourceCulture.GetString("PcbColInvalid", "列数必须大于等于1!"),
ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
numCol.Focus(); numCol.Focus();
}
return; return;
} }
...@@ -201,20 +200,31 @@ namespace TSA_V ...@@ -201,20 +200,31 @@ namespace TSA_V
ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning); ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
} }
if (pcbRowValue <= 0 || pcbColValue <= 0) if (pcbRowValue <= 0)
{
MessageBox.Show(ResourceCulture.GetString("PcbRowValueInvalid", "行间距必须大于0!"),
ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtRowS.Focus();
return;
}
if (pcbColValue <= 0)
{ {
MessageBox.Show(ResourceCulture.GetString("PcbSpacingInvalid", "行/列间距必须都大于0!"), MessageBox.Show(ResourceCulture.GetString("PcbColValueInvalid", "列间距必须大于0!"),
ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning); ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtColS.Focus();
return; return;
} }
if (currBoardInfo == null) if (currBoardInfo == null)
{ {
MessageBox.Show(ResourceCulture.GetString("BoardNull", "板卡信息为空,无法测试。")); MessageBox.Show(ResourceCulture.GetString("BoardNull", "板卡信息为空,无法测试。"));
LogUtil.info("板卡信息为空,无法测试");
return; return;
} }
if (currBoardInfo.smtList == null || currBoardInfo.smtList.Count == 0) if (currBoardInfo.smtList == null || currBoardInfo.smtList.Count == 0)
{ {
MessageBox.Show(ResourceCulture.GetString("NoPoints", "当前程序没有组装点,无法测试。")); MessageBox.Show(ResourceCulture.GetString("NoPoints", "当前程序没有组装点,无法测试。"));
LogUtil.info("当前程序没有组装点,无法测试");
return; return;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!