transliterate


Nametransliterate JSON
Version 1.10.2 PyPI version JSON
download
home_pagehttps://github.com/barseghyanartur/transliterate
SummaryBi-directional transliterator for Python
upload_time2018-09-17 20:52:37
maintainer
docs_urlNone
authorArtur Barseghyan
requires_python
licenseGPL 2.0/LGPL 2.1
keywords translit
VCS
bugtrack_url
requirements factory_boy fake-factory Pillow pytest pytest-cov tox
Travis-CI
coveralls test coverage
            =============
transliterate
=============
Bi-directional transliterator for Python. Transliterates (unicode) strings
according to the rules specified in the language packs (source script <->
target script).

Comes with language packs for the following languages (listed in alphabetical
order):

- Armenian
- Bulgarian (beta)
- Georgian
- Greek
- Macedonian (alpha)
- Mongolian (alpha)
- Russian
- Serbian (alpha)
- Ukrainian (beta)

There are also a number of useful tools included, such as:

- Simple lorem ipsum generator, which allows lorem ipsum generation in the
  language chosen.
- Language detection for the text (if appropriate language pack is available).
- Slugify function for non-latin texts.

Prerequisites
=============
- Python >=2.7, >=3.4, PyPy

Installation
============
Install with latest stable version from PyPI.

.. code-block:: sh

    pip install transliterate

or install the latest stable version from BitBucket:

.. code-block:: sh

    pip install https://bitbucket.org/barseghyanartur/transliterate/get/stable.tar.gz

or install the latest stable version from GitHub:

.. code-block:: sh

    pip install https://github.com/barseghyanartur/transliterate/archive/stable.tar.gz

That's all. See the `Usage and examples`_ section for more.

Usage and examples
==================
Simple usage
------------
Required imports

.. code-block:: python

    from transliterate import translit, get_available_language_codes

Original text

.. code-block:: python

    text = "Lorem ipsum dolor sit amet"

Transliteration to Armenian

.. code-block:: python

    print(translit(text, 'hy'))

    # Լօրեմ իպսում դօլօր սիտ ամետ

Transliteration to Georgian

.. code-block:: python

    print(translit(text, 'ka'))

    # ლორემ იპსუმ დოლორ სით ამეთ

Transliteration to Greek

.. code-block:: python

    print(translit(text, 'el'))

    # Λορεμ ιψθμ δολορ σιτ αμετ

Transliteration to Russian

.. code-block:: python

    print(translit(text, 'ru'))

    # Лорем ипсум долор сит амет

List of available (registered) languages

.. code-block:: python

    print(get_available_language_codes())

    # ['el', 'hy', 'ka', 'ru']

Reversed transliterations are transliterations made from target language to
source language (in terms they are defined in language packs). In case of
reversed transliterations, you may leave out the ``language_code`` attribute,
although if you know it on beforehand, specify it since it works faster that
way.

Reversed transliteration from Armenian

.. code-block:: python

    print(translit(u"Լօրեմ իպսում դօլօր սիտ ամետ", 'hy', reversed=True))

    # Lorem ipsum dolor sit amet

Reversed transliteration from Armenian with ``language_code`` argument left out

.. code-block:: python

    print(translit(u"Լօրեմ իպսում դօլօր սիտ ամետ", reversed=True))

    # Lorem ipsum dolor sit amet

Reversed transliteration from Georgian

.. code-block:: python

    print(translit(u"ლორემ იპსუმ დოლორ სით ამეთ", 'ka', reversed=True))

    # Lorem ipsum dolor sit amet

Reversed transliteration from Georgian with ``language_code`` argument left out

.. code-block:: python

    print(translit(u"ლორემ იპსუმ დოლორ სით ამეთ", reversed=True))

    # Lorem ipsum dolor sit amet

Reversed transliteration from Greek

.. code-block:: python

    print(translit(u"Λορεμ ιψθμ δολορ σιτ αμετ", 'el', reversed=True))

    # Lorem ipsum dolor sit amet

Reversed transliteration from Greek with ``language_code`` argument left out

.. code-block:: python

    print(translit(u"Λορεμ ιψθμ δολορ σιτ αμετ", reversed=True))

    # Lorem ipsum dolor sit amet

Reversed transliteration from Russian (Cyrillic)

.. code-block:: python

    print(translit(u"Лорем ипсум долор сит амет", 'ru', reversed=True))

    # Lorеm ipsum dolor sit amеt

Reversed transliteration from Russian (Cyrillic) with ``language_code``
argument left out

.. code-block:: python

    print(translit(u"Лорем ипсум долор сит амет", reversed=True))

    # Lorem ipsum dolor sit amet

Testing the decorator

.. code-block:: python

    from transliterate.decorators import transliterate_function

    @transliterate_function(language_code='hy')
    def decorator_test(text):
        return text

    print(decorator_test(u"Lorem ipsum dolor sit amet"))

    # Լօրեմ իպսում դօլօր սիտ ամետ

