SUMMARY In the project view, when one right-clicks on a folder which contain a completely untranslated catalogue (i.e. one which only exists as a .pot file, not a ‘.po’ file) and selects ‘Open selected files’, the .pot file is opened instead of a .po file being created. The same thing happens when you right-click on a .pot file and selected ‘Open’. When saving the file, the original .pot file is overwritten, making it an invalid .pot file, i.e. one containing translations. STEPS TO REPRODUCE 1. Open a translation project which contain at least one non-translated files (e.g. use the Norwegian Nynorsk project ‘trunk/l10n-support/nn/kde-nynorsk.lokalize’ in the KDE repository). 2. Right-click on a folder which contain non-translated files (.pot files) (e.g. ‘extragear-edu’ for the Norwegian Nynorsk project) and select ‘Open selected files’ 3. Navigate the one of the .pot files, edit a string and save the file. OBSERVED RESULT The .pot file in the template folder is opened and saved. EXPECTED RESULT A corresponding .po file in translation folder should be created/saved. ADDITIONAL INFORMATION Opening a .pot file by double-clicking on it, works fine. That is, a .po file is created in the translation folder when you save the file. And the name of tab is ‘filename.po’, not ‘filename.pot’, to reflect that you’re editing the .po translation file, not the .pot template file. So it is only when opening files using the ‘Open selected files’ menu item in the right-click menu on a folder or the ‘Open’ menu item in the right-click menu on a file that the wrong file is opened/saved. I set the ‘Severity’ to a ‘Major’, as this bug can lead to data-loss (overwriting template files). I observe this bug using the latest Git version of Lokalize (Lokalize 19.03.70 – not possible to choose this version number in Bugzilla).
> A corresponding .po file in translation folder should be created/saved. How should it be named ? What should happen if there's already a .po file with that same name ? A dialog would be fine in that case ?
1. .po naming algorithm should be the same as if you clicked the same .pot template in the Project Browser tab. 2. When the .po already exists, I think it should open the existing .po file and may be display a messagebox saying something like "<p>Translation catalog %1 for the template %2 already exists. Lokalize opened the existing catalog for you.</p><p>If you wanted to create an empty catalog using the template, delete the existing catalog and try again.</p>". (However it's a very rare case when someone creates .po file with external tools and then goes back to Lokalize to perform the same task.)
IMHO, if there already is a .po file with that name, this should be opened. It’s not necessary to show a dialogue. Basically, clicking a file opens that *catalogue*, which is always a PO file, either an automatically created file (when saved) or an existing PO file.
Revisiting this now, should the .po file be next to the .pot by default and we let the user move the generated .po file by himself if he has a different folder structure?
(In reply to Simon Depiets from comment #4) > Revisiting this now, should the .po file be next to the .pot by default and > we let the user move the generated .po file by himself if he has a different > folder structure? No. The PO file structure mirrors the POT file structure. The structure is set up in the project options (root folder for the PO files, template folder for the POT files). So if the POT file is at ~/kde/trunk/l10n-support/templates/summit/messages/kpat/kpat_mimetypes.pot and the PO file is at ~/kde/trunk/l10n-support/nn/summit/messages/kpat/kpat_mimetypes.po the template folder would be set to (for example) ~/kde/trunk/l10n-support/templates/summit/messages and the root folder would be set to ~/kde/trunk/l10n-support/nn/summit/messages Lokalize handles this perfectly file if you *click* on a single POT file (which doesn’t have a PO file). The PO file is automatically stored in the correct place, in a folder structure in the root folder mirroring the folder structure in the templates folder. It’s when you instead use the ‘Open selected files’ on a folder containing POT files that the PO files generated are stored in the wrong place (and with the wrong extension, POT instead of PO). So perhaps the two ways of creating a PO file from a POT files doesn’t use the same code path?
BTW, note the difference between 1) *left-clicking* on a POT file and 2) *right-clicking* on a POT file and selecting ‘Open’. The former creates a PO file in the correct place. The latter overwrites the POT file (with a file containing any translations added). Right-clicking on either multiple POT files or a folder containing POT files and selecting ‘Open selected files’ works the same way as option 2 above, i.e., it overwrites the POT files.
@Simon so the difference is that left clicking goes through ProjectWidget::slotItemActivated that calls ProjectModell::beginEditing //copies POT file to PO file and returns url of the PO file and then calls fileOpenRequested on it while right mouse button just calls fileOpenRequested on the files themselves. Personally i'm not totally sure that "Open" should be creating a new file, if not, we should add a new action for .pot files that is "Create .po and start editing" or something.
Ok I have a better understanding of the issue now, I'll work on it
Git commit ddb662f89bb06e4c828b7b5250c8ad81b6df5ba4 by Simon Depiets. Committed on 14/06/2020 at 17:41. Pushed by sdepiets into branch 'master'. Harmonize file open behavior for .pot M +3 -3 src/project/projectmodel.h M +4 -1 src/project/projecttab.cpp https://invent.kde.org/sdk/lokalize/commit/ddb662f89bb06e4c828b7b5250c8ad81b6df5ba4