我不知道你的答案如何全面的寻找,但如果你真的只是使用[字符串,字符串]对你的定位和你只是寻找一个快速的方式来加载资源(.resx)文件与翻译结果进行比较,那么以下内容将作为一种相当快速,低技术含量的解决方案。
要记住的一点是,.resx文件只是XML文档,所以它应该可以手动将数据从外部的代码加载到资源。下面的例子在VS2005为我工作和VS2008:
namespace SampleResourceImport
{
class Program
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
string filePath = @"[file path to your resx file]";
doc.Load(filePath);
XmlElement root = doc.DocumentElement;
XmlElement datum = null;
XmlElement value = null;
XmlAttribute datumName = null;
XmlAttribute datumSpace = doc.CreateAttribute("xml:space");
datumSpace.Value = "preserve";
// The following mocks the actual retrieval of your localized text
// from a CSV or ?? document...
// CSV parsers are common enough that it shouldn't be too difficult
// to find one if that's the direction you go.
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("Label1", "First Name");
d.Add("Label2", "Last Name");
d.Add("Label3", "Date of Birth");
foreach (KeyValuePair<string, string> pair in d)
{
datum = doc.CreateElement("data");
datumName = doc.CreateAttribute("name");
datumName.Value = pair.Key;
value = doc.CreateElement("value");
value.InnerText = pair.Value;
datum.Attributes.Append(datumName);
datum.Attributes.Append(datumSpace);
datum.AppendChild(value);
root.AppendChild(datum);
}
doc.Save(filePath);
}
}
}
显然,上述方法不会产生隐藏代码为您的资源,但是打开Visual Studio中的资源文件,并切换无障碍修改为资源将(重新)为您生成静态属性。
如果您正在寻找一个完全基于XML的解决方案(与CSV或Excel互操作),您还可以指示您的翻译人员将其翻译的内容存储在Excel中,保存为XML,然后使用XPath检索您的本地化信息。唯一需要注意的是文件大小往往变得非常臃肿。
祝你好运。
这个工作对resw了。 – b15 2016-06-05 13:51:18