Working with large amounts of data
----------------------------------
If you know which language pack shall be used for transliteration, especially
when working with large amounts of data, it makes sense to get the
transliteration function in the following way:

.. code-block:: python

    from transliterate import get_translit_function

    translit_hy = get_translit_function('hy')

    print(translit_hy(u"Լօրեմ իպսում դօլօր սիտ ամետ", reversed=True))
    # Lorem ipsum dolor sit amet

    print(translit_hy(u"Lorem ipsum dolor sit amet"))
    # Լօրեմ իպսում դօլօր սիտ ամետ

Registering a custom language pack
----------------------------------
Basics
~~~~~~
Make sure to call the ``autodiscover`` function before registering your own
language packs if you want to use the bundled language packs along with your
own custom ones.

.. code-block:: python

    from transliterate.discover import autodiscover
    autodiscover()

Then the custom language pack part comes.

.. code-block:: python

    from transliterate.base import TranslitLanguagePack, registry

    class ExampleLanguagePack(TranslitLanguagePack):
        language_code = "example"
        language_name = "Example"
        mapping = (
            u"abcdefghij",
            u"1234567890",
        )

    registry.register(ExampleLanguagePack)

    print(get_available_language_codes())

    # ['el', 'hy', 'ka', 'ru', 'example']

    print(translit(text, 'example'))

    # Lor5m 9psum 4olor s9t 1m5t

It's possible to replace existing language packs with your own ones. By
default, existing language packs are not force-installed.

To force install a language pack, set the ``force`` argument to True when
registering a language pack. In that case, if a language pack with same
language code has already been registered, it will be replaced; otherwise,
if language pack didn't exist in the registry, it will be just registered.

.. code-block:: python

    registry.register(ExampleLanguagePack, force=True)

Forced language packs can't be replaced or unregistered.

API in depth
~~~~~~~~~~~~
There are 7 class properties that you could/should be using in your language
pack, of which 4 are various sorts of mappings.

Mappings
++++++++

- ``mapping`` (tuple): A tuple of two strings, that simply represent the 
  mapping of characters from the source language to the target language. For
  example, if your source language is Latin and you want to convert "a", "b",
  "c", "d" and "e" characters to appropriate characters in Russian Cyrillic,
  your mapping would look as follows:

  .. code-block:: python

        mapping = (u"abcde", u"абцде")

  Example (taken from the Greek language pack).

  .. code-block:: python
  
        mapping = (
            u"abgdezhiklmnxoprstyfwuABGDEZHIKLMNXOPRSTYFWU",
            u"αβγδεζηικλμνξοπρστυφωθΑΒΓΔΕΖΗΙΚΛΜΝΞΟΠΡΣΤΥΦΩΘ",
        )

- ``reversed_specific_mapping`` (tuple): When making reversed translations,
  the ``mapping`` property is still used, but in some cases you need to provide
  additional rules. This property (``reversed_specific_mapping``) is meant for
  such cases. Further, is alike the ``mapping``.

  Example (taken from the Greek language pack).

  .. code-block:: python

        reversed_specific_mapping = (
            u"θΘ",
            u"uU"
        )

- ``pre_processor_mapping`` (dict): A dictionary of mapping from source
  language to target language. Use this only in cases if a single character
  in source language shall be represented by more than one character in the
  target language.

  Example (taken from the Greek language pack).

  .. code-block:: python
  
        pre_processor_mapping = {
            u"th": u"θ",
            u"ch": u"χ",
            u"ps": u"ψ",
            u"TH": u"Θ",
            u"CH": u"Χ",
            u"PS": u"Ψ",
        }

- ``reversed_specific_pre_processor_mapping``: Same as
  ``pre_processor_mapping``, but used in reversed translations.

  Example (taken from the Armenian language pack)

  .. code-block:: python

        reversed_specific_pre_processor_mapping = {
            u"ու": u"u",
            u"Ու": u"U"
        }

Additional
++++++++++
- ``character_ranges`` (tuple): A tuple of character ranges (unicode table).
  Used in language detection. Works only if ``detectable`` property is set
  to True. Be aware, that language (or shall I better be saying - script) 
  detection is very basic and is based on characters only.

- ``detectable`` (bool): If set to True, language pack would be used
  for automatic language detection.

Using the lorem ipsum generator
-------------------------------
Note, that due to incompatibility of the original `lorem-ipsum-generator`
package with Python 3, when used with Python 3 `transliterate` uses its' own
simplified fallback lorem ipsum generator (which still does the job).

Required imports

.. code-block:: python

    from transliterate.contrib.apps.translipsum import TranslipsumGenerator

Generating paragraphs in Armenian

