How to add value to local resources in using visual localizer

May 14, 2013 at 11:56 AM
I need to work with I am facing a bring problem. Whenever I try to add a value on a resource file which is local resource then I get a error message "cannot reference resources in this file , missing namespace". It works fine when the resource file is a global resource.

One more thing is that I want to add only the string values to resource file from source code. I don't want any button name or label name or form name to be stored there. How should I filter for doing this ?

Thanks in advanced .
May 14, 2013 at 12:27 PM
Hi lollyssium,

this is by design. In order to move a string to a resource file, Visual Localizer must be able to create a reference on its place. In ASP .NET website projects (interestingly, not in web application projects), only global resource files are reference-able. You can verify this by creating a resource in a local resource file manually and attempting to reference it from code; it is not possible.
One more thing is that I want to add only the string values to resource file from source code. I don't want any button name or label name or form name to be stored there. How should I filter for doing this ?
Visual Localizer has quite a strong mechanism for this. First - the "Name", "ID" and "runat" attributes are skipped right away. Second, when you use "batch move" command tool window, there is a "Show filter" tool button. This displays several criteria, according to which you can remove non-localizable strings. And most importantly, you can customize these criteria in the Tools/Options/Visual Localizer options page. This allows you for example to say: "strings located in 'XYZ' attribute must not be localized" - this will cause such strings to be by default unchecked in the batch move tool window.

Hope I helped, feel free to keep asking if not :-)
May 15, 2013 at 3:41 AM
Suppose in my default page I have 6 label and one button . For that certain button click on that page I want to change all label's texts.
protected void Button1_Click(object sender, EventArgs e)
        this.Label1.Text = "hello";
        this.Label2.Text = " World";
        this.Label3.Text = " Madam";
        this.Label4.Text = " I am ";
        this.Label5.Text = " Adam ";
        this.Label6.Text = "  are cute :) ";
When I am going to localize it then I want only these texts and no other options to be seen on the visual localizer batch move window. If it is not possible to show only these string values then I want all these string values to be selected only. How should I proceed ? How can I filter ? I have tried in several ways but failed.

One more question is can I run visual localizer from command line ? If it is possible then how can I do this for a certain website ?
May 15, 2013 at 3:43 AM
Edited May 15, 2013 at 3:50 AM
I mean I need only the constant string values from my code..

That means in my code there will be a portion .Text followed by a '=' then a double quote and followed by some text and ended with a double code. I am actually confused with the regular expression. Can you help me please ?
May 15, 2013 at 7:59 AM
Edited May 15, 2013 at 8:00 AM
There are actually several ways how to do this:
  1. You can select files in the Solution Explorer, right-click them and select Visual Localizer/Batch move from the context menu. I.e. if you right click your Default.aspx.cs in the Solution Explorer and run the Batch move command, only the selected files are scanned.
  2. Open the desired file and highlight all the text that you want to be scanned. Right-click on the selection and run Visual Localizer/Batch move to resources (selection). That means, only highlighted text is scanned.
  3. Or you can customize the filter criteria. By doing this, even strings from the AspX file will be shown in the batch move toolwindow, but they will be unchecked by default. Open the Visual Localizer filter settings page (Tools/Options/Visual Localizer/Filter ToolWindows) - there is a grid with some criteria. Set "Force NOT localize" action in every criteria that says something like "String literal comes from ASP .NET attribute".
  4. And finally, you can add your own criteria. This is done by the "Add" button at the bottom of the settings page. In your case, you could do something like this:
    If line not matches "this.Label\d.Text =" then force NOT localize
    The bold values are available in the combo boxes. This will lead to only strings likes this.Label1.Text = "hello"; will be checked in the batch move tool window.
No, you cannot run Visual Localizer from command line since it requires context of running Visual Studio instance.

Hope I helped, keep asking and/or review the software if you like it :-)