Skip to content

Commit 2130dd8

Browse files
committed
version 3.3.0
1 parent 971de36 commit 2130dd8

21 files changed

+846
-36
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
os: [ubuntu-latest]
1818
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
19-
poetry-version: ["2.0.1"]
19+
poetry-version: ["2.1.2"]
2020
steps:
2121
- uses: actions/checkout@v4
2222
- uses: actions/setup-python@v5

docs/_templates/globaltoc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ <h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3>
77
<li><a href="{{ pathto('api/comments') }}">Comments</a></li>
88
<li><a href="{{ pathto('api/contributors') }}">Contributors</a></li>
99
<li><a href="{{ pathto('api/files') }}">Files</a></li>
10+
<li><a href="{{ pathto('api/glossary_terms') }}">Glossary terms</a></li>
1011
<li><a href="{{ pathto('api/jwt') }}">JWT</a></li>
1112
<li><a href="{{ pathto('api/keys') }}">Keys</a></li>
1213
<li><a href="{{ pathto('api/languages') }}">Languages</a></li>

docs/additional_info/changelog.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,52 @@
33
Changelog
44
=========
55

6+
3.3.0 (22-Apr-2025)
7+
-------------------
8+
9+
* Added support for `GlossaryTerms <https://developers.lokalise.com/reference/list-glossary-terms>`_ endpoint:
10+
11+
.. code-block:: python
12+
13+
glossary_terms = client.glossary_terms(PROJECT_ID, {
14+
"limit": 2,
15+
})
16+
17+
glossary_term = glossary_terms.items[0]
18+
glossary_term.term # => "router"
19+
glossary_terms.next_cursor # => "5489103"
20+
21+
22+
new_glossary_terms = client.create_glossary_terms(PROJECT_ID, [
23+
{
24+
"term": "python",
25+
"description": "sample desc",
26+
"caseSensitive": False,
27+
"forbidden": False,
28+
"translatable": True,
29+
"tags": ["term1"]
30+
},
31+
{
32+
"term": "code editor",
33+
"description": "",
34+
"caseSensitive": False,
35+
"forbidden": False,
36+
"translatable": True,
37+
"translations": [{
38+
"langId": 674,
39+
"translation": "éditeur de code",
40+
"description": (
41+
"Logiciel permettant d’écrire, modifier "
42+
"et organiser du code informatique."
43+
)
44+
}],
45+
"tags": ["term2"]
46+
},
47+
])
48+
49+
new_glossary_terms.items[0].term # => "python"
50+
51+
652
3.2.0 (17-Feb-2025)
753
-------------------
854

docs/api/glossary_terms.rst

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
Glossary terms endpoint
2+
=======================
3+
4+
`Glossary terms documentation <https://developers.lokalise.com/reference/list-glossary-terms>`_
5+
6+
Fetch all glossary terms
7+
------------------------
8+
9+
.. py:function:: glossary_terms(project_id, [params=None])
10+
11+
:param str project_id: ID of the project
12+
:param dict params: Request parameters
13+
:return: Collection of glossary terms
14+
15+
This endpoint uses cursor-based pagination.
16+
17+
Example:
18+
19+
.. code-block:: python
20+
21+
glossary_terms = client.glossary_terms(PROJECT_ID, {
22+
"limit": 2,
23+
"cursor": "12345"
24+
})
25+
26+
glossary_term = glossary_terms.items[0]
27+
glossary_term.term # => "router"
28+
glossary_terms.next_cursor # => "5489103"
29+
30+
31+
Fetch a glossary term
32+
---------------------
33+
34+
.. py:function:: glossary_term(project_id, glossary_term_id)
35+
36+
:param str project_id: ID of the project
37+
:param glossary_term_id: ID of the term to fetch
38+
:return: Glossary term model
39+
40+
Example:
41+
42+
.. code-block:: python
43+
44+
glossary_term = client.glossary_term(PROJECT_ID, GLOSSARY_TERM_ID)
45+
46+
glossary_term.term # => "router"
47+
glossary_term.description # => "A network device"
48+
glossary_term.translatable # => True
49+
50+
51+
Create glossary terms
52+
---------------------
53+
54+
.. py:function:: create_glossary_terms(project_id, params)
55+
56+
:param str project_id: ID of the project
57+
:param params: Glossary terms parameters
58+
:type params: list or dict
59+
:return: Glossary terms collection
60+
61+
Example:
62+
63+
.. code-block:: python
64+
65+
glossary_terms = client.create_glossary_terms(PROJECT_ID, [
66+
{
67+
"term": "python",
68+
"description": "sample desc",
69+
"caseSensitive": False,
70+
"forbidden": False,
71+
"translatable": True,
72+
"tags": ["term1"]
73+
},
74+
{
75+
"term": "code editor",
76+
"description": "",
77+
"caseSensitive": False,
78+
"forbidden": False,
79+
"translatable": True,
80+
"translations": [{
81+
"langId": 674,
82+
"translation": "éditeur de code",
83+
"description": (
84+
"Logiciel permettant d’écrire, modifier "
85+
"et organiser du code informatique."
86+
)
87+
}],
88+
"tags": ["term2"]
89+
},
90+
])
91+
92+
term0 = glossary_terms.items[0]
93+
term1 = glossary_terms.items[1]
94+
95+
term0.term # => "python"
96+
term1.tags # => ["term2"]
97+
98+
99+
Update glossary terms
100+
---------------------
101+
102+
.. py:function:: update_glossary_terms(project_id, params)
103+
104+
:param str project_id: ID of the project
105+
:param dict params: Glossary terms parameters
106+
:return: Glossary terms collection
107+
108+
Example:
109+
110+
.. code-block:: python
111+
112+
updated_terms = client.update_glossary_terms(PROJECT_ID, [
113+
{
114+
"id": GLOSSARY_TERM_ID,
115+
"description": "updated description",
116+
"caseSensitive": False
117+
}
118+
])
119+
120+
term = updated_terms.items[0]
121+
122+
term.description # => "updated description"
123+
term.caseSensitive # => False
124+
125+
126+
Delete glossary terms
127+
---------------------
128+
129+
.. py:function:: delete_glossary_terms(project_id, glossary_terms_ids)
130+
131+
:param str project_id: ID of the project
132+
:type glossary_terms_id: int or str
133+
:param list glossary_terms_ids: List of the term IDs to delete
134+
:return: Delete response
135+
:rtype dict:
136+
137+
Example:
138+
139+
.. code-block:: python
140+
141+
response = client.delete_glossary_terms(PROJECT_ID, [5489360, 5489361])
142+
143+
deleted_info = response['data']['deleted']
144+
145+
deleted_info['count'] # => 2
146+
deleted_info['ids'][0] # => 5489360

docs/index.rst

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,34 @@ Usage
4040
-----
4141

4242
.. toctree::
43-
:maxdepth: 2
44-
45-
api/getting_started
46-
api/branches
47-
api/comments
48-
api/contributors
49-
api/files
50-
api/jwt
51-
api/keys
52-
api/languages
53-
api/orders
54-
api/payment_cards
55-
api/permission_templates
56-
api/projects
57-
api/queued_processes
58-
api/snapshots
59-
api/screenshots
60-
api/segments
61-
api/tasks
62-
api/teams
63-
api/team_users
64-
api/team_user_groups
65-
api/team_user_billing_details
66-
api/translations
67-
api/translation_providers
68-
api/translation_statuses
69-
api/webhooks
43+
:maxdepth: 2
44+
45+
api/getting_started
46+
api/branches
47+
api/comments
48+
api/contributors
49+
api/files
50+
api/glossary_terms
51+
api/jwt
52+
api/keys
53+
api/languages
54+
api/orders
55+
api/payment_cards
56+
api/permission_templates
57+
api/projects
58+
api/queued_processes
59+
api/snapshots
60+
api/screenshots
61+
api/segments
62+
api/tasks
63+
api/teams
64+
api/team_users
65+
api/team_user_groups
66+
api/team_user_billing_details
67+
api/translations
68+
api/translation_providers
69+
api/translation_statuses
70+
api/webhooks
7071

7172
Additional information
7273
----------------------

lokalise/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
This module contains plugin metadata.
55
"""
66

7-
__version__: str = "3.1.0"
7+
__version__: str = "3.3.0"

lokalise/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .client_methods.comments import CommentMethods
1212
from .client_methods.contributors import ContributorMethods
1313
from .client_methods.files import FileMethods
14+
from .client_methods.glossary_terms import GlossaryTermsMethods
1415
from .client_methods.jwt import JwtMethods
1516
from .client_methods.keys import KeyMethods
1617
from .client_methods.languages import LanguageMethods
@@ -39,6 +40,7 @@ class Client(
3940
CommentMethods,
4041
ContributorMethods,
4142
FileMethods,
43+
GlossaryTermsMethods,
4244
JwtMethods,
4345
KeyMethods,
4446
LanguageMethods,
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""
2+
lokalise.client_methods.glossary_terms
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
This module contains API client definition for glossary terms.
5+
"""
6+
from typing import Optional, Union, Dict, Any, List
7+
from lokalise.models.glossary_term import GlossaryTermModel
8+
from lokalise.collections.glossary_terms import GlossaryTermsCollection
9+
from .endpoint_provider import EndpointProviderMixin
10+
11+
12+
class GlossaryTermsMethods(EndpointProviderMixin):
13+
"""Glossary term client methods.
14+
"""
15+
16+
def glossary_terms(self, project_id: str,
17+
params: Optional[Dict] = None) -> GlossaryTermsCollection:
18+
"""Fetches all glossary terms for the given project.
19+
20+
:param str project_id: ID of the project
21+
:param dict params: (optional) Request parameters
22+
:return: Collection of glossary terms
23+
"""
24+
raw_terms = self.get_endpoint("glossary_terms"). \
25+
all(params=params, parent_id=project_id)
26+
return GlossaryTermsCollection(raw_terms)
27+
28+
def glossary_term(self,
29+
project_id: str,
30+
glossary_term_id: Union[str, int]) -> GlossaryTermModel:
31+
"""Fetches a glossary term.
32+
33+
:param str project_id: ID of the project
34+
:param glossary_term_id: ID of the term to fetch
35+
:return: Glossary term model
36+
"""
37+
raw_term = self.get_endpoint("glossary_terms"). \
38+
find(parent_id=project_id, resource_id=glossary_term_id)
39+
return GlossaryTermModel(raw_term)
40+
41+
def create_glossary_terms(self,
42+
project_id: str,
43+
params: Union[Dict[str, Any], List[Dict]]
44+
) -> GlossaryTermsCollection:
45+
"""Creates one or more glossary terms in the project
46+
47+
:param str project_id: ID of the project
48+
:param params: Glossary terms parameters
49+
:type params: list or dict
50+
:return: Glossary terms collection
51+
"""
52+
raw_terms = self.get_endpoint("glossary_terms"). \
53+
create(params=params, wrapper_attr="terms", parent_id=project_id)
54+
55+
return GlossaryTermsCollection(raw_terms)
56+
57+
def update_glossary_terms(self,
58+
project_id: str,
59+
params: Dict[str, Any]) -> GlossaryTermsCollection:
60+
"""Updates one or more glossary terms.
61+
62+
:param str project_id: ID of the project
63+
:param dict params: Glossary terms parameters
64+
:return: Glossary terms collection
65+
"""
66+
raw_terms = self.get_endpoint("glossary_terms"). \
67+
update(params=params, wrapper_attr="terms", parent_id=project_id)
68+
return GlossaryTermsCollection(raw_terms)
69+
70+
def delete_glossary_terms(self, project_id: str,
71+
glossary_terms_ids: List[Union[str, int]]) -> Dict:
72+
"""Deletes one or more glossary terms.
73+
74+
:param str project_id: ID of the project
75+
:type glossary_terms_id: int or str
76+
:param list glossary_terms_ids: List of the term IDs to delete
77+
:return: Delete response
78+
:rtype dict:
79+
"""
80+
response = self.get_endpoint("glossary_terms"). \
81+
delete(
82+
params=glossary_terms_ids,
83+
wrapper_attr="terms",
84+
parent_id=project_id)
85+
return response

0 commit comments

Comments
 (0)