.. code-block:: python

    g_am = TranslipsumGenerator(language_code='hy')
    print(g_am.generate_paragraph())

    # Մագնա տրիստիքուե ֆաուցիբուս ֆամես նետուս նետուս օրցի մաուրիս,
    # սուսցիպիտ. Դապիբուս րիսուս սեդ ադիպիսցինգ դիցտում. Ֆերմենտում ուրնա
    # նատօքուե ատ. Uլտրիցես եգետ, տացիտի. Լիտօրա ցլասս ցօնուբիա պօսուերե
    # մալեսուադա ին իպսում իդ պեր վե.

Generating sentense in Georgian

.. code-block:: python

    g_ka = TranslipsumGenerator(language_code='ka')
    print(g_ka.generate_sentence())

    # გგეთ ყუამ არსუ ვულფუთათე რუთრუმ აუთორ.

Generating sentense in Greek

.. code-block:: python

    g_el = TranslipsumGenerator(language_code='el')
    print(g_el.generate_sentence())

    # Νεc cρασ αμετ, ελιτ vεστιβθλθμ εθ, αενεαν ναμ, τελλθσ vαριθσ.

Generating sentense in Russian (Cyrillic)

.. code-block:: python

    g_ru = TranslipsumGenerator(language_code='ru')
    print(g_ru.generate_sentence())

    # Рисус cонсеcтетуер, фусcе qуис лаореет ат ерос пэдэ фелис магна.

Language detection
------------------
Required imports

.. code-block:: python

    from transliterate import detect_language

Detect Armenian text

.. code-block:: python

    detect_language(u'Լօրեմ իպսում դօլօր սիտ ամետ')

    # hy

Detect Georgian text

.. code-block:: python

    detect_language(u'ლორემ იპსუმ დოლორ სით ამეთ')

    # ka

Detect Greek text

.. code-block:: python

    detect_language(u'Λορεμ ιψθμ δολορ σιτ αμετ')

    # el

Detect Russian (Cyrillic) text

.. code-block:: python

    detect_language(u'Лорем ипсум долор сит амет')

    # ru

Slugify
-------
Required imports

.. code-block:: python

    from transliterate import slugify

Slugify Armenian text

.. code-block:: python

    slugify(u'Լօրեմ իպսում դօլօր սիտ ամետ')

    # lorem-ipsum-dolor-sit-amet

Slugify Georgian text

.. code-block:: python

    slugify(u'ლორემ იპსუმ დოლორ სით ამეთ')

    # lorem-ipsum-dolor-sit-amet

Slugify Greek text

.. code-block:: python

    slugify(u'Λορεμ ιψθμ δολορ σιτ αμετ')

    # lorem-ipsum-dolor-sit-amet

Slugify Russian (Cyrillic) text

.. code-block:: python

    slugify(u'Лорем ипсум долор сит амет')

    # lorem-ipsum-dolor-sit-amet

Missing a language pack?
========================
Missing a language pack for your own language? Contribute to the project by
making one and it will appear in a new version (which will be released very
quickly).

Writing documentation
=====================

Keep the following hierarchy.

.. code-block:: text

    =====
    title
    =====

    header
    ======

    sub-header
    ----------

    sub-sub-header
    ~~~~~~~~~~~~~~

    sub-sub-sub-header
    ^^^^^^^^^^^^^^^^^^

    sub-sub-sub-sub-header
    ++++++++++++++++++++++

    sub-sub-sub-sub-sub-header
    **************************

License
=======
GPL 2.0/LGPL 2.1

Support
=======
For any issues contact me at the e-mail given in the `Author`_ section.

