HakanL / resxtranslator

Resx Resource Translator
GNU General Public License v2.0
139 stars 30 forks source link

Editing a key creates a duplicate when saving and reloading #32

Closed MartinWahnschaffe closed 5 years ago

MartinWahnschaffe commented 6 years ago

Steps to reproduce:

  1. Take a resx file that has at least one entry (not necessary to have additional translation files)
  2. Change the name of the entries Key
  3. Save and reload the directory. Besides the changed key there will now also be an entry with the old key.

This does not happen for newly created keys.

My settings (if relevant)

  <HideEmptyResources>True</HideEmptyResources>
  <ShowNullValuesAsGrayed>True</ShowNullValuesAsGrayed>
  <LanguageSelectOnlyNeutral>True</LanguageSelectOnlyNeutral>
  <OpenLastDirOnStart>True</OpenLastDirOnStart>
  <HideNontranslatedResources>False</HideNontranslatedResources>
  <TranslatableInBrackets>False</TranslatableInBrackets>
  <AddDefaultValuesOnLanguageAdd>False</AddDefaultValuesOnLanguageAdd>
  <CellEditorWrapContents>False</CellEditorWrapContents>
  <ReferencePathsFromResourceDir>True</ReferencePathsFromResourceDir>
  <CellEditorShowWhitespace>False</CellEditorShowWhitespace>
  <StoreCommentsInAllFiles>False</StoreCommentsInAllFiles>
Klocman commented 6 years ago

Can you test this build? Debug.zip It appears to be working correctly, but don't use it on important files. Please check to make sure that nothing more than necessary is removed.

SeriousMartin commented 6 years ago

Just tested it. It doesn't have duplicates anymore đź‘Ť

Unfortunately, it now reorders all the keys, so its a bit difficult to say for sure if something is missing. For most files it just seems to have the entries in reverse alphabetic order. In some files (I couldn't find a clear pattern) only part of the entries are affected.

Klocman commented 6 years ago

Is the ordering the only issue? You can order everything by key to make it easier to compare.

SeriousMartin commented 5 years ago

It was ordered by key. I just opened the directory, changed one file and when saving the key order of many files was changed.

SeriousMartin commented 5 years ago

@Klocman Can you provide a branch with the changes you made? I could look into it and find out why the ordering of the keys is disrupted.

Klocman commented 5 years ago

Here you go https://github.com/HakanL/resxtranslator/tree/removeTest , check the last commit for the change. It looks like the entire _deletedKeys logic can be removed if the only side effect is wrong ordering. It should be possible to preserve it in some different way.

SeriousMartin commented 5 years ago

Thanks, that helped a lot to understand the way the ResourceHolder works. I have created a pull request that will fix the problem and keep the order of the keys.