Skip to content

Commit

Permalink
Merge pull request #38 from plone/maurits/serbian-master
Browse files Browse the repository at this point in the history
Support Cyrillic and Latin character sets for Serbian. [master]
  • Loading branch information
jensens authored Oct 14, 2021
2 parents 36db66a + 838e2b9 commit e9589cf
Show file tree
Hide file tree
Showing 2 changed files with 26 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]
23 changes: 23 additions & 0 deletions plone/i18n/locales/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from plone.i18n.locales.interfaces import IMetadataLanguageAvailability
from zope.interface import implementer

import os


@implementer(ILanguageAvailability)
class LanguageAvailability:
Expand Down Expand Up @@ -460,6 +462,10 @@ class MetadataLanguageAvailability(LanguageAvailability):
"flag": "/++resource++country-flags/al.gif",
},
"sr": {
# Note: we support two character sets for this language.
# See zope_i18n_allowed_languages below.
# TODO: in Plone 6.0 native should become 'Srpski',
# but that requires copying sr@Latn to sr in plone.app.locales.
"native": "српски",
"name": "Serbian",
"flag": "/++resource++country-flags/cs.gif",
Expand Down Expand Up @@ -553,6 +559,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["sr"] = {
"native": "Srpski",
"name": "Serbian (Latin)",
"flag": "/++resource++country-flags/cs.gif",
}
elif "sr@Cyrl" in _zope_i18n_allowed_languages:
_languagelist["sr"] = {
"native": "српски",
"name": "Serbian (Cyrillic)",
"flag": "/++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 e9589cf

Please sign in to comment.