Code Monkey home page Code Monkey logo

python-bcp47-l10n's Introduction

Build Status codecov

python-bcp47-l10n

Localised names for bcp47 language codes

Python examples

You can localise language names using their bcp47 codes. If no locale is provided, the default (ie en) bcp47 names are used.

>>> import bcp47l10n

>>> bcp47l10n.gettext("en")
'English'
>>> bcp47l10n.gettext("en", locale="fr")
'anglais'
>>> bcp47l10n.gettext("en", locale="es")
'Inglés'
>>> bcp47l10n.gettext("en", locale="zh-CN")
'英语'

>>> bcp47l10n.gettext("en-GB")
'English (United Kingdom)'
>>> bcp47l10n.gettext("en-GB", locale="fr")
'anglais (Royaume-Uni)'
>>> bcp47l10n.gettext("en-GB", locale="es")
'Inglés (Reino Unido)'
>>> bcp47l10n.gettext("en-GB", locale="zh-CN")
'英语 (英国)'


>>> bcp47l10n.gettext("ca-valencia")
'Catalan (Valencian)'
>>> bcp47l10n.gettext("ca-valencia", locale="fr")
'catalan (Valencian)'
>>> bcp47l10n.gettext("ca-valencia", locale="es")
'Catalán (Valencian)'
>>> bcp47l10n.gettext("ca-valencia", locale="zh-CN")
'加泰罗尼亚语 (Valencian)'

If the locale is not recognised you get the default english name for the language code

>>> bcp47l10n.gettext("en-GB", locale="NOTALOCALE")
'English (United Kingdom)'

If the language code is not recognized (ie not valid BCP47) the original string is returned

>>> bcp47l10n.gettext("en-NOTAREGION", locale="zh-CN")
'en-NOTAREGION'

python-bcp47-l10n's People

Contributors

phlax avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.