A django model & fixture containing common languages and culture codes
Project description
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
Add languages_plus to your INSTALLED_APPS
Migrate your database and load the language data fixture:
python manage.py migrate python manage.py loaddata languages_data.json.gz
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 latest versions of 3, and 4. 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_languages_plus-2.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 874a268e6988bd8e4ff7c38aad5e70632e97eb431e4c226f637ea3aae563b910 |
|
MD5 | e43b9a1c4a90ff2e452f217e1059e02d |
|
BLAKE2b-256 | 464a3eaa70206b1b7a925ffca650cc6ac21ef098b6c785869fe57430210ba99b |
Hashes for django_languages_plus-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e7956df58c52ef39b7210612db4679386f560735df1ac7135f1731d21c43a07 |
|
MD5 | 73cc84d6163a9ba1e5a8761a3f186fa9 |
|
BLAKE2b-256 | f584ad1fd8e7dcb334e8d860045fa6f42af98237be20d94f21a3d96abd97d42b |