Author
======
Artur Barseghyan <artur.barseghyan@gmail.com>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/barseghyanartur/transliterate",
    "name": "transliterate",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "translit",
    "author": "Artur Barseghyan",
    "author_email": "artur.barseghyan@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/88/e3/84a89c289a5cf00c7aeabfb5a862a6e4cdc25819701cf1c454a18d32ac33/transliterate-1.10.2.tar.gz",
    "platform": "",
    "description": "=============\ntransliterate\n=============\nBi-directional transliterator for Python. Transliterates (unicode) strings\naccording to the rules specified in the language packs (source script <->\ntarget script).\n\nComes with language packs for the following languages (listed in alphabetical\norder):\n\n- Armenian\n- Bulgarian (beta)\n- Georgian\n- Greek\n- Macedonian (alpha)\n- Mongolian (alpha)\n- Russian\n- Serbian (alpha)\n- Ukrainian (beta)\n\nThere are also a number of useful tools included, such as:\n\n- Simple lorem ipsum generator, which allows lorem ipsum generation in the\n  language chosen.\n- Language detection for the text (if appropriate language pack is available).\n- Slugify function for non-latin texts.\n\nPrerequisites\n=============\n- Python >=2.7, >=3.4, PyPy\n\nInstallation\n============\nInstall with latest stable version from PyPI.\n\n.. code-block:: sh\n\n    pip install transliterate\n\nor install the latest stable version from BitBucket:\n\n.. code-block:: sh\n\n    pip install https://bitbucket.org/barseghyanartur/transliterate/get/stable.tar.gz\n\nor install the latest stable version from GitHub:\n\n.. code-block:: sh\n\n    pip install https://github.com/barseghyanartur/transliterate/archive/stable.tar.gz\n\nThat's all. See the `Usage and examples`_ section for more.\n\nUsage and examples\n==================\nSimple usage\n------------\nRequired imports\n\n.. code-block:: python\n\n    from transliterate import translit, get_available_language_codes\n\nOriginal text\n\n.. code-block:: python\n\n    text = \"Lorem ipsum dolor sit amet\"\n\nTransliteration to Armenian\n\n.. code-block:: python\n\n    print(translit(text, 'hy'))\n\n    # \u053c\u0585\u0580\u0565\u0574 \u056b\u057a\u057d\u0578\u0582\u0574 \u0564\u0585\u056c\u0585\u0580 \u057d\u056b\u057f \u0561\u0574\u0565\u057f\n\nTransliteration to Georgian\n\n.. code-block:: python\n\n    print(translit(text, 'ka'))\n\n    # \u10da\u10dd\u10e0\u10d4\u10db \u10d8\u10de\u10e1\u10e3\u10db \u10d3\u10dd\u10da\u10dd\u10e0 \u10e1\u10d8\u10d7 \u10d0\u10db\u10d4\u10d7\n\nTransliteration to Greek\n\n.. code-block:: python\n\n    print(translit(text, 'el'))\n\n    # \u039b\u03bf\u03c1\u03b5\u03bc \u03b9\u03c8\u03b8\u03bc \u03b4\u03bf\u03bb\u03bf\u03c1 \u03c3\u03b9\u03c4 \u03b1\u03bc\u03b5\u03c4\n\nTransliteration to Russian\n\n.. code-block:: python\n\n    print(translit(text, 'ru'))\n\n    # \u041b\u043e\u0440\u0435\u043c \u0438\u043f\u0441\u0443\u043c \u0434\u043e\u043b\u043e\u0440 \u0441\u0438\u0442 \u0430\u043c\u0435\u0442\n\nList of available (registered) languages\n\n.. code-block:: python\n\n    print(get_available_language_codes())\n\n    # ['el', 'hy', 'ka', 'ru']\n\nReversed transliterations are transliterations made from target language to\nsource language (in terms they are defined in language packs). In case of\nreversed transliterations, you may leave out the ``language_code`` attribute,\nalthough if you know it on beforehand, specify it since it works faster that\nway.\n\nReversed transliteration from Armenian\n\n.. code-block:: python\n\n    print(translit(u\"\u053c\u0585\u0580\u0565\u0574 \u056b\u057a\u057d\u0578\u0582\u0574 \u0564\u0585\u056c\u0585\u0580 \u057d\u056b\u057f \u0561\u0574\u0565\u057f\", 'hy', reversed=True))\n\n    # Lorem ipsum dolor sit amet\n\nReversed transliteration from Armenian with ``language_code`` argument left out\n\n.. code-block:: python\n\n    print(translit(u\"\u053c\u0585\u0580\u0565\u0574 \u056b\u057a\u057d\u0578\u0582\u0574 \u0564\u0585\u056c\u0585\u0580 \u057d\u056b\u057f \u0561\u0574\u0565\u057f\", reversed=True))\n\n    # Lorem ipsum dolor sit amet\n\nReversed transliteration from Georgian\n\n.. code-block:: python\n\n    print(translit(u\"\u10da\u10dd\u10e0\u10d4\u10db \u10d8\u10de\u10e1\u10e3\u10db \u10d3\u10dd\u10da\u10dd\u10e0 \u10e1\u10d8\u10d7 \u10d0\u10db\u10d4\u10d7\", 'ka', reversed=True))\n\n    # Lorem ipsum dolor sit amet\n\nReversed transliteration from Georgian with ``language_code`` argument left out\n\n.. code-block:: python\n\n    print(translit(u\"\u10da\u10dd\u10e0\u10d4\u10db \u10d8\u10de\u10e1\u10e3\u10db \u10d3\u10dd\u10da\u10dd\u10e0 \u10e1\u10d8\u10d7 \u10d0\u10db\u10d4\u10d7\", reversed=True))\n\n    # Lorem ipsum dolor sit amet\n\nReversed transliteration from Greek\n\n.. code-block:: python\n\n    print(translit(u\"\u039b\u03bf\u03c1\u03b5\u03bc \u03b9\u03c8\u03b8\u03bc \u03b4\u03bf\u03bb\u03bf\u03c1 \u03c3\u03b9\u03c4 \u03b1\u03bc\u03b5\u03c4\", 'el', reversed=True))\n\n    # Lorem ipsum dolor sit amet\n\nReversed transliteration from Greek with ``language_code`` argument left out\n\n.. code-block:: python\n\n    print(translit(u\"\u039b\u03bf\u03c1\u03b5\u03bc \u03b9\u03c8\u03b8\u03bc \u03b4\u03bf\u03bb\u03bf\u03c1 \u03c3\u03b9\u03c4 \u03b1\u03bc\u03b5\u03c4\", reversed=True))\n\n    # Lorem ipsum dolor sit amet\n\nReversed transliteration from Russian (Cyrillic)\n\n.. code-block:: python\n\n    print(translit(u\"\u041b\u043e\u0440\u0435\u043c \u0438\u043f\u0441\u0443\u043c \u0434\u043e\u043b\u043e\u0440 \u0441\u0438\u0442 \u0430\u043c\u0435\u0442\", 'ru', reversed=True))\n\n    # Lor\u0435m ipsum dolor sit am\u0435t\n\nReversed transliteration from Russian (Cyrillic) with ``language_code``\nargument left out\n\n.. code-block:: python\n\n    print(translit(u\"\u041b\u043e\u0440\u0435\u043c \u0438\u043f\u0441\u0443\u043c \u0434\u043e\u043b\u043e\u0440 \u0441\u0438\u0442 \u0430\u043c\u0435\u0442\", reversed=True))\n\n    # Lorem ipsum dolor sit amet\n\nTesting the decorator\n\n.. code-block:: python\n\n    from transliterate.decorators import transliterate_function\n\n    @transliterate_function(language_code='hy')\n    def decorator_test(text):\n        return text\n\n    print(decorator_test(u\"Lorem ipsum dolor sit amet\"))\n\n    # \u053c\u0585\u0580\u0565\u0574 \u056b\u057a\u057d\u0578\u0582\u0574 \u0564\u0585\u056c\u0585\u0580 \u057d\u056b\u057f \u0561\u0574\u0565\u057f\n\nWorking with large amounts of data\n----------------------------------\nIf you know which language pack shall be used for transliteration, especially\nwhen working with large amounts of data, it makes sense to get the\ntransliteration function in the following way:\n\n.. code-block:: python\n\n    from transliterate import get_translit_function\n\n    translit_hy = get_translit_function('hy')\n\n    print(translit_hy(u\"\u053c\u0585\u0580\u0565\u0574 \u056b\u057a\u057d\u0578\u0582\u0574 \u0564\u0585\u056c\u0585\u0580 \u057d\u056b\u057f \u0561\u0574\u0565\u057f\", reversed=True))\n    # Lorem ipsum dolor sit amet\n\n    print(translit_hy(u\"Lorem ipsum dolor sit amet\"))\n    # \u053c\u0585\u0580\u0565\u0574 \u056b\u057a\u057d\u0578\u0582\u0574 \u0564\u0585\u056c\u0585\u0580 \u057d\u056b\u057f \u0561\u0574\u0565\u057f\n\nRegistering a custom language pack\n----------------------------------\nBasics\n~~~~~~\nMake sure to call the ``autodiscover`` function before registering your own\nlanguage packs if you want to use the bundled language packs along with your\nown custom ones.\n\n.. code-block:: python\n\n    from transliterate.discover import autodiscover\n    autodiscover()\n\nThen the custom language pack part comes.\n\n.. code-block:: python\n\n    from transliterate.base import TranslitLanguagePack, registry\n\n    class ExampleLanguagePack(TranslitLanguagePack):\n        language_code = \"example\"\n        language_name = \"Example\"\n        mapping = (\n            u\"abcdefghij\",\n            u\"1234567890\",\n        )\n\n    registry.register(ExampleLanguagePack)\n\n    print(get_available_language_codes())\n\n    # ['el', 'hy', 'ka', 'ru', 'example']\n\n    print(translit(text, 'example'))\n\n    # Lor5m 9psum 4olor s9t 1m5t\n\nIt's possible to replace existing language packs with your own ones. By\ndefault, existing language packs are not force-installed.\n\nTo force install a language pack, set the ``force`` argument to True when\nregistering a language pack. In that case, if a language pack with same\nlanguage code has already been registered, it will be replaced; otherwise,\nif language pack didn't exist in the registry, it will be just registered.\n\n.. code-block:: python\n\n    registry.register(ExampleLanguagePack, force=True)\n\nForced language packs can't be replaced or unregistered.\n\nAPI in depth\n~~~~~~~~~~~~\nThere are 7 class properties that you could/should be using in your language\npack, of which 4 are various sorts of mappings.\n\nMappings\n++++++++\n\n- ``mapping`` (tuple): A tuple of two strings, that simply represent the \n  mapping of characters from the source language to the target language. For\n  example, if your source language is Latin and you want to convert \"a\", \"b\",\n  \"c\", \"d\" and \"e\" characters to appropriate characters in Russian Cyrillic,\n  your mapping would look as follows:\n\n  .. code-block:: python\n\n        mapping = (u\"abcde\", u\"\u0430\u0431\u0446\u0434\u0435\")\n\n  Example (taken from the Greek language pack).\n\n  .. code-block:: python\n  \n        mapping = (\n            u\"abgdezhiklmnxoprstyfwuABGDEZHIKLMNXOPRSTYFWU\",\n            u\"\u03b1\u03b2\u03b3\u03b4\u03b5\u03b6\u03b7\u03b9\u03ba\u03bb\u03bc\u03bd\u03be\u03bf\u03c0\u03c1\u03c3\u03c4\u03c5\u03c6\u03c9\u03b8\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0399\u039a\u039b\u039c\u039d\u039e\u039f\u03a0\u03a1\u03a3\u03a4\u03a5\u03a6\u03a9\u0398\",\n        )\n\n- ``reversed_specific_mapping`` (tuple): When making reversed translations,\n  the ``mapping`` property is still used, but in some cases you need to provide\n  additional rules. This property (``reversed_specific_mapping``) is meant for\n  such cases. Further, is alike the ``mapping``.\n\n  Example (taken from the Greek language pack).\n\n  .. code-block:: python\n\n        reversed_specific_mapping = (\n            u\"\u03b8\u0398\",\n            u\"uU\"\n        )\n\n- ``pre_processor_mapping`` (dict): A dictionary of mapping from source\n  language to target language. Use this only in cases if a single character\n  in source language shall be represented by more than one character in the\n  target language.\n\n  Example (taken from the Greek language pack).\n\n  .. code-block:: python\n  \n        pre_processor_mapping = {\n            u\"th\": u\"\u03b8\",\n            u\"ch\": u\"\u03c7\",\n            u\"ps\": u\"\u03c8\",\n            u\"TH\": u\"\u0398\",\n            u\"CH\": u\"\u03a7\",\n            u\"PS\": u\"\u03a8\",\n        }\n\n- ``reversed_specific_pre_processor_mapping``: Same as\n  ``pre_processor_mapping``, but used in reversed translations.\n\n  Example (taken from the Armenian language pack)\n\n  .. code-block:: python\n\n        reversed_specific_pre_processor_mapping = {\n            u\"\u0578\u0582\": u\"u\",\n            u\"\u0548\u0582\": u\"U\"\n        }\n\nAdditional\n++++++++++\n- ``character_ranges`` (tuple): A tuple of character ranges (unicode table).\n  Used in language detection. Works only if ``detectable`` property is set\n  to True. Be aware, that language (or shall I better be saying - script) \n  detection is very basic and is based on characters only.\n\n- ``detectable`` (bool): If set to True, language pack would be used\n  for automatic language detection.\n\nUsing the lorem ipsum generator\n-------------------------------\nNote, that due to incompatibility of the original `lorem-ipsum-generator`\npackage with Python 3, when used with Python 3 `transliterate` uses its' own\nsimplified fallback lorem ipsum generator (which still does the job).\n\nRequired imports\n\n.. code-block:: python\n\n    from transliterate.contrib.apps.translipsum import TranslipsumGenerator\n\nGenerating paragraphs in Armenian\n\n.. code-block:: python\n\n    g_am = TranslipsumGenerator(language_code='hy')\n    print(g_am.generate_paragraph())\n\n    # \u0544\u0561\u0563\u0576\u0561 \u057f\u0580\u056b\u057d\u057f\u056b\u0584\u0578\u0582\u0565 \u0586\u0561\u0578\u0582\u0581\u056b\u0562\u0578\u0582\u057d \u0586\u0561\u0574\u0565\u057d \u0576\u0565\u057f\u0578\u0582\u057d \u0576\u0565\u057f\u0578\u0582\u057d \u0585\u0580\u0581\u056b \u0574\u0561\u0578\u0582\u0580\u056b\u057d,\n    # \u057d\u0578\u0582\u057d\u0581\u056b\u057a\u056b\u057f. \u0534\u0561\u057a\u056b\u0562\u0578\u0582\u057d \u0580\u056b\u057d\u0578\u0582\u057d \u057d\u0565\u0564 \u0561\u0564\u056b\u057a\u056b\u057d\u0581\u056b\u0576\u0563 \u0564\u056b\u0581\u057f\u0578\u0582\u0574. \u0556\u0565\u0580\u0574\u0565\u0576\u057f\u0578\u0582\u0574 \u0578\u0582\u0580\u0576\u0561\n    # \u0576\u0561\u057f\u0585\u0584\u0578\u0582\u0565 \u0561\u057f. U\u056c\u057f\u0580\u056b\u0581\u0565\u057d \u0565\u0563\u0565\u057f, \u057f\u0561\u0581\u056b\u057f\u056b. \u053c\u056b\u057f\u0585\u0580\u0561 \u0581\u056c\u0561\u057d\u057d \u0581\u0585\u0576\u0578\u0582\u0562\u056b\u0561 \u057a\u0585\u057d\u0578\u0582\u0565\u0580\u0565\n    # \u0574\u0561\u056c\u0565\u057d\u0578\u0582\u0561\u0564\u0561 \u056b\u0576 \u056b\u057a\u057d\u0578\u0582\u0574 \u056b\u0564 \u057a\u0565\u0580 \u057e\u0565.\n\nGenerating sentense in Georgian\n\n.. code-block:: python\n\n    g_ka = TranslipsumGenerator(language_code='ka')\n    print(g_ka.generate_sentence())\n\n    # \u10d2\u10d2\u10d4\u10d7 \u10e7\u10e3\u10d0\u10db \u10d0\u10e0\u10e1\u10e3 \u10d5\u10e3\u10da\u10e4\u10e3\u10d7\u10d0\u10d7\u10d4 \u10e0\u10e3\u10d7\u10e0\u10e3\u10db \u10d0\u10e3\u10d7\u10dd\u10e0.\n\nGenerating sentense in Greek\n\n.. code-block:: python\n\n    g_el = TranslipsumGenerator(language_code='el')\n    print(g_el.generate_sentence())\n\n    # \u039d\u03b5c c\u03c1\u03b1\u03c3 \u03b1\u03bc\u03b5\u03c4, \u03b5\u03bb\u03b9\u03c4 v\u03b5\u03c3\u03c4\u03b9\u03b2\u03b8\u03bb\u03b8\u03bc \u03b5\u03b8, \u03b1\u03b5\u03bd\u03b5\u03b1\u03bd \u03bd\u03b1\u03bc, \u03c4\u03b5\u03bb\u03bb\u03b8\u03c3 v\u03b1\u03c1\u03b9\u03b8\u03c3.\n\nGenerating sentense in Russian (Cyrillic)\n\n.. code-block:: python\n\n    g_ru = TranslipsumGenerator(language_code='ru')\n    print(g_ru.generate_sentence())\n\n    # \u0420\u0438\u0441\u0443\u0441 c\u043e\u043d\u0441\u0435c\u0442\u0435\u0442\u0443\u0435\u0440, \u0444\u0443\u0441c\u0435 q\u0443\u0438\u0441 \u043b\u0430\u043e\u0440\u0435\u0435\u0442 \u0430\u0442 \u0435\u0440\u043e\u0441 \u043f\u044d\u0434\u044d \u0444\u0435\u043b\u0438\u0441 \u043c\u0430\u0433\u043d\u0430.\n\nLanguage detection\n------------------\nRequired imports\n\n.. code-block:: python\n\n    from transliterate import detect_language\n\nDetect Armenian text\n\n.. code-block:: python\n\n    detect_language(u'\u053c\u0585\u0580\u0565\u0574 \u056b\u057a\u057d\u0578\u0582\u0574 \u0564\u0585\u056c\u0585\u0580 \u057d\u056b\u057f \u0561\u0574\u0565\u057f')\n\n    # hy\n\nDetect Georgian text\n\n.. code-block:: python\n\n    detect_language(u'\u10da\u10dd\u10e0\u10d4\u10db \u10d8\u10de\u10e1\u10e3\u10db \u10d3\u10dd\u10da\u10dd\u10e0 \u10e1\u10d8\u10d7 \u10d0\u10db\u10d4\u10d7')\n\n    # ka\n\nDetect Greek text\n\n.. code-block:: python\n\n    detect_language(u'\u039b\u03bf\u03c1\u03b5\u03bc \u03b9\u03c8\u03b8\u03bc \u03b4\u03bf\u03bb\u03bf\u03c1 \u03c3\u03b9\u03c4 \u03b1\u03bc\u03b5\u03c4')\n\n    # el\n\nDetect Russian (Cyrillic) text\n\n.. code-block:: python\n\n    detect_language(u'\u041b\u043e\u0440\u0435\u043c \u0438\u043f\u0441\u0443\u043c \u0434\u043e\u043b\u043e\u0440 \u0441\u0438\u0442 \u0430\u043c\u0435\u0442')\n\n    # ru\n\nSlugify\n-------\nRequired imports\n\n.. code-block:: python\n\n    from transliterate import slugify\n\nSlugify Armenian text\n\n.. code-block:: python\n\n    slugify(u'\u053c\u0585\u0580\u0565\u0574 \u056b\u057a\u057d\u0578\u0582\u0574 \u0564\u0585\u056c\u0585\u0580 \u057d\u056b\u057f \u0561\u0574\u0565\u057f')\n\n    # lorem-ipsum-dolor-sit-amet\n\nSlugify Georgian text\n\n.. code-block:: python\n\n    slugify(u'\u10da\u10dd\u10e0\u10d4\u10db \u10d8\u10de\u10e1\u10e3\u10db \u10d3\u10dd\u10da\u10dd\u10e0 \u10e1\u10d8\u10d7 \u10d0\u10db\u10d4\u10d7')\n\n    # lorem-ipsum-dolor-sit-amet\n\nSlugify Greek text\n\n.. code-block:: python\n\n    slugify(u'\u039b\u03bf\u03c1\u03b5\u03bc \u03b9\u03c8\u03b8\u03bc \u03b4\u03bf\u03bb\u03bf\u03c1 \u03c3\u03b9\u03c4 \u03b1\u03bc\u03b5\u03c4')\n\n    # lorem-ipsum-dolor-sit-amet\n\nSlugify Russian (Cyrillic) text\n\n.. code-block:: python\n\n    slugify(u'\u041b\u043e\u0440\u0435\u043c \u0438\u043f\u0441\u0443\u043c \u0434\u043e\u043b\u043e\u0440 \u0441\u0438\u0442 \u0430\u043c\u0435\u0442')\n\n    # lorem-ipsum-dolor-sit-amet\n\nMissing a language pack?\n========================\nMissing a language pack for your own language? Contribute to the project by\nmaking one and it will appear in a new version (which will be released very\nquickly).\n\nWriting documentation\n=====================\n\nKeep the following hierarchy.\n\n.. code-block:: text\n\n    =====\n    title\n    =====\n\n    header\n    ======\n\n    sub-header\n    ----------\n\n    sub-sub-header\n    ~~~~~~~~~~~~~~\n\n    sub-sub-sub-header\n    ^^^^^^^^^^^^^^^^^^\n\n    sub-sub-sub-sub-header\n    ++++++++++++++++++++++\n\n    sub-sub-sub-sub-sub-header\n    **************************\n\nLicense\n=======\nGPL 2.0/LGPL 2.1\n\nSupport\n=======\nFor any issues contact me at the e-mail given in the `Author`_ section.\n\nAuthor\n======\nArtur Barseghyan <artur.barseghyan@gmail.com>\n",
    "bugtrack_url": null,
    "license": "GPL 2.0/LGPL 2.1",
    "summary": "Bi-directional transliterator for Python",
    "version": "1.10.2",
    "project_urls": {
        "Homepage": "https://github.com/barseghyanartur/transliterate"
    },
    "split_keywords": [
        "translit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a16e9a9d597dbdd6d0172427c8cc07c35736471e631060df9e59eeb87687f817",
                "md5": "f6641b6024c639da4e2a1907ebf99c04",
                "sha256": "010a5021bf6021689c4fade0985f3f7b3db1f2f16a48a09a56797f171c08ed42"
            },
            "downloads": -1,
            "filename": "transliterate-1.10.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f6641b6024c639da4e2a1907ebf99c04",
            "packagetype": "bdist_wheel",
            "python_version": "3.6",
            "requires_python": null,
            "size": 45780,
            "upload_time": "2018-09-17T20:52:40",
            "upload_time_iso_8601": "2018-09-17T20:52:40.332011Z",
            "url": "https://files.pythonhosted.org/packages/a1/6e/9a9d597dbdd6d0172427c8cc07c35736471e631060df9e59eeb87687f817/transliterate-1.10.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "88e384a89c289a5cf00c7aeabfb5a862a6e4cdc25819701cf1c454a18d32ac33",
                "md5": "4a552ae70039a66e9a732832b8a96cb2",
                "sha256": "bc608e0d48e687db9c2b1d7ea7c381afe0d1849cad216087d8e03d8d06a57c85"
            },
            "downloads": -1,
            "filename": "transliterate-1.10.2.tar.gz",
            "has_sig": false,
            "md5_digest": "4a552ae70039a66e9a732832b8a96cb2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 43088,
            "upload_time": "2018-09-17T20:52:37",
            "upload_time_iso_8601": "2018-09-17T20:52:37.984479Z",
            "url": "https://files.pythonhosted.org/packages/88/e3/84a89c289a5cf00c7aeabfb5a862a6e4cdc25819701cf1c454a18d32ac33/transliterate-1.10.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2018-09-17 20:52:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "barseghyanartur",
    "github_project": "transliterate",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": false,
    "requirements": [
        {
            "name": "factory_boy",
            "specs": [
                [
                    "==",
                    "2.7.0"
                ]
            ]
        },
        {
            "name": "fake-factory",
            "specs": [
                [
                    "==",
                    "0.7.2"
                ]
            ]
        },
        {
            "name": "Pillow",
            "specs": [
                [
                    "==",
                    "3.4.2"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "3.0.2"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "==",
                    "2.2.1"
                ]
            ]
        },
        {
            "name": "tox",
            "specs": [
                [
                    "==",
                    "2.1.1"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "transliterate"
}
        
Elapsed time: 0.10254s