Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
pycountry.LOCALES_DIR,
)
def ugettext(s): return s
LANGUAGES = (
('en', ugettext('English')),
('es', ugettext('Spanish')),
# ('ar', ugettext('Arabic')), # Uncomment when we have translations
# ('en-PT', ugettext('English - Pirate')),
)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
),
"resolution_finder": JobFactoryResolutionFinder(
self,
config['scanner_resolution'].value,
RECOMMENDED_SCAN_RESOLUTION
),
"scan": JobFactoryCalibrationScan(
self,
self.device_settings['resolution']['stores']['loaded']
),
"progress_updater": JobFactoryProgressUpdater(self.progressbar),
}
try:
translations = gettext.translation(
'iso639-3', pycountry.LOCALES_DIR
)
logger.info("Language name translations loaded")
except Exception:
logger.exception("Unable to load languages translations")
translations = None
ocr_tools = pyocr.get_available_tools()
if len(ocr_tools) == 0:
short_ocr_langs = []
else:
short_ocr_langs = ocr_tools[0].get_available_languages()
ocr_langs = []
for short in short_ocr_langs:
if short in ['equ', 'osd']:
# ignore some (equ = equation ; osd = orientation detection)
def get_sorted_countries(language="en"):
"""
Gets the list of countries sorted by localized name.
NOTE: If we start adding more localization code, we should probably consolidate that code into a localization module.
:param language: Language to localize into and sort
:return: list of countries sorted by localized language
"""
translator = gettext.translation(
domain='iso3166',
localedir=pycountry.LOCALES_DIR,
languages=[language],
codeset='utf-8',
fallback=True,
)
return sorted([(c.name, translator.gettext(c.name)) for c in list(pycountry.countries)], key=lambda x: x[1])