Import Localization Updates from CSV File

May 4, 2013 at 7:55 PM
I got an excel spreadsheet back from our translator with updates, and right now I either have to use RegexBuddy to extract the stuff to paste in, OR I have to copy and paste by hand. Could you provide a way to take in text from a CSV file (by pasting or selecting a file) in the format of [key][TAB]value[CR/LF] and replace any values found in a particular resx file that I select?

It seems like an easy addition to the software and would help me IMMENSELY.

Thanks for your support and for such a kick-ass product!

May 5, 2013 at 5:28 PM
Hi doubled80,

I'm one step ahead of you this time :-). This feature is already implemented. You can paste (ctrl+v or via context menu) tab-separated text directly into the strings grid. I myself have tested it in Excel. The pasting should correctly handle such things as multiline content and tab-characters in the translated values.
First 'column' of the text is interpreted as the resource key, second one as the resource value and the last one as the comment.
May 6, 2013 at 3:30 PM
If I paste in items that are out of order, will it still fill in everything correctly?
May 6, 2013 at 3:37 PM
Not sure what you mean by 'items out of order'. The pasting method works very simply; it interprets the text as
key <TAB> value <TAB> comment
and inserts new rows into the grid for each row in input data. If the value or comment columns are missing, empty strings are inserted.
May 6, 2013 at 4:58 PM
Here's the situation which should give you some context:

Let's say I have 100 strings that need to be localized. I do Google Translate, but I then send those 100 strings in an XLS file to my translator to be reviewed.

In the meantime, I add like 100 more strings while making additions to the app.

The translator sends her 100 strings back in the same excel file. They may not be in the same order as what is displayed on the screen. I would like to be able to paste (or some other method) the stuff I get from her into the resx file and it would match up the key and replace the value, instead of overwriting the first 100 lines it sees.

Since I needed it done really quickly over the weekend, and I wasn't sure if your program handled it correctly, I made a simple program to update them all on the fly from a CSV file. Here's the program I used:

using System;
using System.Text.RegularExpressions;

namespace UpdateResxFileWithChanges
    class Program
        static void Main(string[] args)

            string inputFile = @"../../Changes-es.txt";
            string updateFile = @"C:\SomePath\Localization\";

            var inputTxt = System.IO.File.ReadAllLines(inputFile);
            var output = System.IO.File.ReadAllText(updateFile);

            var regex = "<data name=\"{0}\".*?>\\s*?<value>(?<value>.*?)</value>\\s*?</data>";
            var updater = new Regex(@"<value>.*?</value>", RegexOptions.IgnoreCase);
            Regex parser;

            foreach (var line in inputTxt)
                var s = line.Split('\t');
                if (s.Length == 2)
                    var useRegex = string.Format(regex, s[0]);
                    parser = new Regex(useRegex, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    var m = parser.Match(output);
                    if (m.Success)
                        string toUpdate = m.Value;
                        string updated = updater.Replace(toUpdate, "<value>" + s[1] + "</value>");
                        output = output.Replace(toUpdate, updated);
                        Console.WriteLine("OK: Updated " + line);
                        Console.WriteLine("ERROR: No match found for line '" + line + ".");
                    Console.WriteLine("ERROR: Did not translate '" + line + "' because split len != 2.");

            System.IO.File.WriteAllText(updateFile, output);

May 6, 2013 at 5:35 PM
Edited May 6, 2013 at 6:03 PM
I see. Visual Localizer does not provide direct support for this, but there are at least two simple workarounds. The problem is, your solution works only if there are no multiline strings in the file.

A. There are free editors of ResX files that do not require Visual Studio and are intended to be used be translators. Try Zeta Editor for example. Your translator would be able to edit directly the ResX file without a need to copy data.

B. Copy original data (with keys) from the strings grid to a blank Excel stylesheet. Next to it, copy the translated data (also with keys). Sort both tables according to keys. Copy & paste translated data instead of the original (thanks to sorting, it will match the right keys). Copy the result table back to the Visual Localizer editor.

Actually, Visual Localizer editor allows you to sort the grid as well, so you could leave out Excel and do it all in the editor itself.