Skip to content

Commit

Permalink
Merge pull request #37 from plone/maurits/serbian-4x
Browse files Browse the repository at this point in the history
Support Cyrillic and Latin character sets for Serbian. [4.x]
  • Loading branch information
jensens authored Oct 14, 2021
2 parents 93fca12 + ed1343a commit 8cbc721
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions news/326.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Support Cyrillic and Latin character sets for Serbian.
See `locales issue 326 <https://github.com/collective/plone.app.locales/issues/326>`_.
[maurits, fredvd]
20 changes: 20 additions & 0 deletions plone/i18n/locales/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from plone.i18n.locales.interfaces import IMetadataLanguageAvailability
from zope.interface import implementer

import os
import six


Expand Down Expand Up @@ -469,6 +470,8 @@ class MetadataLanguageAvailability(LanguageAvailability):
u'flag': u'/++resource++country-flags/al.gif',
},
u'sr': {
# Note: we support two character sets for this language.
# See zope_i18n_allowed_languages below.
u'native': 'српски',
u'name': 'Serbian',
u'flag': u'/++resource++country-flags/cs.gif',
Expand Down Expand Up @@ -562,6 +565,23 @@ class MetadataLanguageAvailability(LanguageAvailability):
},
}

# Character sets are a thing now.
# See https://github.com/collective/plone.app.locales/issues/326
# At the moment only for Serbian.
_zope_i18n_allowed_languages = os.environ.get("zope_i18n_allowed_languages", "")
if 'sr@Latn' in _zope_i18n_allowed_languages:
_languagelist[u'sr'] = {
u'native': 'Srpski',
u'name': 'Serbian (Latin)',
u'flag': u'/++resource++country-flags/cs.gif',
}
elif 'sr@Cyrl' in _zope_i18n_allowed_languages:
_languagelist[u'sr'] = {
u'native': 'српски',
u'name': 'Serbian (Cyrillic)',
u'flag': u'/++resource++country-flags/cs.gif',
}

# convert the utf-8 encoded values to unicode
for code in _languagelist:
value = _languagelist[code]
Expand Down

0 comments on commit 8cbc721

Please sign in to comment.