Improve handling of import queue template entries
Goal
According to user feedback, the current workflow to review templates on the import queue is not very efficient. Especially the need to switch between the queue listing and the form for the individual entries is slowing down work, as well as the need to copy-and-paste strings to define template names and translation domains.
Anticipated imporvement are:
- get suggestions on template name and translation domain based on the file name
- if the suggestoin is correct, the approval should occur right in the queue list display by changing the status of the entry.
Changed workflow
The workflow should be changed to include more states for the queue entries. These new states represent the findings of the auto-approval script when it was not able to approve an entry.
New marks this template as a (possibly) new upload that has not been uploaded yet. This is determined by extracting a template name from the file name and not finding a match for it in the database.
Exists marks this template as (possibly) being a replacement for an existing template but with a changed file name. This is the case if the template name extracted from the file name is found in the database but the existing translation domain does not match the new translation domain. Approving this entry would update the translation domain to the new value.
Conflicts marks a template whose translation domain is already found in a different package (this check is already done). The reviewer's action woudl be to either block this entry or to deactivate the old template and approve this entry.
Also, the Approved state should be available fromt he queue listing for entries in those states so that the reviewer does not have to go through the form if the suggested values are correct.
Template name extraction
A central point of the changed workflow is the extraction of template names and translation domains from the filenames of the the template files.
- To extract the template name, the file name without the .pot extension is split into all parts delimited by - (dash) or _ (underscore) and then joined again using dashes (template names cannot contain underscores). The joined name is searched for in the databae and if not found, the last part is removed and the search repeated, and again until all parts have been tried.
- Example: Filename my_translation_domain-2.4-beta.pot would result in a search for the following template names:
- my-translation-domain-2.4-beta (Not found)
- my-translation-domain-2.4 (Not found)
- my-translation-domain (Found!)
Another check would be, if any of the parts are made up of numbers and dots, representing a version number. For suggesting a new template name if no matching existing name was found, all the parts before this numerical part would be used.
- Example: Filename my_translation_domain-2.4-beta.pot would result in a search for the following template names:
- The suggested translation domain is simply the name of the file without directories and the the .pot extension. A further step could be to use the name of the containing directory if the name of the template is "messages.pot".