Skip to content
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

Add API for glossary #4118

Closed
twboc opened this issue Jul 1, 2020 · 5 comments · Fixed by #4401
Closed

Add API for glossary #4118

twboc opened this issue Jul 1, 2020 · 5 comments · Fixed by #4401
Assignees
Labels
backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. enhancement Adding or requesting a new feature.
Milestone

Comments

@twboc
Copy link

twboc commented Jul 1, 2020

Describe the bug

When uploading a json file containing translations to the source language with endpoint:
POST /api/translations/(string:project)/(string:component)/(string:language)/file/

New fields saved in json file do not show as additianal translation just like when passing the same file with import glossary method in web client ui.

To Reproduce

Steps to reproduce the behavior:

  1. Prepare json file with translations
  2. Upload the file with curl passing the parameters:
    curl -X POST
    -F file=@$filepath
    -F overwrite=true
    -H "Authorization: Token $API_KEY"
    "https://hostname.com/api/translations/$PROJECT/$TRANSLATIONS_COMPONENT/$LANG/file/"
  3. Open the glossary in the web client /dictionaries/app5/en/
  4. See error - no additional fields from json file added.

If json file added manually glossary is updated with new fields in json file.

How to extend glossary through API

Expected behavior

Uploading a translation json file with additional keys extends the glossary.

@nijel nijel changed the title API - Importing Translation with additional fields does not update the keys in glossary. Add API for glossary Jul 2, 2020
@nijel
Copy link
Member

nijel commented Jul 2, 2020

You are uploading a translation, not a glossary. There is currently no API for glossary.

@nijel nijel added backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. enhancement Adding or requesting a new feature. labels Jul 2, 2020
@nijel nijel added this to To do in API improvements via automation Jul 2, 2020
@github-actions
Copy link

github-actions bot commented Jul 2, 2020

This issue has been added to the backlog. It is not scheduled on our roadmap, but it eventually might be implemented. In case you desperately need this feature, please consider helping or funding the development.

@nijel
Copy link
Member

nijel commented Aug 21, 2020

Desired API:

  • /glossaries/ - list glossaries user has access to
  • /glossaries/(int: id)/ - get details of a glossary (name, color, source language - the last one is not yet there, will be added once Glossary: Add source language attribute #4359 is merged), PUT/PATCH to modify
  • /glossaries/(int: id)/projects/ - get list of associate projects to a glossary, POST to associate another project
  • /glossaries/(int: id)/project/(int: component_id)/ - DELETE to remove project from glossary
  • /glossaries/(int: id)/terms/ - get list of glossary terms, paginated, POST to add new one
  • /glossaries/(int: id)/terms/(int: term_id) - get term details, DELETE to remove, PUT/PATCH to modify

Access control:

  • to see a glossary user needs access to any of component associated with it
  • to edit a glossary attributes, user needs component.edit on any of component associated with it
  • there are glossary.edit glossary.add and glossary.delete permission for editing glossary terms

@nijel
Copy link
Member

nijel commented Aug 21, 2020

The source_language attribute should land soon via #4359, it should support editing in a same way as on project - accept both language code or object from request.

@nijel nijel moved this from To do to In progress in API improvements Aug 21, 2020
@SaptakS SaptakS mentioned this issue Aug 30, 2020
4 tasks
@nijel nijel added this to the 4.3 milestone Sep 15, 2020
API improvements automation moved this from In progress to Done Sep 21, 2020
nijel added a commit that referenced this issue Sep 21, 2020
* Adds glossary API
* Fixes perm check for glossary API
* Fixes permission for glossary term in API
* Use to_internal_value for source languages in glossary

Fixes #4118

Co-authored-by: Michal Čihař <michal@cihar.com>
@github-actions
Copy link

Thank you for your report, the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, consider supporting Weblate by donating.

nijel added a commit that referenced this issue Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. enhancement Adding or requesting a new feature.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants