将 Visual Studio 资源文件转换为文本文件?

发布于 2024-07-07 08:35:39 字数 95 浏览 6 评论 0原文

我知道有一些工具可以将文本文件转换为 Visual Studio 的资源文件。 但我想将资源文件中的文本获取到文本文件,以便可以翻译它们。 或者有更好的方法来做到这一点吗?

I know there are tools to get text files to resource files for Visual Studio. But I want to get the text from my resource files to a text file so they can be translated. Or is there a better way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

时光是把杀猪刀 2024-07-14 08:35:40

您可能想查看Excel 资源传输。 这是
用于从资源文件导入和导出文本的 Microsoft Excel 插件。
有试用版。 完整版售价 25 欧元。

You may want to have a look at Excel Resource Transfer. It is
an Add-In for Microsoft Excel to import and export texts from resource files.
There is a trial version. The full version costs 25,- Euro.

身边 2024-07-14 08:35:40

如果您正在为 Web 项目执行此操作,则进行国际化(包括翻译)的更好方法是使用 i18n nuget包。 不仅可以更好地使用模板,而且还具有其他优点,例如本地化 URL。

以下是来自 github 存储库的示例:

<div id="content">
    <h2>[[[Welcome to my web app!]]]</h2>
    <h3><span>[[[Amazing slogan here]]]</span></h3>
    <p>[[[Ad copy that would make Hiten Shah fall off his chair!]]]</p>
    <span class="button" title="[[[Click to see plans and pricing]]]">
        <a href="@Url.Action("Plans", "Home", new { area = "" })">
            <strong>[[[SEE PLANS & PRICING]]]</strong>
            <span>[[[Free unicorn with all plans!]]]</span>
        </a>
    </span>
</div>

运行构建后任务会生成一个 PO 数据库,该数据库可以提供给使用 PO 编辑工具的翻译人员(例如 POEdit) 提供特定于语言环境的文本。

If you're doing this for a web project, a better way to do internationalization (including translation) is to use the i18n nuget package. Not only does work better with templates but it has other nice-to-haves like localized URLs.

Here's an example from the github repo:

<div id="content">
    <h2>[[[Welcome to my web app!]]]</h2>
    <h3><span>[[[Amazing slogan here]]]</span></h3>
    <p>[[[Ad copy that would make Hiten Shah fall off his chair!]]]</p>
    <span class="button" title="[[[Click to see plans and pricing]]]">
        <a href="@Url.Action("Plans", "Home", new { area = "" })">
            <strong>[[[SEE PLANS & PRICING]]]</strong>
            <span>[[[Free unicorn with all plans!]]]</span>
        </a>
    </span>
</div>

Running a post-build task generates a PO database that can be provided to translators that use PO editing tools (like POEdit) to provide locale-specific text.

落花随流水 2024-07-14 08:35:40

您可以使用 Microsoft 的 winres.exe,它可以让您本地化 Windows 窗体,而无需使用 Visual Studio。 它不会将资源保存到文本文件中,但其想法是每种文化的本地化专家可以使用该工具生成应用程序的本地化版本。

这是一个更好的解释:
http://msdn.microsoft.com/en-us /library/8bxdx003(VS.80).aspx

You could use winres.exe from Microsoft, it lets you localize windows forms without having to use Visual Studio. It doesn't save the resources to a text file, but the idea is that the localization expert for each culture could use the tool to generate a localized versions of the application.

Here's a better explanation:
http://msdn.microsoft.com/en-us/library/8bxdx003(VS.80).aspx

慵挽 2024-07-14 08:35:39

您可以使用 Resx Editor,这是一个小型的面向翻译的文件编辑器。

  • 目标受众:翻译人员。
  • 支持的文件格式:Microsoft RESX 2.0

以下是 Joannès Vermoel(免费工具的作者)博客的链接关于它的条目

You could use Resx Editor, a small translation-oriented file editor.

  • Target audience: translators.
  • Supported file format: Microsoft RESX 2.0

Here is a link to Joannès Vermoel's (the author of the free tool) weblog entry about it.

你在看孤独的风景 2024-07-14 08:35:39

最后,我只是使用了一个快速技巧:

public class Export
{
    public string Run()
    {
        var resources = new StringBuilder();

        var assembly = Assembly.GetExecutingAssembly();
        var types = from t in assembly.GetTypes()
                    where t != typeof(Export)
                    select t;
        foreach (Type t in types)
        {
            resources.AppendLine(t.Name);
            resources.AppendLine("Key, Value");
            var props = from p in t.GetProperties()
                        where !p.CanWrite && p.Name != "ResourceManager"
                        select p;
            foreach (PropertyInfo p in props)
            {
                resources.AppendFormat("\"{0}\",\"{1}\"\n", p.Name, p.GetValue(null));
            }

            resources.AppendLine();
        }
        return resources.ToString();
    }
}

将此代码添加到包含您的 .resx 文件的项目中(我的位于单独的“语言”项目中),然后使用以下代码将结果保存到 .csv 中,以便它可以加载电子表格编辑器。

var hack = new Languages.Export();
var resourcesSummary = hack.Run();
var cultureName = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
using (TextWriter file = File.CreateText(@"C:\resources." + cultureName + ".csv"))
{
    file.Write(resourcesSummary);
}

这不允许您将文件从 .csv 导入回 .resx 文件以便对其进行编译。 如果有一个实用程序可以做到这一点那就太好了。

In the end I just used a quick hack:

public class Export
{
    public string Run()
    {
        var resources = new StringBuilder();

        var assembly = Assembly.GetExecutingAssembly();
        var types = from t in assembly.GetTypes()
                    where t != typeof(Export)
                    select t;
        foreach (Type t in types)
        {
            resources.AppendLine(t.Name);
            resources.AppendLine("Key, Value");
            var props = from p in t.GetProperties()
                        where !p.CanWrite && p.Name != "ResourceManager"
                        select p;
            foreach (PropertyInfo p in props)
            {
                resources.AppendFormat("\"{0}\",\"{1}\"\n", p.Name, p.GetValue(null));
            }

            resources.AppendLine();
        }
        return resources.ToString();
    }
}

Add this code to the project which contains your.resx files (mine are in a separate "Languages" project) then use the following code to save the result into a .csv so that it can be loaded with a spreadsheet editor.

var hack = new Languages.Export();
var resourcesSummary = hack.Run();
var cultureName = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
using (TextWriter file = File.CreateText(@"C:\resources." + cultureName + ".csv"))
{
    file.Write(resourcesSummary);
}

This does not allow you to import files from the .csv back to your .resx files so that they can be compiled. It would be nice to have a utility that would do that.

扮仙女 2024-07-14 08:35:39

您可以使用Simple Resx Editor,它有一些有趣的功能,可以帮助您进入翻译过程。

You can use Simple Resx Editor, it has some interesting features that will help you into the translation process.

油焖大侠 2024-07-14 08:35:39

尽管这有违直觉,但翻译 exe 而不是资源文件是一个更好的主意。 请在此处阅读原因:

http://www.apptranslator.com/misconceptions.html

Even though it is counter intuitive, it's a better idea to translate the exe rather than the resource file. Read why here:

http://www.apptranslator.com/misconceptions.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文