Beispiel #1
0
def changedlocale(new_locale=None, category='LC_COLLATE'):
    """ Change locale temporarily within a context (with-statement) """
    # The new locale parameter should be a tuple, e.g. ('is_IS', 'UTF-8')
    # The category should be a string such as 'LC_TIME', 'LC_NUMERIC' etc.
    cat = locale.__getattribute__(category)
    old_locale = locale.getlocale(cat)
    try:
        locale.setlocale(cat, new_locale or _DEFAULT_LOCALE)
        yield locale.strxfrm  # Function to transform string for sorting
    finally:
        locale.setlocale(cat, old_locale)
Beispiel #2
0
	def days(self):
		if len(self._days) == 0:
			self._days.extend([locale.nl_langinfo(
				locale.__getattribute__('DAY_' + str(i+1))).lower() \
					for i in xrange(7)])
		return self._days
Beispiel #3
0
	def months(self):
		if len(self._months) == 0:
			self._months.extend([locale.nl_langinfo(
				locale.__getattribute__('MON_' + str(i+1))).lower() \
					for i in xrange(12)])
		return self._months