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.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 948e9e1a9046a3e65a483c7da2d8c8517e35587a6da6845653b940f0414b884f |
|
MD5 | 904a8dc1a04c7c8a09c7ceb0f3f4dfbd |
|
BLAKE2b-256 | ea5169bcd88e4cd3049e529933c03e99a3cd3ac0d10af28b6d2a0552dde80faa |
Close
Hashes for mediawiki_langcodes-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73518860691a2c5d032796cd766f070079e03524371919bb66445a2020b7ac51 |
|
MD5 | 8261fd379f20d4977086cd0b06b9ae86 |
|
BLAKE2b-256 | 3da0d7c2ac8af60bcf68717780e65c18973a7742f95da0a92ea79f811637fb02 |