How to use the pycountry.LOCALES_DIR function in pycountry

To help you get started, we’ve selected a few pycountry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github learningequality / studio / contentcuration / contentcuration / settings.py View on Github external
# 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/
github openpaperwork / paperwork / paperwork-gtk / src / paperwork / frontend / settingswindow / __init__.py View on Github external
),
            "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)
github learningequality / studio / contentcuration / contentcuration / forms.py View on Github external
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])