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
Initial virtual folders #3600
Initial virtual folders #3600
Conversation
item = make_generic_item(directory) | ||
filters = {} | ||
|
||
if len(VirtualFolder.get_matching_for(directory.pootle_path)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see this will incur in N*M+1 queries, where:
- N is the number of directories being displayed in the overview,
- M is the number of filtering rules in each browsable
VirtualFolder
, and - 1 is the query needed for retrieving browsable
VirtualFolder
s
Looks excessive on a first sight, even more taking into account there's no caching of any sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been replaced by a new call that triggers only 1 query.
Regarding the cache, the plan is to get something that works, and then optimize it using cache.
6adea80
to
bfe72eb
Compare
In order to check this locally you will have to follow these steps:
|
.. versionadded:: 2.7 | ||
|
||
Virtual folders provide a way to group translations based on any criteria, | ||
including a same file across all the languages in a project, or specific files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does a same file mean here? Can you maybe reword it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means that a file named file.po
is matched in all languages in a project. For example /af/proj/file.po
or /eu/proj/file.po
.
Rephrased to avoid confusion.
2e4fbe1
to
5e6d829
Compare
.. _virtual_folders#attributes: | ||
|
||
Virtual folders attributes | ||
----------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Underline unnecessarily long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
c48830e
to
853893a
Compare
Thanks, @julen. Are you able to setup v-folders on your side? I think I tried to closely follow the sample JSON provided, but have no luck seeing the v-folders in the browser |
I can actaully see the empty but open side panel if I go to https://translate.stage.evernote.com/ru/website3_evernote/home/ (again, this might be some side effect of caching, but worth checking on your side) |
@iafan this first stage commit has no UI. The change forces editing based on v-folder priority. The second stage, not yet PR'd, adds the UI for the TP level. |
@dwaynebailey, so how one is supposed to test this? It makes sense to add UI to this PR as well, and test the feature as a whole, IMO. |
@iafan I realize some setting changes to disable the imports/exports were uncommitted on myside, and that's fixed now. In any case this displays that imports/exports in master is not in good shape, and I already reported this on IRC. |
return locations | ||
elif "{LANG}" in self.location: | ||
return [self.location.replace("{LANG}", lang.code) | ||
for lang in Language.objects.all()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use only current project languages.
It seems that I missed the party.
No descriptions are being displayed as it is not yet clear to me where does should be displayed.
This is just the first step. In the future you can expand this as necessary to support more filtering methods. For now using stores just recovers our lost goals functionality.
No. This is not yet implemented. You can instead hide vfolders by setting them to not being browsable. Changing vfolders is supported through the
I was assuming that people would check the docs and the sample JSON in case of doubt. As you can see the sample JSON always includes the trailing slashes. Just checked the code and it never complains, but in some cases the absence of trailing slash might result on not getting the desired results on filtering.
No change is done in this PR to the sidebar, so these should be issues already present on master.
I don't think this PR has bugs. Re testing, see below.
Please see the testing steps provided on comment #3600 (comment) I am aware that lack of UI difficults too much the testing, but the steps in that comment should be enough. If they are not enough we can talk about appending here some of the commits already finished that add UI bits, despite that I would prefer to land the current set of commits since has been tested and reworked several times instead of adding more commits that might need to be reworked more times thus delaying this PR even more. |
@iafan I agree we need a way to remove a vfolder. IMHO considering that a vfolder that is not on the JSON means that it should be removed is a bad idea. I mean that if you have 100 vfolders you usually going to use the JSON to just alter some vfolders (lets say 5 of them) and having to deal with a JSON with 100 vfolder is not comfortable. Besides that having a Another option is to add a new management command $ ./manage.py del_vfolder my-vfolder /{LANG}/proj/dir/subdir/subsubdir/ which I am not sure if can be considered simple and easy. Anyway whichever way we take re deleting, IMHO it is less priority than providing a working UI for translators to work with vfolders. Despite it is an ugly workaround, you can always hide vfolders by setting them to not being browsable. |
@unho can you create an issue to track the del_vfolder command. I think we can delay it with the 1.0 and not browesable hack. But we do need to fix it to complete the feature. |
@iafan the way I tested was as following. I created 3 simple 3 unit PO files (translated, untranslated, fuzzy) a.po, b.po, c.po. I created vfolder that set 2.0 for b.po and 0.5 priorities for a.po. Used the editor to ensure that the files appear in the order specified which would be b.po, c.po, a.po. This first implementation is designed simply to ensure the backend for storing goals is good and that priority sorting of gaols works correctly. |
@dwaynebailey Done: #3634 |
Using a m2m field between VirtualFolder and Unit will ease fast retrieving of matching units and vfolders, also will allow to retrieve units sorted by vfolder priority. The priority field is a float in order to be able to set priorities between 0 and 1. Validators are not run on instance save, so the we can't use validators to ensure the priority is greater than zero. Part of translate#3521.
Not browsable vfolders are not returned. Fixes translate#3522.
The 'view all' link is never sorted. Part of translate#3614.
Links to all units are not sorted. Also this is only for directories, since we are currently recovering our previous goals functionality, which used stores. Fixes translate#3614.
Then I can delegate the review to @julen. If this feature is not visible and has not reached the level it can be of real use to us (Evernote), I'm ok to have it merged if Julen confirms that it looks sane from the backend side. I'll be happy to review this once the UI part has landed, and once we can start testing this on some real-life scenarios (for us the first most obvious case will be to group projects together, which needs the filters to support paths, not individual .po files). |
@unho, I think I disagree on this. From my perspective, it would be much easier to have one JSON file which fully represents the config for all v-folders, and maintain it, adding or deleting entries from it. Then a single command, say, Otherwise, you're going to have two commands ( |
I see your point, but I was thinking on a several admins scenario. Maybe yours is better. @dwaynebailey any input on this?
@iafan Can you explain this a bit more? |
I think this is pretty similar to regular Pootle configs. We have several Pootle admins, and they have an access to the Pootle configuration file, which we keep in Git. The same thing is applicable to this JSON config — especially if there are multiple people working with it — it makes sense to keep it in version control (and this is where its history will be stored), and then apply it as a whole (e.g. as a part of deployment script) to the server. |
This is pretty straightforward: imagine you can set up any path prefix in your {
"name": "ios_skitch_evernote_bundle",
"location": "/{LANG}/",
"filters": {
"files": [
"ios_skitch_evernote",
"common_skitch_evernote"
]
}
}, This is a v-folder that lives inside each language folder, and which groups two translation projects together, identified by their relative paths: |
Ready to review.
This is meant to somehow recover our old goals functionality, but using the new vfolders.
This provides a management command to create and update virtual folders, adds the ability to sort the units by (vfolder) priority on the editor, and injects the priority sorting into the translate URLs in the translation project overview.
Things that differ from specs: