Skip to content

Commit 71a7344

Browse files
committed
WEB-4278 : Create translated (de) news categories vocabulary for e-guichet (citizen project)
1 parent 378d897 commit 71a7344

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CHANGES.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Changelog
55
1.2.16 (unreleased)
66
-------------------
77

8-
- Nothing changed yet.
8+
- WEB-4278 : Create translated (de) news categories vocabulary for e-guichet (citizen project)
9+
[boulch]
910

1011

1112
1.2.15 (2025-05-14)

src/imio/news/core/vocabularies.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from zope.schema.vocabulary import SimpleTerm
1212
from zope.schema.vocabulary import SimpleVocabulary
1313
from zope.schema.interfaces import IVocabularyFactory
14+
from zope.i18n import translate
1415

1516

1617
class NewsCategoriesVocabularyFactory:
@@ -28,6 +29,23 @@ def __call__(self, context=None):
2829
NewsCategoriesVocabulary = NewsCategoriesVocabularyFactory()
2930

3031

32+
class NewsDeCategoriesVocabularyFactory:
33+
def __call__(self, context=None):
34+
vocabulary = NewsCategoriesVocabularyFactory()(context)
35+
translated_terms = [
36+
SimpleTerm(
37+
value=term.value,
38+
token=term.token,
39+
title=translate(term.title, target_language="de"),
40+
)
41+
for term in vocabulary
42+
]
43+
return SimpleVocabulary(translated_terms)
44+
45+
46+
NewsDeCategoriesVocabulary = NewsDeCategoriesVocabularyFactory()
47+
48+
3149
class NewsLocalCategoriesVocabularyFactory:
3250
def __call__(self, context=None, lang="fr"):
3351
if IPloneSiteRoot.providedBy(context):

src/imio/news/core/vocabularies.zcml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
component=".vocabularies.NewsCategoriesVocabulary"
77
provides="zope.schema.interfaces.IVocabularyFactory"
88
/>
9+
10+
<utility
11+
name="imio.news.vocabulary.NewsDeCategories"
12+
component=".vocabularies.NewsDeCategoriesVocabulary"
13+
provides="zope.schema.interfaces.IVocabularyFactory"
14+
/>
915

1016
<utility
1117
name="imio.news.vocabulary.NewsLocalCategories"

0 commit comments

Comments
 (0)