Loading...
 

Multi-Language Add-In for Visual Studio


ASP.NET MVC issues

Hi Phil,

I'm having a ASP.NET MVC website and I'm facing 2 issues:

Resource class not updated
When I mark new strings for localization, they show up in the tool, it writes the proper code in View (most of the time), but the Resources class doesn't get the new property :_( I found out I can manually add the property to the Resources class (but it's a lot of manual work that I kind of expected the tool to do for me).

Strings with ' causes issues
When I scan a View with multiple strings, it will only scan until first string containing ' (like in "I'm") and skip the rest/make the rest unavailable (I found out I can remove the ' and rescan, mark new strings and add ' through the tool afterwards to overcome this - but again: I did expect the tool to do this for me) - no info in log file btw

Thanks for taking your time to read this. Let me know if you need more info.

Germany

Hello Nick,

I have just uploaded a new version, 6.2.0, which you can download with the following link:
Beta Version 6.02

This should fix the problem with inverted commas in HTML text.

I could not reproduce the problem generating resources. Can you try the command "Store resources for Web projects" in the Runtime-Support-Menu (3rd button on the toolbar).

This version also contains some initial support for IStringLocalizer.
At present, it is only in code files (.cs) and not in views (.cshtml) and it is restricted to Controller classes. You can select the option in the project properties dialog or in the "wizard" dialog when you add support to a new project. I will write a more detailed description later, when I have added support for views.

Phil


Hi Phil,

Tried to scan project with Beta 6.02.0000 and got following exception:

at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.Combine(String path1, String path2)
at MultiLang.clsFormsAndControls.ExcludeAspCoreResourceFiles() in c:\MultiLang.2017\VS2013\MultiLang\Classes\clsFormsAndControls.vb:line 1054
at MultiLang.clsFormsAndControls.Reinitialise() in c:\MultiLang.2017\VS2013\MultiLang\Classes\clsFormsAndControls.vb:line 365
at MultiLang.clsProject.InitialiseFormsAndControls() in c:\MultiLang.2017\VS2013\MultiLang\Classes\clsProject.vb:line 4319
at MultiLang.ctlToolWindow.DoubleScan(clsProject MLProject, enumScanRestore RescanSource, enumScanRestore RescanControls, Boolean IsRescan, Boolean ImportResX) in c:\MultiLang.2017\VS2013\MultiLang\Controls\ctlToolWindow.vb:line 1931
at MultiLang.ctlToolWindow.ProjectInit(clsProject MLProject, Boolean MultipleProjectDialogShown) in c:\MultiLang.2017\VS2013\MultiLang\Controls\ctlToolWindow.vb:line 1581


Just downgraded to 6.01.0047 - and I'm able to scan again :-)
Germany

Sorry about that. I think that your project contains a generic class, which caused the error.

Can you try again?

Beta Version 6.02

Phil


Strings with ' causes issues - FIXED :-D

