Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource Files with duplicate Project, File, and Key #494

Closed
Darkseal opened this issue Aug 27, 2022 · 9 comments
Closed

Resource Files with duplicate Project, File, and Key #494

Darkseal opened this issue Aug 27, 2022 · 9 comments
Milestone

Comments

@Darkseal
Copy link

Darkseal commented Aug 27, 2022

Hello there,

I'm currently evaluating this tool to ease the translation of a couple ASP.NET Core projects (~1000 resource entries). First of all, thank you for having done this - it was precisely what I was looking for!

That said, while trying it I've noticed an odd behavior that raises some concerns: if I perform the export, the resulting MS Excel export file doesn't have a column containing the full path + filename of the various resource files, or any distinctive unique name that can be used to uniquely identify them. I only see Project, File, and Key columns, none of which is necessarily unique (even combined).

Given the above, how can the tool distinguish between two (or more) different resx files having the same Project, File, and Key values, but a different path?

For example, consider the following three resource files:

  • /Views/Home/Index.en.resx
  • /Views/Shop/Index.en.resx
  • /Views/Community/Index.en.resx

The above files all have the same Project value (since they all belong to the same project), and the same Name value (which is Index); moreover, they could even share some Key values, since keys must only be unique within a single resx file (same key names in different resx files are allowed).

Now, suppose I only want to export one of these three files, change some of its resource values (possibly even adding new keys and/or deleting existing keys), and then import back the modified MS Excel file. Will the software be able to properly identify the correct "source" resx file I have exported and only update that file, leaving the other files untouched? And if so, how does it do it?

Please let me know, thanks!

@tom-englert
Copy link
Collaborator

Did you try and it failed?

@Darkseal
Copy link
Author

Darkseal commented Aug 27, 2022

Yes. As a matter of fact, it didn't "fail": it imported all the exported keys in the first .resx file, leaving the other two as they were. More precisely, the outcome is the following:

  • /Views/Community/Index.en.resx <-- all the keys present in the 3 files are here now, including the updated ones
  • /Views/Home/Index.en.resx <-- unchanged - still has its keys (no updates)
  • /Views/Shop/Index.en.resx <-- unchanged - still has its keys (no updates)

I think we might have a non-trivial issue here, unless I did something wrong: in my opinion, it could be easily fixed by adding the project-relative resx file path in the Name column (or just adding another column, like Path, and use that to locate the proper file), unless you have a better idea.

Please let me know your thoughts on that. Also, feel free to ask me anything (I think I could replicate the issue in a sample project and send you a ZIP file containing it, if you want)

@tom-englert
Copy link
Collaborator

I'm not sure what you are doing, but when I export it looks like this:
image

@Darkseal
Copy link
Author

Darkseal commented Aug 28, 2022

It seems that your export already contain the project-relative path of the resource in column B, which absence is what causes all the trouble in my export/import process.

Unfortunately, mine doesn't. Here's the screenshot of my project's resx structure:

ss_01

And here's the screenshot of the resulting Excel export for these selected files:

ss_02

Notice the absence of the project-relative path in column B: the value is Index for all the four (different) .resx files, instead of Resources/Views/ComingSoon/Index, Resources/Views/Diary/Index, and the likes.

Maybe there's a way to enable/disable the project-relative path segment which I did miss? I have tried to look into ResXResourceManager's Configuration tab, but I didn't find anything there.

Please let me know, thanks

@Darkseal
Copy link
Author

Darkseal commented Aug 28, 2022

UPDATE: I've noticed that I only have this issue in the VS2022 extension - the standalone app looks fine and the project-relative path is present.

VS2022 extension screenshot:

ss-01

Standalone version screenshot (same project, folder, and PC):

ss-02

It seems that there's something wrong in the VS2002 extension version while calculating the resource file's uniqueName, which doesn't happen in the standalone version. I'm trying that in multiple solutions and this always happens.

@tom-englert
Copy link
Collaborator

In the VSIX the unique name comes from Visual Studio.
Also I don't see any neutral resources, that can't work anyhow.

@Darkseal
Copy link
Author

Darkseal commented Aug 30, 2022

Neutral resources are not an issue there (key names are used for default/fallback strings), we don't use them.

I think that the issue lies in the uniqueName, which in my scenario doesn't include the project-relative path (don't know why). However, since the stand-alone app doesn't have this issue and it seems like I'm the only one experiencing this in the VSIX, I think I'll just use the stand-alone app and get it solved like that :)

Thanks again for the support

@VladDragnea
Copy link
Contributor

VladDragnea commented Sep 18, 2022

Hi all,
I was also reviewing this tool (which is great, btw) for using with a WPF solution with lots of resource files. I've run into the same kind of issue while exporting resources, and noticed that it's happening for projects that are outside the path of the solution.
The problem is caused by the inability to get the path of a project file relative to the solution root in a situation like the one previously mentioned.
I've submitted a PR with a fix for this issue (#495). (This might also fix #431)

@tom-englert
Copy link
Collaborator

Fixed by #495

@tom-englert tom-englert added this to the 1.69 milestone Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants