-
Notifications
You must be signed in to change notification settings - Fork 1
Add endpoints for source and translation string details. #5
Conversation
905427b
to
4953a69
Compare
|
One use-case for downloading just source is if the editor were loaded before selecting a language, such as if it is deployed as a standalone application. It would also be useful in any case where someone wants to look at source strings. The use-cases for downloading just translations include changing language, and requesting translations from another language for reference. In both cases the editor already has the source strings so it would be wasteful to make the server look them up from the database and transmit them over the connection. |
No, just the head revision of the translation. I can imagine plenty of use-cases for wanting the head revision without the history, so it should not be included by default. It would make sense to allow clients to optionally request history, either in a separate request or as part of a trans or source+trans request, so I could add endpoints to include translation history:
I will create an issue for adding these - this pull request has plenty in it already, and the endpoints work without history. We may eventually want source history as well. I'm not sure if we have the data for that, but there are some file formats for which it makes sense (anything that provides an ID for strings). We can design a sensible endpoint for that to make sure we aren't painting ourselves into a corner with the proposed URLs. It could just use something like |
The editor can just ask for |
Just happened to look at the endpoints and had a question: I think I like the |
@davidmason, so we are allowing the editor to be loaded with no selected locale (with selected document I assume), how is that gonna display on the text area? |
Either one provides sufficient information to generate the response. I have a few reasons to prefer my proposal to this suggestion:
There is one aspect of my proposed endpoints that is not really sensible: the whole leading portion of the URL is redundant. Since I opted for the (Long) ID rather than resId, there is enough information to get all the data without knowing the project, version or document. I can only think of two reasons to keep all that other stuff in the URL, and both are weak:
So basically I should probably be using |
+1 on |
I'm not sure if we are doing this at the moment, but it seems likely we will want to do so in the future. Off the top of my head, I can picture showing the source on the left as it already does, and on the right showing "select a language". |
So, in terms of Sure, In terms of the editor, since it will probably do paging of some sort, why not use the index in the document to identify it. In the end, the url would be something like: |
The closest we have is resId, which appears to be an arbitrary string - the lack of constraint on resId leads to 2 problems:
That would be a reasonable option - good for URL length (shorter on average than database ID) and for readability, and more semantically meaningful than the database ID. It is also expressive enough to fetch data about any individual row or set of rows from the document. It does add one limitation that does not exist when using database IDs: if the editor condenses multiple small documents into a single view (as has been requested by users, and presumably it one day will do so), the editor would not be able to request text flow data in a range that crosses a document boundary. This would be most noticeable when loading a set of single-string documents: if a page is 20 rows, it would require 20 requests to fetch the first page, whereas using database ID would require only one'*. '* I would probably use 3 though: fetch the first row on its own immediately, then the next 3 or so, then the rest of the page, the goal being to allow the user to start editing immediately without waiting for the whole page to load. |
@carlosmunoz I might as well add both database-ID and document-row endpoints to the fake server, so we can try both in the editor and evaluate them with a bit of practical experience. I'll create an issue to track the document-row endpoint creation. I will keep |
That shouldn't be a very common case.
Maybe splitting those is not such a bad idea. Keeping your requests short and quick is a good way of preventing long lived operations from hogging the system (even if they are reads). some applications restrict the number of elements that can be read (written) in a single operation, maybe we should consider the same.
I think that's a very good idea.
Sounds good |
It is common enough that translators to have suggested combining documents several times. I think it is worth considering. There is a chance that we would decide that designs that cater well to the tiny-documents use-case require too much of a trade-off in other areas, but if we end up with a couple of options that are equally worthy in other areas, tiny-document handling could be the decider. |
some text flows. | ||
- may respond with 403 (Forbidden) if the list of ids is too long. The | ||
limit should be set at a sufficiently high number as to prevent the editor | ||
getting a 403 response in normal operation. |
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.
some applications restrict the number of elements that can be read (written) in a single operation, maybe we should consider the same.
I agree completely. We can figure out a sensible limit once we see what the editor tends to use normally. I suspect it will also force better async design in the editor, by making us think about breaking up requests that would be too large.
👍 |
39a6497
to
9454944
Compare
This adds 3 endpoints: source strings, translation strings, and both. The endpoints use query parameter 'ids' to request a specific set of translation units using the textflow numeric id (comma-separated list). This also replaces the simple list of path strings with a list of thunks, allowing far more flexibility in specifying paths, particularly sets of similar paths that would require a lot of repetition.
9454944
to
332abc0
Compare
Required some changes to how endpoints are specified so that earlier endpoints would take precedence, and so that different query string parameters can be specified.