Asp.net 资源文件翻译助手
来源:互联网 发布:甲骨文软件多少钱 编辑:程序博客网 时间:2024/05/22 08:02
最近项目需要做一个双语的网站,需要将对资源文件进行翻译,在vs里翻译感觉不够方便,参考SimpleResxEditor,自己写了个资源文件编辑助手,自己DIY的才是最好用的,呵呵,软件界面:
使用方法:
实现思路:
1.资源文件对应的实体
namespace ResxEditor{ public class ResourceItem { public ResourceItem() { } public ResourceItem(int id, string key, string value, string comment) { this.ID = id; this.Key = key; this.Value = value; this.Comment = comment; } public int ID { get; set; } public string Key { get; set; } public string Value { get; set; } public string Comment { get; set; } }}
2.读取资源文件的方法
/// <summary> /// 读取资源文件 /// </summary> /// <returns></returns> private List<ResourceItem> GetDicList() { List<ResourceItem> itemList = new List<ResourceItem>(); ResXResourceReader rsxResource = new ResXResourceReader(resourceFilePath); rsxResource.UseResXDataNodes = true; AssemblyName[] referencedAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies(); IDictionaryEnumerator enumerator = rsxResource.GetEnumerator(); int i = 0; while (enumerator.MoveNext()) { DictionaryEntry current = (DictionaryEntry)enumerator.Current; ResXDataNode node = (ResXDataNode)current.Value; string strKey = node.Name; //资源项名 string strValue = node.GetValue(referencedAssemblies).ToString();//值 string strComment = node.Comment; //注释 ResourceItem item = new ResourceItem(i, strKey, strValue, strComment); itemList.Add(item); i++; } return itemList; }3.写入资源文件的方法
private void BtnUpdate_Click(object sender, EventArgs e) { LblResult.Text = ""; //写入键值对 List<ResourceItem> itemList = GetDicList(); ResXResourceWriter rswt = new ResXResourceWriter(resourceFilePath); foreach (ResourceItem item in itemList) { if (string.Compare(item.Key, TxtKey.Text, true) == 0) { ResXDataNode node = new ResXDataNode(item.Key, TxtTranslate.Text.Trim());//将翻译写入Value node.Comment = TxtValue.Text;//将value写入注释 rswt.AddResource(node); } else { ResXDataNode node = new ResXDataNode(item.Key, item.Value); node.Comment = item.Comment; rswt.AddResource(node); } } rswt.Close(); rswt.Dispose(); LblResult.Text = "更新成功!"; LblResult.ForeColor = Color.Green; }
软件下载:http://download.csdn.net/detail/a497785609/4040724
源码下载:http://download.csdn.net/detail/a497785609/4040709
- Asp.net 资源文件翻译助手
- asp.net学习资源
- Asp.net 控件资源
- asp.net学习资源
- asp.net 学习资源
- ASP.net学习资源
- ASP.NET资源
- Asp.Net学习资源
- asp.net 学习资源
- Asp.net资源链接
- ASP.NET相关资源
- ASP.NET学习资源
- asp.net 学习资源
- asp.net资源
- ASP.NET学习资源
- Asp.net资源
- asp.net分页资源
- ASP.NET学习资源
- php5.2 的 php.ini 中文版
- @PostConstruct 和 @PreDestroy 使用
- 工业太阳光全光谱稳态模拟中采用氙灯与金属卤素灯的性能对比概要
- 说说程序员封闭开发的那些事
- PHP简单实现中文分词全文索引实例(tag专题)
- Asp.net 资源文件翻译助手
- Linux--根文件系统的挂载过程分析
- Linux设备驱动程序学习笔记
- 论TCP连接的应用层心跳包的必要性
- 设计模式入门学习 策略模式
- linux根文件系统挂载
- 有的观点比较犀利。
- 贴个自个用的vimrc
- 重构