Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Diaoul/babelfish
BabelFish is a Python library to work with countries and languages
https://github.com/Diaoul/babelfish
Last synced: 11 days ago
JSON representation
BabelFish is a Python library to work with countries and languages
- Host: GitHub
- URL: https://github.com/Diaoul/babelfish
- Owner: Diaoul
- License: bsd-3-clause
- Created: 2013-09-27T21:46:45.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2024-07-09T19:23:32.000Z (4 months ago)
- Last Synced: 2024-10-14T20:34:30.662Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 239 KB
- Stars: 25
- Watchers: 5
- Forks: 14
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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```
### 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.