基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
using Lskj.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.Business.Impl
|
||||
{
|
||||
public sealed class LanguageTranslation
|
||||
{
|
||||
/// <summary>
|
||||
/// 翻译文本存放字典
|
||||
/// </summary>
|
||||
private static Dictionary<string, string> ContrastiveLanguage = new Dictionary<string, string>();
|
||||
/// <summary>
|
||||
/// 是否有可翻译的文本
|
||||
/// </summary>
|
||||
public static bool Translatable = false;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置登录页面语言选项
|
||||
/// </summary>
|
||||
public static DataTable GetLoginLanguage(string Language)
|
||||
{
|
||||
try
|
||||
{
|
||||
//P_language_Login表,配置右键、提示信息、列名
|
||||
DataTable LoginBoxLanguageTable = null;
|
||||
if (BaseImpl.HasExistsTable("P_language_Login"))
|
||||
{
|
||||
LoginBoxLanguageTable = BaseImpl.GetDataTableResult(string.Format("select [中文],[{0}] from P_language_Login", Language));
|
||||
|
||||
}
|
||||
//return DatabasePropertySheet.Rows.Count > 1 ? DatabasePropertySheet : null;
|
||||
return LoginBoxLanguageTable;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置登录页面语言选项
|
||||
/// </summary>
|
||||
public static DataTable GetAllLanguage()
|
||||
{
|
||||
try
|
||||
{
|
||||
DataTable DatabasePropertySheet = null;
|
||||
//P_language表,配置右键、提示信息、列名
|
||||
if (BaseImpl.HasExistsTable("P_language"))
|
||||
{
|
||||
DatabasePropertySheet = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME from information_schema.columns where table_name = 'P_language'"));
|
||||
|
||||
}
|
||||
return DatabasePropertySheet!=null&&DatabasePropertySheet.Rows.Count > 1 ? DatabasePropertySheet : null;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取选中语言的对照文本
|
||||
/// </summary>
|
||||
public static void GetLanguageComparisonTable()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(ERPInfo.Instance.LanguageName))
|
||||
{
|
||||
string sql = string.Format("update P_EmployeeTab set useLanguage=N'{0}' where EmployeeId='{1}'", ERPInfo.Instance.LanguageName, ERPInfo.Instance.UserId);
|
||||
BaseImpl.ExecSqlValue(sql);
|
||||
|
||||
if (ERPInfo.Instance.LanguageName.Equals("中文")) return;
|
||||
|
||||
DataTable languageTable = BaseImpl.GetDataTableResult(string.Format("select [中文],[{0}] from P_language", ERPInfo.Instance.LanguageName));
|
||||
foreach (DataRow item in languageTable.Rows)
|
||||
{
|
||||
if (!ContrastiveLanguage.ContainsKey(item["中文"] + ""))
|
||||
{
|
||||
ContrastiveLanguage.Add(item["中文"] + "", item[ERPInfo.Instance.LanguageName] + "");
|
||||
}
|
||||
}
|
||||
if (ContrastiveLanguage.Count > 0) Translatable = true;
|
||||
|
||||
//DataTable FixedButtonsTable = BaseImpl.GetDataTableResult(string.Format("select [中文],[{0}] from P_FixedButtonsLanguage", ERPInfo.Instance.LanguageName));
|
||||
//foreach (DataRow item in FixedButtonsTable.Rows)
|
||||
//{
|
||||
// if (!ContrastiveLanguage.ContainsKey(item["中文"] + ""))
|
||||
// {
|
||||
// ContrastiveLanguage.Add(item["中文"] + "", item[ERPInfo.Instance.LanguageName] + "");
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 传入文本,获取对应语言的翻译文本
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetTranslatedText(string text)
|
||||
{
|
||||
string value = text;
|
||||
if (ContrastiveLanguage.ContainsKey(text))
|
||||
{
|
||||
value = ContrastiveLanguage[text];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 传入文本,获取对应语言的翻译文本(程序中固定的按钮,右键等)
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
//public static string GetFixedTranslatedText(string text)
|
||||
//{
|
||||
// string value = text;
|
||||
// if (ContrastiveLanguage.ContainsKey(text))
|
||||
// {
|
||||
// value = ContrastiveLanguage[text];
|
||||
// }
|
||||
|
||||
// return value;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 传入表格,翻译对应列的信息(模块信息)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DataTable InitialTableTranslation(DataTable dataTable)
|
||||
{
|
||||
|
||||
foreach (DataRow item in dataTable.Rows)
|
||||
{
|
||||
item["MenuCaption"] = GetTranslatedText(item["MenuCaption"] + "");
|
||||
item["SubSysName"] = GetTranslatedText(item["SubSysName"] + "");
|
||||
item["SearchMenuCaption"] = GetTranslatedText(item["MenuCaption"] + "-" + item["SubSysName"]);
|
||||
}
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 传入表格,翻译指定列信息
|
||||
/// </summary>
|
||||
/// <param name="dataTable">表格数据</param>
|
||||
/// <param name="ccolumnName">需要翻译的列</param>
|
||||
/// <returns></returns>
|
||||
public static DataTable TranslationTableColumn(DataTable dataTable, string ccolumnName)
|
||||
{
|
||||
if (dataTable != null && dataTable.Columns.Contains(ccolumnName))
|
||||
{
|
||||
foreach (DataRow item in dataTable.Rows)
|
||||
{
|
||||
item[ccolumnName] = GetTranslatedText(item[ccolumnName] + "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user