Open tanaka-takayoshi opened 7 years ago
Tooling for VS Code or VS for Mac? @sayedihashimi @madskristensen
@spboyer I'm not aware of any tooling for those SKUs regarding .resx files. That's not to say that there aren't any
@ryanbrandenburg @DamianEdwards How do Visual Studio for Code folks generate/edit .resx files?
@tanaka-takayoshi can you try How to edit a .resx file on Mac OS
@Rick-Anderson Thanks. I'm not a Mac user but Linux user. However, it appears working on Linux. I'll try later and report.
@Rick-Anderson I tried it, but there are some problems.
POEditor on Linux doesn't have a function to import resx and add a localization term from scratch. It intends to import localization terms from souce code directly, but it doesn't work for ASP.NET Core codes.
http://converter.webtranslateit.com/ has other supported format. I tried CSV. But it can't convert the resource whose key contains space. So, for example, such term can't convert CSV to resx. https://github.com/aspnet/Entropy/blob/rel/1.1.0/samples/Localization.StarterWeb/Resources/Views.Home.About.fr.resx#L123
Now, as far as https://msdn.microsoft.com/en-us/library/ekyft91f(v=vs.100).aspx is the formal schema for resource file, only supported way on Linux and Mac OSX is editing resx file directly as plain XML file. I'll try to create VS Code extension for editing resx file or dotnet cli extension for converting to resx from some kind of files (like csv).
@tanaka-takayoshi Thanks for the update.
I think that this may be a bug for tooling for xplat and not for docs.
@danroth27
@danroth27 @DamianEdwards Will VS for Mac solve this for the Mac? What about Linux?
@DamianEdwards How do Visual Studio for Code folks generate/edit .resx files? Will VS for Mac solve this for the Mac? What about Linux?
Any news on this?
After looking to too many articles I have installed the visual studio community edition on Windows. It seems that the utility tool (https://docs.microsoft.com/es-es/dotnet/framework/tools/resgen-exe-resource-file-generator?view=netframework-4.7.1) for generating .resources from .restext , .txt or resx is, unfortunately, only installed by installing Visual studio
@VanKichline where can we open an issue on this for Visual Studio for Mac. Linux needs a solution too. This is an essential tool.
We really need an xplat tool for this.
@tanaka-takayoshi have you found any workarounds?
@Rick-Anderson Though I haven't checked the recent updates regarding this issue, my previous comment might be still valid. https://github.com/aspnet/Docs/issues/2501#issuecomment-272670895
At first, we need a template file for resource file, which can be generated by Visual Studio. So we need Visual Studio (on Windows) for the first time. Once a resource file is created, we can copy it to Linux/Mac and simply edit the file.
ASP.NET Core team might have to clarify the XML scheme for the resource file. Once XML scheme is defined, we can create a resource file without Visual Studio. If XML scheme is same as one for .NET Framework, could you add to ASP.NET Core document as a specificastion?
@ryanbrandenburg @DamianEdwards @danroth27 @rynowak This is our #1
request.
@Andrew-MSFT Are there any plans to support generating/editing resx on xplat?
I remembered that I created a tool called LocalizationResourceGenerator which generate & translate resources based on default <resource>.resx
, I think I will have a look again to support creating a .resx file from .restext , .txt or any popular format .. please your feedback is welcome
@Andrew-MSFT Are there any plans to support generating/editing resx on xplat? cc @sayedihashimi
FYI I update the tool that I created, so you can generate resx
files from restext
files, but still Visual Studio support will be great
This is something we'd like to support eventually, but it's not on the roadmap in the .NET Core 3.0 time frame
@AndrewBrianHall Now that .NET Core 3.0 has shipped and 3.1 is on the way, would you consider this item for the next release?
I'm working on VS Code extension for editing resx files, hope to share it with you once it's ready
FYI I'm still working on the extension, facing some issues in the UI part, hopefully I will find time to finish them and release a beta version
However you can use the CLI tool that I referred to above, your feedback is very important
Hi All, i was having the issue where I needed resx files to generate designer.cs files from VS Code. The following tool helped me to do this: https://github.com/Taritsyn/ResxToCs. I just added the ResxToCs.MSBuild (nuget package) which added a build task to my csproj file and created designer.cs files each build.
One thing to mention is that the format of the translation to designer.cs file is different to how Visual studio translates it. For example the generated designer.cs files declared public properties rather than private (which is what visual studio does). So we had to modify our reflection code accordingly.
@KathleenDollard
This extension seems to do the job.
For now, the generation and manipulation of resource files is quite limited to the tools available on Windows (such as Resgen.exe). Even Visual Studio for Mac is unable to edit these files.
A truly cross-platform alternative to this issue would be to adopt Portable Objects (PO) to manage localization. This library seems to be a good starting point: https://github.com/VitaliiTsilnyk/NGettext
By the way, it costs nothing to mention that advances in this area are still outside the scope of .NET 5, as can be seen in this design proposal: https://github.com/dotnet/designs/pull/102
@hishamco please review the VSC extension @knuxbbs mentions above. cc @KathleenDollard
Sure, I was started on mine long time ago, but I was quite busy on some OSS especially after my left ankle was broken
@Rick-Anderson I have a quick look, if you mean https://github.com/VitaliiTsilnyk/NGettext this is a library for PO files not resx, seems I need spend some time to finalize a first beta version of what I started unless VS Code or Visual Studio for Mac Team planned for something similar
By the way, it costs nothing to mention that advances in this area are still outside the scope of .NET 5, as can be seen in this design proposal: dotnet/designs#102
Are there any plans to support a dotnet
command line tool for creating a new .resx
file and adding it to a .csproj
?
It is quite disappointing that support for creating/editing .resx
files outside of Windows/Visual Studio has languished for so long. VS for macOS can create a .resx
files but has no editor for them. JetBrains Rider doesn't seem to have support, either. 😞
@grumpydumpty have a look to LocalizationResourceGenerator
Thanks @hishamco, will take a look at it.
That said, I still believe this should be part of the standard Microsoft dotnet
command line tooling.
I found thit extension which works pretty well in VS Code.
@gmarokov I found that too, which is great for editing but the code behind doesn't get updated on save or compile for me.
How is this still not solved? It's been over 4 years.
@tanaka-takayoshi @JohnGalt1717 @BrightSoul @piekstra @rminon @grumpydumpty
Can you let us know what you'd like to have? … A CLI tool? VS Code extension? Is it just for creating/editing the files so they can be used in ASP.NET Core (via IStringLocalizer) or is it to generate the .cs file too?
ASP.NET Core supports other providers, the most popular being the PO (Portable Object) provider from OrchardCore.
@Rick-Anderson Well I'd start with dotnet build should generate everything automatically and we should get the same functionality as VS.NET has for doing this from resx in some form without having to use VS.net. Be that dotnet gen or just dotnet build/watch it should generate this and be done and it should be done in a way that I can add a task to vs code or whatever other tool I'm using to generate stuff for me.
@Rick-Anderson I have been following this issue for quite a while too, waiting for any news... It is baffling that there is still no improvement on this front.
I18n / l10n are such completely fundamental aspects of software that a development ecosystem should provide. For such a world class framework like .NET, that has gone cross-platform already 5 years ago, I still cannot believe that there is such poor support for this on Linux.
I guess what we are all asking is not necessarily a specific tool (although it could be) but just general support for it as a first-class feature, as you would have on Windows with Visual Studio.
@tanaka-takayoshi @JohnGalt1717 @BrightSoul @piekstra @rminon @grumpydumpty Can you let us know what you'd like to have? … A CLI tool? VS Code extension? Is it just for creating/editing the files so they can be used in ASP.NET Core (via IStringLocalizer) or is it to generate the .cs file too?
ASP.NET Core supports other providers, the most popular being the PO (Portable Object) provider from OrchardCore.
@Rick-Anderson in an ideal world? All of the above. Personally I was following the guidance here and realized that I would need to use Visual Studio instead of my preferred IDE, VS Code. On VS Code there was no clear way to create a properly-formatted .resx
file and when simply creating a file with that extension, there is no way to view a friendly rendered UI for adding or modifying Key / Value pairs for the resource file. Switching to Visual Studio for Mac (I'm on 11.2 Big Sur), I was able to generate the .resx
file with what appeared to be proper formatting, but still it was not rendering a UI that would let me easily make modifications. Switching back to VS Code, I found an extension that someone mentioned above that ended up working for me at that point. I had originally tried using this extension which had more installs and reviews but when saving changes, the changes were not persisted to the .resx
file and it would be reset. Not sure if that was because my .resx
file was improperly formatted (I started with an empty file when using that extension).
In general I try to avoid non-Microsoft extensions for VS Code for security and privacy reasons so it was unfortunate that neither VS Code, nor Visual Studio supported the editing capability.
One thing that Visual Studio did automatically that VS Code could not, was update my .csproj
file with the necessary ItemGroup
s to use the resource files when I added them.
I tend to use VS Code extensions over CLI tools, but in this scenario, anything beyond what was available by default would have been a better experience. Having to switch back and forth between two IDEs to get parts of what was necessary to add localization to my controller messages in my ASP.NET Core 5 Web API was disappointing and confusing and I would not expect a junior developer on my team to be able to get through it in a reasonable amount of time.
That was very long-winded, so to be more concise:
I have an ASP.NET Core 5 Web API with controllers that needed to use an injected IStringLocalizer to support localized messaging returned in responses from my endpoints. I wanted VS Code to support generating a well-formatted .resx
file, including the necessary references to that file in my .csproj
file, and to be able to edit the .resx
file with a user-friendly interface.
@piekstra regarding Visual Studio for Mac, they have a feature on their backlog to support editing .resx files with a designer. I believe it's pretty high on the priority list, but I could be wrong.
cc @jmatthiesen
@piekstra regarding Visual Studio for Mac, they have a feature on their backlog to support editing .resx files with a designer. I believe it's pretty high on the priority list, but I could be wrong.
cc @jmatthiesen
Rider supports this since version 2020.2. How embarrassing!
@Rick-Anderson I'm currently using the VSCode extension ResX editor. That works for me (thanks Domink Vonk, the author) but it can't be a solution because:
Generating and editing resx files should be supported by the dotnet
command.
@Rick-Anderson
I think there should be resource generator backend in dotnet sdk. Various IDEs (VS, VS for Mac, VS Code, etc.) should implement only frontend part (UI/UX). Generation results should be deterministic.
Today, various generators produce different content (comments, formatting, etc.). This makes it difficult to work in different IDEs on the same project/repository.
Why not switching to json instead of resx?
Any updates on this front?
Would it not be possible to use source generators for this? that way we can get rid of the Designer files.
Would it not be possible to use source generators for this? that way we can get rid of the Designer files.
@mikadumont @BillWagner @jaredpar @chsienki @IEvangelist
Our entire loc story depends on Resource files which can only be created in VS. Can't we replace .resx files with source generators?
cc @madskristensen @adityamandaleeka
Hi @Rick-Anderson - this certainly doesn't feel like a docs concern, but rather that of the product team. While we might influence their decision, and while I agree this would be advantageous, I don't think we should go changing all of the loc docs to use a source generator unless we get product team agreement. I'm happy to be a part of the conversation.
I just had good luck with Tim Heuer's ResX Viewer and Editor in VSC. My rubber duck 🦆 session with a Blazor project is in ...
https://github.com/dotnet/AspNetCore.Docs/issues/31694
... and I'm adding remarks on using it to the Blazor Glob and Loc article ...
Include a VSC path for resource files https://github.com/dotnet/AspNetCore.Docs/pull/31706
Hisham has signed off in agreement that it's a respectable approach. I'm waiting on Tim's blessing to merge the PR.
We need to generate and edit in localization. However the document describes the steps only on the Visual Studio on Windows. Now ASP.NET Core is cross platform so could you describe the supported steps on Linux and Mac OS.
At least, the document should describe the XML schema and the sample XML for resx.
Edit by @Rick-Anderson : See LocalizationResourceGenerator which generates & translates resources based on default
<resource>.resx
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.