Skip to content

Commit

Permalink
Support Cyrillic and Latin character sets for Serbian.
Browse files Browse the repository at this point in the history
See collective/plone.app.locales#326

Let 'sr' be general Serbian. Can be Latin or Cyrillic.
You can influence which character set is used, by choosing one of three values in an environment variable:

```
zope_i18n_allowed_languages sr
zope_i18n_allowed_languages sr@Cyrl
zope_i18n_allowed_languages sr@Latn
```

Default character set in Plone 5.2 is Cyrillic, but this may change to Latin in 6.0.
  • Loading branch information
mauritsvanrees committed Sep 7, 2021
1 parent 93fca12 commit ed1343a
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 ed1343a

Please sign in to comment.