File: README.md

package info (click to toggle)
babelfish 0.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 416 kB
  • sloc: python: 707; makefile: 5; sh: 4
file content (77 lines) | stat: -rw-r--r-- 1,818 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# 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.