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

Import of Excel fails if the neutral resource file have been deleted #449

Open
Nisden opened this issue Jan 21, 2022 · 2 comments
Open

Import of Excel fails if the neutral resource file have been deleted #449

Nisden opened this issue Jan 21, 2022 · 2 comments

Comments

@Nisden
Copy link

Nisden commented Jan 21, 2022

Describe the bug
Resx Manager fails to import all translations when the neutral resource file have been deleted, but there still is a localized version.

  • MyResource.resx
  • MyResource.da.resx

To Reproduce

  1. Create a resource file with a single row
  2. Translate the row to another language
  3. Export an Excel file of all rows
  4. Delete the neutral resx file
  5. Import the Excel file

Expected behavior
I would expect the ResxManager to skip importing the translation, similar to how it works if all the Resource files are deleted.

I tried debugging this a bit, but I was unable to detect where I would need to make my changes.
But I believe the primary culprit is here:

var mappings = table.Skip(1)
.Select(columns => new { Key = columns[0], TextColumns = columns.Skip(fixedColumnHeadersCount).Take(dataColumnCount).ToArray() })
.Where(mapping => !string.IsNullOrEmpty(mapping.Key))
.SelectMany(mapping => mapping.TextColumns.Select((column, index) =>
new
{
mapping.Key,
Entry = entity.Entries.SingleOrDefault(e => e.Key == mapping.Key) ?? entity.Add(mapping.Key),
Text = column,
Culture = dataColumnHeaders[index].ExtractCulture(),
ColumnKind = dataColumnHeaders[index].GetColumnKind()
}))
.Where(mapping => mapping.Entry != null)
.Select(mapping => new EntryChange(mapping.Entry!, mapping.Text, mapping.Culture, mapping.ColumnKind, mapping.Entry!.GetEntryData(mapping.Culture, mapping.ColumnKind)))
.ToArray();

@tom-englert
Copy link
Collaborator

The neutral file is the key file, so removing it is nothing we need to support.
The project will be messed up any way, so what would be the use case?

@Nisden
Copy link
Author

Nisden commented Jan 24, 2022

Hi Tom!

I agree its messed up, but it can happen when you have multiple developers and translators working in the same project on multiple branches. My real life case was that a developer deleted a section of the application (including translations), but our translator had already exported an excel file because they where adding a new language.

Honestly what was bugging me the most was the error message "Import failed partially. Some columns have been already imported, but not all." it provided no helpful hint on what was wrong.

Maybe listing what imports failed in the "output" tab would be helpful?

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

2 participants