Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 是否将Visual Studio资源文件转换为文本文件?_Visual Studio_Localization_Resource File - Fatal编程技术网

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

Visual studio 是否将Visual Studio资源文件转换为文本文件?,visual-studio,localization,resource-file,Visual Studio,Localization,Resource File,我知道有一些工具可以将文本文件转换为VisualStudio的资源文件。但是我想把我的资源文件中的文本转换成一个文本文件,这样它们就可以被翻译了。还是有更好的方法 您可以使用一个小型的面向翻译的文件编辑器 目标受众:翻译 支持的文件格式:Microsoft RESX 2.0 以下是Joannès Vermoel(免费工具的作者)关于它的链接。尽管这是违反直觉的,但最好翻译exe而不是资源文件。请在此处阅读原因: 您可以使用Microsoft的winres.exe,它使您无需使用Visual

我知道有一些工具可以将文本文件转换为VisualStudio的资源文件。但是我想把我的资源文件中的文本转换成一个文本文件,这样它们就可以被翻译了。还是有更好的方法

您可以使用一个小型的面向翻译的文件编辑器

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

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

尽管这是违反直觉的,但最好翻译exe而不是资源文件。请在此处阅读原因:


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

这里有一个更好的解释:
您可能想看看。它是 Microsoft Excel的外接程序,用于从资源文件导入和导出文本。
有一个试用版。完整版本的价格为25欧元。

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

最后,我使用了一个快速破解:

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文件,以便进行编译。如果有一个实用程序可以做到这一点,那就太好了。

如果你是为一个web项目这样做的,那么更好的国际化(包括翻译)方法就是使用。它不仅可以更好地使用模板,而且还有其他一些很好的功能,比如本地化的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>

欢迎使用我的网络应用!]]
[[[这里有令人惊叹的口号]]
[[[Hiten Shah从椅子上摔下来的广告副本!]]


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

好主意,你知道有类似ASP.NET资源文件的应用吗?@takrl谢谢,该项目显然已移至此链接(我更新了答案)这才是真正的答案。