Skip to main content

A django model & fixture containing common languages and culture codes

Project description

https://badge.fury.io/py/django-languages-plus.svg https://travis-ci.org/cordery/django-languages-plus.svg?branch=master https://codecov.io/gh/cordery/django-languages-plus/branch/master/graph/badge.svg

django-languages-plus provides models and fixtures for working with both common languages and ‘culture codes’ or locale codes, like pt-BR.

Note that this is only a small (but popular) subset of all living languages, and is not even a comprehensive set of the ISO 639 languages. It does however include the endonym/autonym/exonym.

The Language model contains all ISO 639-1 languages and related information from http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

The model provides the following fields (original wikipedia.org column name in parentheses).

  • name_en (ISO Language Name)

  • name_native (Native Name)

  • iso_639_1 (639-1)

  • iso_639_2T = (639-2/T)

  • iso_639_2B = (639-2/B)

  • iso_639_3 = (639-3)

  • family = (Language Family)

  • countries_spoken

Installation

pip install django-languages-plus

Usage

  1. Add languages_plus to your INSTALLED_APPS

  2. Migrate your database and load the language data fixture:

    python manage.py migrate
    python manage.py loaddata languages_data.json.gz
  3. In your code use:

    from languages_plus.models import Language
    lang = Language.objects.get(iso_639_1='en')

Generating Culture Codes (ex: pt_BR)

django-countries-plus(https://pypi.python.org/pypi/django-countries-plus) is now an explicit requirement. After installing both packages you can run the following command once to associate the two datasets and generate a list of culture codes (pt_BR for example):

from languages_plus.utils import associate_countries_and_languages
associate_countries_and_languages()

Requirements

django-countries-plus >= 1.

Django: Tested against the LTS versions of 3, 4, and the latest of 5. Python 3

Running Tests

Does the code actually work?

$ poetry install
$ poetry run pytest

Or for the full tox suite:

$ poetry install
$ pip install tox
$ tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_languages_plus-2.1.0.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_languages_plus-2.1.0-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file django_languages_plus-2.1.0.tar.gz.

File metadata

  • Download URL: django_languages_plus-2.1.0.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

File hashes

Hashes for django_languages_plus-2.1.0.tar.gz
Algorithm Hash digest
SHA256 268b66257f834e1ce84e45d1dbab40c3745deda723d70d227c4d2eb61f3b3749
MD5 2daed4b7eeca56e7e693b935f7c3aca6
BLAKE2b-256 c3675bd05163283a18bf48968373446308f3545cd68e48b84f6545eff4f753c2

See more details on using hashes here.

File details

Details for the file django_languages_plus-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_languages_plus-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 415ed02e8adaf0190a0a996111809a19b42456ce763a957dfed69a47d88f6977
MD5 1196c442ea6d0c8ece3844240f87fcb1
BLAKE2b-256 d95eece4f7935b83c2bb8831a7ed9d4676bc4bbc51dbb6731a9f4be8e6e5ee16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page