From: alexbodn@gmail.com Date: Sun, 13 Mar 2016 11:28:20 +0000 (+0200) Subject: Add support for character order information X-Git-Tag: 2.3.1~4^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3536d49c1b72a94b3cf73499174238fb89cf05a;p=thirdparty%2Fbabel.git Add support for character order information --- diff --git a/babel/core.py b/babel/core.py index 3e9f9a39..251ebf16 100644 --- a/babel/core.py +++ b/babel/core.py @@ -885,6 +885,29 @@ class Locale(object): """ return self._data.get('ordinal_form', _default_plural_rule) + @property + def character_order(self): + """The text direction for the language. + + >>> Locale('de', 'DE').character_order + 'left-to-right' + >>> Locale('ar', 'SA').character_order + 'right-to-left' + """ + return self._data['character_order'] + + @property + def direction(self): + """The text direction for the language in CSS short-hand form. + + >>> Locale('de', 'DE').direction + 'ltr' + >>> Locale('ar', 'SA').direction + 'rtl' + """ + order = self.character_order + return ''.join([word[0] for word in order.split('-')]) + def default_locale(category=None, aliases=LOCALE_ALIASES): """Returns the system default locale for a given category, based on diff --git a/scripts/import_cldr.py b/scripts/import_cldr.py index 00d11e95..af48d0f3 100755 --- a/scripts/import_cldr.py +++ b/scripts/import_cldr.py @@ -422,6 +422,9 @@ def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False): parse_unit_patterns(data, tree) parse_date_fields(data, tree) + for elem in tree.findall('.//layout/orientation/characterOrder'): + data['character_order'] = elem.text + write_datafile(data_filename, data, dump_json=dump_json)