将 CSV 文件或 Excel 电子表格转换为 RESX 文件
我正在寻找针对我遇到的问题的解决方案或建议。 我有一堆需要本地化的 ASPX 页面,还有一堆需要支持 6 种语言的文本。
进行翻译的人员无法访问 Visual Studio,最简单的工具可能是 Excel。 如果我们使用 Excel 甚至导出到 CSV,我们需要能够导入以移动到 .resx 文件。 那么,最好的方法是什么?
我知道这个问题,转换 Visual Studio 资源文件到文本文件? 已经并且使用 Resx Editor,但更容易的解决方案将是首选。
I am looking for a solution or recommendation to a problem I am having. I have a bunch of ASPX pages that will be localized and have a bunch of text that needs to be supported in 6 languages.
The people doing the translation will not have access to Visual Studio and the likely easiest tool is Excel. If we use Excel or even export to CSV, we need to be able to import to move to .resx files. So, what is the best method for this?
I am aware of this question, Convert a Visual Studio resource file to a text file? already and the use of Resx Editor but an easier solution would be preferred.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定您正在寻找的答案有多全面,但如果您真的只是使用 [string, string] 对进行本地化,并且您只是在寻找一种快速加载资源(.resx)的方法文件与翻译结果,那么以下将作为一个相当快速、低技术含量的解决方案。
需要记住的是,.resx 文件只是 XML 文档,因此应该可以从外部代码手动将数据加载到资源中。 以下示例在 VS2005 和 VS2008 中适用于我:
显然,前面的方法不会为您的资源生成代码隐藏,但是在 Visual Studio 中打开资源文件并切换资源的辅助功能修饰符将(重新)生成为您提供静态属性。
如果您正在寻找完全基于 XML 的解决方案(相对于 CSV 或 Excel 互操作),您还可以指示翻译人员将其翻译内容存储在 Excel 中,另存为 XML,然后使用 XPath 检索您的本地化信息。 唯一需要注意的是文件大小往往会变得相当臃肿。
祝你好运。
I'm not sure how comprehensive an answer you're looking for, but if you're really just using [string, string] pairs for your localization, and you're just looking for a quick way to load resource (.resx) files with the results of your translations, then the following will work as a fairly quick, low-tech solution.
The thing to remember is that .resx files are just XML documents, so it should be possible to manually load your data into the resource from an external piece of code. The following example worked for me in VS2005 and VS2008:
Obviously, the preceding method won't generate the code-behind for your resource, however opening the resource file in Visual Studio and toggling the accessibility modifier for the resource will (re)generate the static properties for you.
If you're looking for a completely XML-based solution (vs. CSV or Excel interop), you could also instruct your translators to store their translated content in Excel, saved as XML, then use XPath to retrieve your localization info. The only caveat being the file sizes tend to become pretty bloated.
Best of luck.
我遇到了类似的问题,并意识到从 excel 文件创建 .resx 文件的最简单方法是使用 excel 的串联函数生成“<”data”>”..”<”/data”>” .resx 文件的节点,然后在任何文本编辑器中手动将生成的行复制到 .resx 文件中。 假设您在 Excel 文档的 A 列中有“名称”,在 Excel 文档的 B 列中有“值”。 使用 C 列中的以下公式,
您将获得资源的数据节点。 然后,您可以将此公式复制到所有行,然后复制 .resx 文件中 C 列的内容。
I ran into similar problem and realized that the simplest way to create a .resx file from excel file is using a concatenate function of excel to generate "<"data">".."<"/data">" node for the .resx file and then manually copying the generated rows to the .resx file in any text editor. So lets say that you have "Name" in column A of an excel document and "value" in Column B of the excel document. Using following formula in Column C
you will get the data node for resource. You can then copy this formula to all the rows and then copy the contents of Column C in your .resx file.
如果是 csv 格式,这里有一个快速的 Ruby 脚本来生成数据元素。
If it's in csv here's a quick Ruby script to generate the data elements.