X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/8550d172b829f29b2fcd4723789fb2a5d9fff6eb..82c0860d1520489be56457829d49eb17f165b9cd:/src/librarian/util.py diff --git a/src/librarian/util.py b/src/librarian/util.py index 5c9fbc2..805cefd 100644 --- a/src/librarian/util.py +++ b/src/librarian/util.py @@ -2,10 +2,7 @@ # by Paul Winkler # http://code.activestate.com/recipes/81611-roman-numerals/ # PSFL (GPL compatible) -from __future__ import print_function, unicode_literals - import os -import six def int_to_roman(input): @@ -94,7 +91,7 @@ def roman_to_int(input): ... ValueError: input is not a valid roman numeral: IL """ - if not isinstance(input, six.text_type): + if not isinstance(input, str): raise TypeError("expected string, got %s" % type(input)) input = input.upper() nums = ['M', 'D', 'C', 'L', 'X', 'V', 'I'] @@ -128,3 +125,14 @@ def roman_to_int(input): def makedirs(path): if not os.path.isdir(path): os.makedirs(path) + + +def get_translation(language): + import gettext + from .functions import lang_code_3to2 + + return gettext.translation( + 'messages', + localedir=os.path.join(os.path.dirname(__file__), 'locale'), + languages=[lang_code_3to2(language), 'pl'], + )