Convert MediaWiki language names and codes
Project description
MediaWiki langcodes
Convert MediaWiki language names and language codes.
Build dependencies
-
php
-
wget
Build
$ python -m venv .venv
$ source .venv/bin/activate.fish
$ python -m pip install -U pip build
$ make
Update extra language names
Extract language names from Lua modules in the Wiktionary dump file, use code from https://github.com/tatuylonen/wiktextract/blob/master/languages/get_data.py
$ python languages/get_data.py en --db-file ../en_20231220.db
$ python languages/get_data.py zh --db-file ../zh_20231220.db
then in this project folder:
// download files
$ make lang_files
// remove old extra files
$ rm build_script/extra_names/*.json
// create a db file without extra languages
$ python build_script/main.py
$ python build_script/add_extra.py en path_to_en_extra_json
// add extra languages from the English Wiktionary
$ python build_script/main.py
$ python build_script/add_extra.py zh path_to_zh_extra_json
Usage
from mediawiki_langcodes import code_to_name, name_to_code
code_to_name("fr") # return "français"
code_to_name("fr", "en") # return "French"
name_to_code("français") # return "fr"
name_to_code("français", "fr") # return "fr"
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
Close
Hashes for mediawiki_langcodes-0.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | be80365249b96c6385df0273a9c7810c82cb4a345e2517ab4285fbac0210cd11 |
|
MD5 | 3014be455f0752af0c46d8383ea6fbc7 |
|
BLAKE2b-256 | d8e731fd8b96059c94ae396c3ab7ad63b34579d4565d0ddd4db22d760cc2b1bd |
Close
Hashes for mediawiki_langcodes-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 677326c9b15214b790274a5d964b095b28c9e9849126acd7ba9708f5614bd191 |
|
MD5 | 13a1616a58a7a7fd57c6f621a99569c4 |
|
BLAKE2b-256 | fb7049bc5637aad1a2441d41292f7efd63b7e7408904a71e02cf11a3597f274b |