# BabelFish
BabelFish is a Python library to work with countries and languages.
[![tests](https://github.com/Diaoul/babelfish/actions/workflows/test.yml/badge.svg)](https://github.com/Diaoul/babelfish/actions/workflows/test.yml)
## Usage
BabelFish provides scripts, countries and languages from their respective ISO
standards and a handy way to manipulate them with converters.
### Script
Script representation from 4-letter code (ISO-15924):
```python
>>> import babelfish
>>> script = babelfish.Script('Hira')
>>> script
<Script [Hira]>
```
### Country
Country representation from 2-letter code (ISO-3166):
```python
>>> country = babelfish.Country('GB')
>>> country
<Country [GB]>
```
Built-in country converters (name):
```python
>>> country = babelfish.Country.fromname('United Kingdom')
>>> country
<Country [GB]>
```
### Language
Language representation from 3-letter code (ISO-639-3):
```python
>>> language = babelfish.Language("eng")
>>> language
<Language [en]>
```
Country-specific language:
```python
>>> language = babelfish.Language('por', 'BR')
>>> language
<Language [pt-BR]>
```
Language with specific script:
```python
>>> language = babelfish.Language.fromalpha2('sr')
>>> language.script = babelfish.Script('Cyrl')
>>> language
<Language [sr-Cyrl]>
```
Built-in language converters (alpha2, alpha3b, alpha3t, name, scope, type and opensubtitles):
```python
>>> language = babelfish.Language('por', 'BR')
>>> language.alpha2
'pt'
>>> language.name
'Portuguese'
>>> language.scope
'individual'
>>> language.type
'living'
>>> language.opensubtitles
'pob'
>>> babelfish.Language.fromalpha3b('fre')
<Language [fr]>
```
## License
BabelFish is licensed under the [3-clause BSD license](http://opensource.org/licenses/BSD-3-Clause>)
Copyright (c) 2013, the BabelFish authors and contributors.
Raw data
{
"_id": null,
"home_page": "https://github.com/Diaoul/babelfish",
"name": "babelfish",
"maintainer": null,
"docs_url": "https://pythonhosted.org/babelfish/",
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "language, country, locale",
"author": "Antoine Bertin",
"author_email": "ant.bertin@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/c5/8f/17ff889327f8a1c36a28418e686727dabc06c080ed49c95e3e2424a77aa6/babelfish-0.6.1.tar.gz",
"platform": null,
"description": "# BabelFish\nBabelFish is a Python library to work with countries and languages.\n\n[![tests](https://github.com/Diaoul/babelfish/actions/workflows/test.yml/badge.svg)](https://github.com/Diaoul/babelfish/actions/workflows/test.yml)\n\n## Usage\nBabelFish provides scripts, countries and languages from their respective ISO\nstandards and a handy way to manipulate them with converters.\n\n### Script\nScript representation from 4-letter code (ISO-15924):\n```python\n>>> import babelfish\n>>> script = babelfish.Script('Hira')\n>>> script\n<Script [Hira]>\n```\n\n### Country\nCountry representation from 2-letter code (ISO-3166):\n```python\n>>> country = babelfish.Country('GB')\n>>> country\n<Country [GB]>\n```\n\nBuilt-in country converters (name):\n```python\n>>> country = babelfish.Country.fromname('United Kingdom')\n>>> country\n<Country [GB]>\n```\n\n### Language\nLanguage representation from 3-letter code (ISO-639-3):\n```python\n>>> language = babelfish.Language(\"eng\")\n>>> language\n<Language [en]>\n```\n\nCountry-specific language:\n```python\n>>> language = babelfish.Language('por', 'BR')\n>>> language\n<Language [pt-BR]>\n```\n\nLanguage with specific script:\n```python\n>>> language = babelfish.Language.fromalpha2('sr')\n>>> language.script = babelfish.Script('Cyrl')\n>>> language\n<Language [sr-Cyrl]>\n```\n\nBuilt-in language converters (alpha2, alpha3b, alpha3t, name, scope, type and opensubtitles):\n```python\n>>> language = babelfish.Language('por', 'BR')\n>>> language.alpha2\n'pt'\n>>> language.name\n'Portuguese'\n>>> language.scope\n'individual'\n>>> language.type\n'living'\n>>> language.opensubtitles\n'pob'\n>>> babelfish.Language.fromalpha3b('fre')\n<Language [fr]>\n```\n\n## License\nBabelFish is licensed under the [3-clause BSD license](http://opensource.org/licenses/BSD-3-Clause>)\n\nCopyright (c) 2013, the BabelFish authors and contributors.\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "A module to work with countries and languages",
"version": "0.6.1",
"project_urls": {
"Homepage": "https://github.com/Diaoul/babelfish",
"Repository": "https://github.com/Diaoul/babelfish"
},
"split_keywords": [
"language",
" country",
" locale"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "95a1bd4f759db13cd8beb9c9f68682aced5d966781b9d7380cf514a306f56762",
"md5": "b82dbf7639910d3908b6d717d71dfd1c",
"sha256": "512f1501d4c8f7d38f0921f48660be7542de1a7b24abb6a6a65324a670150293"
},
"downloads": -1,
"filename": "babelfish-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b82dbf7639910d3908b6d717d71dfd1c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 94231,
"upload_time": "2024-05-09T21:16:22",
"upload_time_iso_8601": "2024-05-09T21:16:22.633604Z",
"url": "https://files.pythonhosted.org/packages/95/a1/bd4f759db13cd8beb9c9f68682aced5d966781b9d7380cf514a306f56762/babelfish-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c58f17ff889327f8a1c36a28418e686727dabc06c080ed49c95e3e2424a77aa6",
"md5": "a3ef27e5b12c795d48aa6fa4005d2826",
"sha256": "decb67a4660888d48480ab6998309837174158d0f1aa63bebb1c2e11aab97aab"
},
"downloads": -1,
"filename": "babelfish-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "a3ef27e5b12c795d48aa6fa4005d2826",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 87706,
"upload_time": "2024-05-09T21:16:24",
"upload_time_iso_8601": "2024-05-09T21:16:24.357941Z",
"url": "https://files.pythonhosted.org/packages/c5/8f/17ff889327f8a1c36a28418e686727dabc06c080ed49c95e3e2424a77aa6/babelfish-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-09 21:16:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Diaoul",
"github_project": "babelfish",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "babelfish"
}