Convert a Visual Studio resource file to a text file?
Asked Answered
G

7

8

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?

Garik answered 13/10, 2008 at 19:38 Comment(0)
M
2

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

Mcquoid answered 9/3, 2009 at 0:46 Comment(0)
C
3

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.

Commonable answered 13/10, 2008 at 19:57 Comment(1)
@takrl thanks, the project was moved to this link apparently resx.sourceforge.net (I updated the answer)Commonable
A
3

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.

Adjust answered 5/7, 2013 at 17:11 Comment(1)
This is the real answer.Jim
M
2

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

Mcquoid answered 9/3, 2009 at 0:46 Comment(0)
S
1

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

Scud answered 13/10, 2008 at 21:21 Comment(1)
nice idea, do you know of any apps like that for ASP.NET Resource files?Chaddy
P
1

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.

Pozzuoli answered 20/10, 2008 at 6:19 Comment(0)
O
1

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.

Oconnell answered 7/12, 2015 at 0:44 Comment(0)
I
0

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

Inman answered 16/10, 2008 at 12:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.