-
Notifications
You must be signed in to change notification settings - Fork 462
Character order and measurement systems #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c3536d4
2ab44a0
532f638
91ae2ef
99dc0c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -885,6 +885,40 @@ def ordinal_form(self): | |
| """ | ||
| return self._data.get('ordinal_form', _default_plural_rule) | ||
|
|
||
| @property | ||
| def measurement_systems(self): | ||
| """Localized names for various measurement systems. | ||
|
|
||
| >>> Locale('fr', 'FR').measurement_systems['US'] | ||
| u'am\\xe9ricain' | ||
| >>> Locale('en', 'US').measurement_systems['US'] | ||
| u'US' | ||
|
|
||
| """ | ||
| return self._data['measurement_systems'] | ||
|
|
||
| @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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels pretty redundant with the method above. I understand the value of providing the CSS-specific value in this package (commonly used), but I don't think it belongs in the Locale class. We could create helper modules that provide methods like this that transform CLDR values into ones accepted by other systems. Off hand, I can't think of any other ones that might be relevant for CSS (maybe language code?), but, for instance, converting date format strings to JS compatible ones might be useful to someone.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is that much of an evil. After all,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yikes, good catch. :) What do you think about transforming "left-to-right" to "ltr" (yah, I'm still trying to get rid of one of the two methods :)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, |
||
| def text_direction(self): | ||
| """The text direction for the language in CSS short-hand form. | ||
|
|
||
| >>> Locale('de', 'DE').text_direction | ||
| 'ltr' | ||
| >>> Locale('ar', 'SA').text_direction | ||
| 'rtl' | ||
| """ | ||
| return ''.join(word[0] for word in self.character_order.split('-')) | ||
|
|
||
|
|
||
| def default_locale(category=None, aliases=LOCALE_ALIASES): | ||
| """Returns the system default locale for a given category, based on | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would have been a great use of a Python 3.4 Enum. Just an observation, no need to do anything here. :)