| Conditions | 2 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | from ._utils import export |
||
| 28 | @export |
||
| 29 | def to_language(locale): |
||
| 30 | """ |
||
| 31 | Turn a locale name (en_US) into a language name (en-us). |
||
| 32 | |||
| 33 | Extracted `from Django <https://github.com/django/django/blob/e74b3d724e5ddfef96d1d66bd1c58e7aae26fc85/django/utils/translation/__init__.py#L265-L271>`_. |
||
| 34 | |||
| 35 | """ |
||
| 36 | p = locale.find("_") |
||
| 37 | if p >= 0: |
||
| 38 | return locale[:p].lower() + "-" + locale[p + 1:].lower() |
||
| 39 | else: |
||
| 40 | return locale.lower() |
||
| 41 |