Resource class not updated (not fixed :_( )
I tried to "Store resources for Web projects", but it didn't fix the problem.

Looking in my source control "differences", I only find changes to:

  • App_Data/EF.JA.Web.UI_ml.xml
  • App_Data/ml_temp_SourceScan.xml
  • App_GlobalResources/Resoureces.en-US.resx
  • App_GlobalResources/Resoureces.resx
  • Views/Login/Index.cshtml


I can't really see why it's not updating file:
C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.Designer.cs
EF.JA.Web.UI.Dino.App_GlobalResources > class Resources

I think below is the log file related to this action (new string is called "I'm lovin it").


15:45:58.964303: Set=True for 1 node(s) in 1 source files
15:45:58.968306: Processing Views\Login\Index.cshtml
15:45:59.024359: NewStringID 12498
15:45:59.026361: StoreText ID=12498, IetfTag=en-US, Text = I'm lovin it
15:45:59.026861: Adding new translation
15:45:59.085918: Resource name I_m_lovin_it
15:45:59.115446: Storing: Component=Resources.resx, Property=I_m_lovin_it, ResourceName=I_m_lovin_it, StringID=12498
15:45:59.231057: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.resx
15:45:59.234060: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.resx.backup
15:45:59.251077: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.resx.backup
15:45:59.254080: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.en-US.resx
15:45:59.254080: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.en-US.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.en-US.resx.backup
15:45:59.263088: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.en-US.resx.backup
15:45:59.301625: Finished: Set=True for 1 node(s)
15:46:16.798441: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.da.resx
15:46:16.798441: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.da.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.da.resx.backup
15:46:16.808451: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.da.resx.backup
15:46:16.809452: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.de.resx
15:46:16.809452: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.de.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.de.resx.backup
15:46:16.817960: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.de.resx.backup
15:46:16.818460: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.fi.resx
15:46:16.818460: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.fi.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.fi.resx.backup
15:46:16.827469: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.fi.resx.backup
15:46:16.827970: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.fr.resx
15:46:16.828470: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.fr.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.fr.resx.backup
15:46:16.836978: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.fr.resx.backup
15:46:16.837479: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.nl.resx
15:46:16.837479: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.nl.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.nl.resx.backup
15:46:16.846487: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.nl.resx.backup
15:46:16.846487: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.no.resx
15:46:16.846988: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.no.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.no.resx.backup
15:46:16.861502: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.no.resx.backup
15:46:16.862002: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.pl.resx
15:46:16.862002: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.pl.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.pl.resx.backup
15:46:16.870510: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.pl.resx.backup
15:46:16.871011: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.sv.resx
15:46:16.871011: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.sv.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.sv.resx.backup
15:46:16.879519: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.sv.resx.backup
15:46:16.880020: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.et.resx
15:46:16.880520: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.et.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.et.resx.backup
15:46:16.888528: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.et.resx.backup
15:46:16.889028: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.lv.resx
15:46:16.889028: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.lv.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.lv.resx.backup
15:46:16.898037: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.lv.resx.backup
15:46:16.898538: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.lt.resx
15:46:16.898538: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.lt.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.lt.resx.backup
15:46:16.907546: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.lt.resx.backup
15:46:16.908047: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.resx
15:46:16.908547: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.resx.backup
15:46:16.917556: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.resx.backup
15:46:16.918056: Closing editor window Resources.Designer.cs
15:46:16.987122: Exporting to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.en-US.resx
15:46:16.987623: Renaming C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.en-US.resx to C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.en-US.resx.backup
15:46:16.996131: After export: Deleting C:\Data\EF\Repo\Solutions\EF.JA.Web.UI.Dino2\src\EF.JA.Web.UI.Dino2\App_GlobalResources\Resources.en-US.resx.backup


Germany

If the problem is that the .resx file (Resources.resx) is generated, but the code file (Resources.Designer.cs) then it is a problem with the "CustomTool" property.

Can you select the resource file in the solution explorer, go to the properties window and check the Custom Tool property. If it is empty, then set it to PublicResXFileCodeGenerator.

Image

It will probably generate the code file immediately, but if not, there is a command in the context menu in the solution explorer "Run Custom Tool"

Image

Multi-Language can and should set this property automatically. It does set it for some project types when it creates the file, but not for Web Projects. In fact, there is a comment in the code that it should not be done for web-site projects, but I am sure that this refers to a very old version of ASP.NET.

I will check which project types require it and which do not, and update the code.

Phil

Germany

I have found another issue, which applies to Web Site projects but not to Web Application projects.

If the project is a Web Site, then my previous reply is nonsense, because you cannot define a custom tool for the resource file. In some way which I don't really understand, ASP generates an equivalent class on the fly.

However, the code generated by Multi-Language in a code file is incorrect.

The resource name has to be prefixed with Resources.Resources., where both the Namespace and Class are named resources.

This is shown in the following screen shot, with a 'peek' at the generated code.

Image

It does work to specify "using Resources;" at the top of the file, and to use only Resources. as the prefix.

Strangely, the same does not apply in .cshtml files. In that case it is possible to write @using Resources; at the top of the file, and to use the simpler prefix Resources.

I have uploaded a fix in version 6.02.0003, which you can download with the link

Download Beta Version 6.02

This change actually affects both .cs and .cshtml files, but I will try to return to the shorter version in .cshtml files in the next update. I have changed my mind on that, because it is more difficult than I expected. I would rather push on with IStringLocalizer support smile. I will try to come back to it later.

Phil


Hi Phil,

Custom Tool frown

I tried to set "Custom Tool" to "PublicResXFileCodeGenerator" (right clicking resx file, selecting properties, going to "Embedded Resource" configuration and manually pasting before mentioned string since I was unable to select anything from a drop down like on your screenshot).

Unfortunately it didn't work out and I get following error

An error has occurred while saving the edited properties listed below:
- Custom Tool
One or more values are invalid. An internal error occurred. Please contact Microsoft Product Support Services.

So in other words, I'm still unable to auto-generate the Resources.Designer.cs file (and I'm currently updating this file manually for any new string sad )


Resources.Resources cool

I don't see this issue in my MVC project for cshtml files. I've added a @using for the full namespace where Resources class is placed:

@using EF.JA.Web.UI.Dino.App_GlobalResources;

Above using (in top of cshtml) allows me to reach text "Login" like:

@Resources.Login

So fortunately I'm not having that issue at least cool