Skip to content

Commit

Permalink
Merge pull request #10 from LBeaudoux/immutable
Browse files Browse the repository at this point in the history
Merge before version 2.0.0 launch
  • Loading branch information
LBeaudoux authored Aug 27, 2021
2 parents bb25091 + fd142c4 commit af1550e
Show file tree
Hide file tree
Showing 16 changed files with 865 additions and 427 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ env_iso639/
build/
dist/
iso639_lang.egg-info/
.vscode
how_to_upload_to_PyPI.txt
.vscode/
*.ipynb
46 changes: 42 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Lang(name='French', pt1='fr', pt2b='fre', pt2t='fra', pt3='fra', pt5='')
iso639-lang allows you to switch from one language code to another easily.
There’s no need to manually download or parse data files, just use the `Lang` class!

ISO 639-1, ISO 639-2, ISO 639-3 and ISO 639-5 parts are all supported.
ISO 639-1, ISO 639-2, ISO 639-3 and ISO 639-5 parts are all supported.

## Installing iso639-lang and Supported Versions

Expand Down Expand Up @@ -52,8 +52,34 @@ Begin by importing the `Lang` class:
>>> lg.pt5
''
```
`Lang` instances are sortable by name and hashable.
```python
>>> langs = [Lang("deu"), Lang("eng"), Lang("rus"), Lang("eng")]
>>> [lg.name for lg in sorted(langs)]
['English', 'English', 'German', 'Russian']
>>> [lg.pt3 for lg in set(langs)]
['eng', 'rus', 'deu']
```

### Language Types

The type of a language is accessible thanks to the `type` method.
```python
>>> lg = Lang("Latin")
>>> lg.type()
'Ancient'
```

### Macrolanguages

You can easily determine whether a language is a macrolanguage or an individual language.
```python
>>> lg = Lang("Arabic")
>>> lg.scope()
'Macrolanguage'
```

You can easily get the macrolanguage of an individual language.
Use the `macro` method to get the macrolanguage of an individual language.
```python
>>> lg = Lang("Wu Chinese")
>>> lg.macro()
Expand All @@ -68,6 +94,8 @@ Conversely, you can also list all the individual languages that share a common m
Lang(name='Dari', pt1='', pt2b='', pt2t='', pt3='prs', pt5='')]
```

### Exceptions

When an invalid language value is passed to `Lang`, an `InvalidLanguageValue` exception is raised.
```python
>>> from iso639.exceptions import InvalidLanguageValue
Expand All @@ -91,9 +119,19 @@ When an deprecated language value is passed to `Lang`, a `DeprecatedLanguageValu
'Gascon replaced by Occitan (post 1500)'
```

## Data included in iso639-lang
### Other functions

`iter_langs()` iterates through all possible Lang instances, ordered alphabetically by name.

```python
>>> from iso639 import iter_langs
>>> [lg.name for lg in iter_langs()]
["'Are'are", "'Auhelawa", "A'ou", 'A-Pucikwar', 'Aari', ... , 'ǁGana', 'ǁXegwi', 'ǂHua', 'ǂUngkue', 'ǃXóõ']
```

## Sources of data used by iso639-lang

As of May 12, 2021, iso639-lang is based on the latest official code tables provided by the ISO 639 registration authorities.
As of August 17, 2021, iso639-lang is based on the latest official code tables provided by the ISO 639 registration authorities.


| Standard | Name | Registration Authority |
Expand Down
Loading

0 comments on commit af1550e

Please sign in to comment.