# transliterate package

## Subpackages

- transliterate.contrib package
  - Subpackages
    - transliterate.contrib.apps package
      - Subpackages
        - transliterate.contrib.apps.translipsum package
          - Submodules
          - transliterate.contrib.apps.translipsum.utils module
            - `Generator`
              - `Generator.generate_paragraph()`
              - `Generator.generate_sentence()`
              - `Generator.generate_word()`
          - Module contents
            - `TranslipsumGenerator`
              - `TranslipsumGenerator.generate_paragraph()`
              - `TranslipsumGenerator.generate_sentence()`
      - Module contents
    - transliterate.contrib.languages package
      - Subpackages
        - transliterate.contrib.languages.bg package
          - Subpackages
            - transliterate.contrib.languages.bg.data package
              - Submodules
              - transliterate.contrib.languages.bg.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.bg.translit_language_pack module
            - `BulgarianLanguagePack`
              - `BulgarianLanguagePack.character_ranges`
              - `BulgarianLanguagePack.detectable`
              - `BulgarianLanguagePack.language_code`
              - `BulgarianLanguagePack.language_name`
              - `BulgarianLanguagePack.mapping`
              - `BulgarianLanguagePack.pre_processor_mapping`
              - `BulgarianLanguagePack.reversed_specific_mapping`
          - Module contents
        - transliterate.contrib.languages.el package
          - Subpackages
            - transliterate.contrib.languages.el.data package
              - Submodules
              - transliterate.contrib.languages.el.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.el.translit_language_pack module
            - `GreekLanguagePack`
              - `GreekLanguagePack.character_ranges`
              - `GreekLanguagePack.detectable`
              - `GreekLanguagePack.language_code`
              - `GreekLanguagePack.language_name`
              - `GreekLanguagePack.mapping`
              - `GreekLanguagePack.pre_processor_mapping`
              - `GreekLanguagePack.reversed_specific_mapping`
          - Module contents
        - transliterate.contrib.languages.he package
          - Submodules
          - transliterate.contrib.languages.he.translit_language_pack module
            - `HebrewLanguagePack`
              - `HebrewLanguagePack.character_ranges`
              - `HebrewLanguagePack.detectable`
              - `HebrewLanguagePack.language_code`
              - `HebrewLanguagePack.language_name`
              - `HebrewLanguagePack.mapping`
              - `HebrewLanguagePack.pre_processor_mapping`
              - `HebrewLanguagePack.reversed_specific_mapping`
          - Module contents
        - transliterate.contrib.languages.hi package
          - Submodules
          - transliterate.contrib.languages.hi.translit_language_pack module
            - `HindiLanguagePack`
              - `HindiLanguagePack.character_ranges`
              - `HindiLanguagePack.detectable`
              - `HindiLanguagePack.language_code`
              - `HindiLanguagePack.language_name`
              - `HindiLanguagePack.mapping`
              - `HindiLanguagePack.pre_processor_mapping`
          - Module contents
        - transliterate.contrib.languages.hy package
          - Subpackages
            - transliterate.contrib.languages.hy.data package
              - Submodules
              - transliterate.contrib.languages.hy.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.hy.translit_language_pack module
            - `ArmenianLanguagePack`
              - `ArmenianLanguagePack.character_ranges`
              - `ArmenianLanguagePack.detectable`
              - `ArmenianLanguagePack.language_code`
              - `ArmenianLanguagePack.language_name`
              - `ArmenianLanguagePack.mapping`
              - `ArmenianLanguagePack.pre_processor_mapping`
              - `ArmenianLanguagePack.reversed_specific_mapping`
              - `ArmenianLanguagePack.reversed_specific_pre_processor_mapping`
          - Module contents
        - transliterate.contrib.languages.ka package
          - Subpackages
            - transliterate.contrib.languages.ka.data package
              - Submodules
              - transliterate.contrib.languages.ka.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.ka.translit_language_pack module
            - `GeorgianLanguagePack`
              - `GeorgianLanguagePack.character_ranges`
              - `GeorgianLanguagePack.detectable`
              - `GeorgianLanguagePack.language_code`
              - `GeorgianLanguagePack.language_name`
              - `GeorgianLanguagePack.mapping`
              - `GeorgianLanguagePack.pre_processor_mapping`
              - `GeorgianLanguagePack.translit()`
          - Module contents
        - transliterate.contrib.languages.l1 package
          - Subpackages
            - transliterate.contrib.languages.l1.data package
              - Submodules
              - transliterate.contrib.languages.l1.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.l1.translit_language_pack module
            - `Latin1SupplementLanguagePack`
              - `Latin1SupplementLanguagePack.character_ranges`
              - `Latin1SupplementLanguagePack.detectable`
              - `Latin1SupplementLanguagePack.language_code`
              - `Latin1SupplementLanguagePack.language_name`
              - `Latin1SupplementLanguagePack.mapping`
              - `Latin1SupplementLanguagePack.reversed_specific_mapping`
              - `Latin1SupplementLanguagePack.reversed_specific_pre_processor_mapping`
          - Module contents
        - transliterate.contrib.languages.mk package
          - Subpackages
            - transliterate.contrib.languages.mk.data package
              - Submodules
              - transliterate.contrib.languages.mk.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.mk.translit_language_pack module
            - `MacedonianLanguagePack`
              - `MacedonianLanguagePack.character_ranges`
              - `MacedonianLanguagePack.detectable`
              - `MacedonianLanguagePack.language_code`
              - `MacedonianLanguagePack.language_name`
              - `MacedonianLanguagePack.mapping`
              - `MacedonianLanguagePack.pre_processor_mapping`
              - `MacedonianLanguagePack.reversed_specific_mapping`
          - Module contents
        - transliterate.contrib.languages.mn package
          - Subpackages
            - transliterate.contrib.languages.mn.data package
              - Submodules
              - transliterate.contrib.languages.mn.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.mn.translit_language_pack module
            - `MongolianLanguagePack`
              - `MongolianLanguagePack.character_ranges`
              - `MongolianLanguagePack.detectable`
              - `MongolianLanguagePack.language_code`
              - `MongolianLanguagePack.language_name`
              - `MongolianLanguagePack.mapping`
              - `MongolianLanguagePack.pre_processor_mapping`
              - `MongolianLanguagePack.reversed_specific_mapping`
          - Module contents
        - transliterate.contrib.languages.ru package
          - Subpackages
            - transliterate.contrib.languages.ru.data package
              - Submodules
              - transliterate.contrib.languages.ru.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.ru.translit_language_pack module
            - `RussianLanguagePack`
              - `RussianLanguagePack.character_ranges`
              - `RussianLanguagePack.detectable`
              - `RussianLanguagePack.language_code`
              - `RussianLanguagePack.language_name`
              - `RussianLanguagePack.mapping`
              - `RussianLanguagePack.pre_processor_mapping`
              - `RussianLanguagePack.reversed_specific_mapping`
          - Module contents
        - transliterate.contrib.languages.sr package
          - Subpackages
            - transliterate.contrib.languages.sr.data package
              - Submodules
              - transliterate.contrib.languages.sr.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.sr.translit_language_pack module
            - `SerbianLanguagePack`
              - `SerbianLanguagePack.character_ranges`
              - `SerbianLanguagePack.detectable`
              - `SerbianLanguagePack.language_code`
              - `SerbianLanguagePack.language_name`
              - `SerbianLanguagePack.mapping`
              - `SerbianLanguagePack.pre_processor_mapping`
              - `SerbianLanguagePack.reversed_specific_mapping`
          - Module contents
        - transliterate.contrib.languages.uk package
          - Subpackages
            - transliterate.contrib.languages.uk.data package
              - Submodules
              - transliterate.contrib.languages.uk.data.default module
              - Module contents
          - Submodules
          - transliterate.contrib.languages.uk.translit_language_pack module
            - `UkrainianLanguagePack`
              - `UkrainianLanguagePack.character_ranges`
              - `UkrainianLanguagePack.language_code`
              - `UkrainianLanguagePack.language_name`
              - `UkrainianLanguagePack.mapping`
              - `UkrainianLanguagePack.pre_processor_mapping`
              - `UkrainianLanguagePack.reversed_specific_mapping`
          - Module contents
      - Module contents
  - Module contents
- transliterate.tests package
  - Subpackages
    - transliterate.tests.data package
      - Submodules
      - transliterate.tests.data.default module
      - Module contents
  - Submodules
  - transliterate.tests.base module
  - transliterate.tests.defaults module
  - transliterate.tests.helpers module
    - `log_info()`
    - `py2only()`
  - transliterate.tests.test_transliterate module
    - `TransliterateTest`
      - `TransliterateTest.setUp()`
      - `TransliterateTest.test_01_get_available_language_codes()`
      - `TransliterateTest.test_02_translit_latin_to_armenian()`
      - `TransliterateTest.test_03_translit_latin_to_georgian()`
      - `TransliterateTest.test_04_translit_latin_to_greek()`
      - `TransliterateTest.test_06_translit_latin_to_bulgarian_cyrillic()`
      - `TransliterateTest.test_06_translit_latin_to_cyrillic()`
      - `TransliterateTest.test_06_translit_latin_to_mongolian_cyrillic()`
      - `TransliterateTest.test_06_translit_latin_to_serbian_cyrillic()`
      - `TransliterateTest.test_06_translit_latin_to_ukrainian_cyrillic()`
      - `TransliterateTest.test_07_translit_armenian_to_latin()`
      - `TransliterateTest.test_08_translit_georgian_to_latin()`
      - `TransliterateTest.test_09_translit_greek_to_latin()`
      - `TransliterateTest.test_11_translit_bulgarian_cyrillic_to_latin()`
      - `TransliterateTest.test_11_translit_cyrillic_to_latin()`
      - `TransliterateTest.test_11_translit_mongolian_cyrillic_to_latin()`
      - `TransliterateTest.test_11_translit_serbian_cyrillic_to_latin()`
      - `TransliterateTest.test_11_translit_ukrainian_cyrillic_to_latin()`
      - `TransliterateTest.test_12_function_decorator()`
      - `TransliterateTest.test_13_method_decorator()`
      - `TransliterateTest.test_14_function_decorator()`
      - `TransliterateTest.test_15_register_custom_language_pack()`
      - `TransliterateTest.test_16_translipsum_generator_armenian()`
      - `TransliterateTest.test_17_translipsum_generator_georgian()`
      - `TransliterateTest.test_18_translipsum_generator_greek()`
      - `TransliterateTest.test_20_translipsum_generator_bulgarian_cyrillic()`
      - `TransliterateTest.test_20_translipsum_generator_cyrillic()`
      - `TransliterateTest.test_20_translipsum_generator_mongolian_cyrillic()`
      - `TransliterateTest.test_20_translipsum_generator_serbian_cyrillic()`
      - `TransliterateTest.test_20_translipsum_generator_ukrainian_cyrillic()`
      - `TransliterateTest.test_21_language_detection_armenian()`
      - `TransliterateTest.test_22_language_detection_georgian()`
      - `TransliterateTest.test_23_language_detection_greek()`
      - `TransliterateTest.test_25_false_language_detection_cyrillic()`
      - `TransliterateTest.test_25_language_detection_cyrillic()`
      - `TransliterateTest.test_26_slugify_armenian()`
      - `TransliterateTest.test_27_slugify_georgian()`
      - `TransliterateTest.test_28_slugify_greek()`
      - `TransliterateTest.test_30_slugify_bulgarian_cyrillic()`
      - `TransliterateTest.test_30_slugify_cyrillic()`
      - `TransliterateTest.test_30_slugify_mongolian_cyrillic()`
      - `TransliterateTest.test_30_slugify_serbian_cyrillic()`
      - `TransliterateTest.test_30_slugify_ukrainian_cyrillic()`
      - `TransliterateTest.test_31_override_settings()`
      - `TransliterateTest.test_31b_get_translit_function()`
      - `TransliterateTest.test_32_auto_translit_reversed()`
      - `TransliterateTest.test_33_register_unregister()`
      - `TransliterateTest.test_35_translit_serbian_cyrillic_to_serbian_latin()`
      - `TransliterateTest.test_35_translit_serbian_latin_to_serbian_cyrillic()`
  - Module contents

## Submodules

## transliterate.base module

class transliterate.base.TranslitLanguagePack

  Bases: `object`

  Base language pack.

  > The attributes below shall be defined in every language pack.

  > `language_code`: Language code (obligatory). Example value: ‘hy’, ‘ru’. `language_name`: Language name (obligatory). Example value: ‘Armenian’,

  > > ‘Russian’.

  > `character_ranges`: Character ranges that are specific to the language.

  >   When making a pack, check this page for the ranges.

  > `mapping`: Mapping (obligatory). A tuple, consisting of two strings

  >   (source and target). Example value: (u’abc’, u’աբց’).

  > `reversed_specific_mapping`: Specific mapping (one direction only) used

  >   when transliterating from target script to source script (reversed transliteration).

  > ՝՝pre_processor_mapping՝՝: Pre processor mapping (optional). A dictionary

  >   mapping for letters that can’t be represented by a single latin letter.

  > ՝՝reversed_specific_pre_processor_mapping՝՝: Pre processor mapping (

  >   optional). A dictionary mapping for letters that can’t be represented by a single latin letter (reversed transliteration).

  > example:

      >>>    class ArmenianLanguagePack(TranslitLanguagePack):
      >>>    language_code = "hy"
      >>>    language_name = "Armenian"
      >>>    character_ranges = ((0x0530, 0x058F), (0xFB10, 0xFB1F))
      >>>    mapping = (
      >>>        u"abgdezilxkhmjnpsvtrcq&ofABGDEZILXKHMJNPSVTRCQOF", # Source script
      >>>        u"աբգդեզիլխկհմյնպսվտրցքևօֆԱԲԳԴԵԶԻԼԽԿՀՄՅՆՊՍՎՏՐՑՔՕՖ", # Target script
      >>>    )
      >>>    reversed_specific_mapping = (
      >>>        u"ռՌ",
      >>>        u"rR"
      >>>    )
      >>>    pre_processor_mapping = {
      >>>        # lowercase
      >>>        u"e'": u"է",
      >>>        u"y": u"ը",
      >>>        u"th": u"թ",
      >>>        u"jh": u"ժ",
      >>>        u"ts": u"ծ",
      >>>        u"dz": u"ձ",
      >>>        u"gh": u"ղ",
      >>>        u"tch": u"ճ",
      >>>        u"sh": u"շ",
      >>>        u"vo": u"ո",
      >>>        u"ch": u"չ",
      >>>        u"dj": u"ջ",
      >>>        u"ph": u"փ",
      >>>        u"u": u"ու",
      >>>
      >>>        # uppercase
      >>>        u"E'": u"Է",
      >>>        u"Y": u"Ը",
      >>>        u"Th": u"Թ",
      >>>        u"Jh": u"Ժ",
      >>>        u"Ts": u"Ծ",
      >>>        u"Dz": u"Ձ",
      >>>        u"Gh": u"Ղ",
      >>>        u"Tch": u"Ճ",
      >>>        u"Sh": u"Շ",
      >>>        u"Vo": u"Ո",
      >>>        u"Ch": u"Չ",
      >>>        u"Dj": u"Ջ",
      >>>        u"Ph": u"Փ",
      >>>        u"U": u"Ու"
      >>>    }
      >>>    reversed_specific_pre_processor_mapping = {
      >>>        u"ու": u"u",
      >>>        u"Ու": u"U"
      >>>    }
          Note, that in Python 3 you won't be using u prefix before the strings.

  character_ranges = None
  characters = None
  classmethod contains(character)

    Check if given character belongs to the language pack.

    Return bool:

  classmethod detect(num_words=None)

    Detect the language.

    Heavy language detection, which is activated for languages that are harder detect (like Russian Cyrillic and Ukrainian Cyrillic).

    Parameters:

      - value (unicode) – Input string.

      - num_words (int) – Number of words to base decision on.

    Return bool:

      True if detected and False otherwise.

  detectable = False
  language_code = None
  language_name = None
  make_strict(value, reversed=False)

    Strip out unnecessary characters from the string.

    Parameters:

      - value (string)

      - reversed (bool)

    Return string:

  mapping = None
  pre_processor_mapping = None
  pre_processor_mapping_keys = []
  reversed_characters = None
  reversed_pre_processor_mapping_keys = []
  reversed_specific_mapping = None
  reversed_specific_pre_processor_mapping = None
  reversed_specific_pre_processor_mapping_keys = []
  classmethod suggest(reversed=False, limit=None)

    Suggest possible variants (some sort of auto-complete).

    Parameters:

      - value (str)

      - limit (int) – Limit number of suggested variants.

    Return list:

  translit(value, reversed=False, strict=False, fail_silently=True)

    Transliterate the given value according to the rules.

    Rules are set in the transliteration pack.

    Parameters:

      - value (str)

      - reversed (bool)

      - strict (bool)

      - fail_silently (bool)

    Return str:

## transliterate.conf module

transliterate.conf.get_setting(name, default=None)

  Get a variable from local settings.

  Parameters:

    - name (str)

    - default (mixed) – Default value.

  Return mixed:

transliterate.conf.reset_to_defaults_settings()

  Reset settings to defaults.

transliterate.conf.set_setting(name, value)

  Override default settings.

  Parameters:

    - name (str)

    - value (mixed)

## transliterate.decorators module

transliterate.decorators.transliterate_function

  alias of `TransliterateFunction`

transliterate.decorators.transliterate_method

  alias of `TransliterateMethod`

## transliterate.defaults module

## transliterate.discover module

transliterate.discover.autodiscover()

  Auto-discover the language packs in contrib/apps.

## transliterate.exceptions module

exception transliterate.exceptions.ImproperlyConfigured

  Bases: `Exception`

  Exception raised when developer didn’t configure the code properly.

exception transliterate.exceptions.InvalidRegistryItemType

  Bases: `ValueError`

  Raised when an attempt is made to register an item in the registry.

  Raised when an attempt is made to register an item in the registry which does not have a proper type.

exception transliterate.exceptions.LanguageCodeError

  Bases: `Exception`

  Exception raised when language code is empty or has incorrect value.

exception transliterate.exceptions.LanguageDetectionError

  Bases: `Exception`

  Exception raised when language can’t be detected.

  Exception raised when language can’t be detected for the text given.

exception transliterate.exceptions.LanguagePackNotFound

  Bases: `Exception`

  Exception raised when language pack is not found.

  Exception raised when language pack is not found for the language code given.

## transliterate.helpers module

transliterate.helpers.PROJECT_DIR(base)

  Project dir.

transliterate.helpers.project_dir(base)

  Project dir.

## transliterate.utils module

transliterate.utils.detect_language(text, num_words=None, fail_silently=True, heavy_check=False)

  Detect the language from the value given.

  Detect the language from the value given based on ranges defined in active language packs.

  Parameters:

    - value (unicode) – Input string.

    - num_words (int) – Number of words to base decision on.

    - fail_silently (bool)

    - heavy_check (bool) – If given, heavy checks would be applied when simple checks don’t give any results. Heavy checks are language specific and do not apply to a common logic. Heavy language detection is defined in the `detect` method of each language pack.

  Return str:

    Language code.

transliterate.utils.get_available_language_codes()

  Get list of language codes for registered language packs.

  Return list:

transliterate.utils.get_available_language_packs()

  Get list of registered language packs.

  Return list:

transliterate.utils.get_translit_function(language_code)

  Return translit function for the language given.

  Parameters:

    language_code (str)

  Return callable:

transliterate.utils.slugify(text, language_code=None)

  Slugify the given text.

  If no `language_code` is given, auto-detect the language code from text given.

  Parameters:

    - text (str)

    - language_code (str)

  Return str:

transliterate.utils.suggest(value, language_code=None, reversed=False, limit=None)

  Suggest possible variants.

  Parameters:

    - value (str)

    - language_code (str)

    - reversed (bool) – If set to True, reversed translation is made.

    - limit (int) – Limit number of suggested variants.

  Return list:

transliterate.utils.translit(value, language_code=None, reversed=False, strict=False)

  Transliterate the text for the language given.

  Language code is optional in case of reversed translations (from some script to latin).

  Parameters:

    - value (str)

    - language_code (str)

    - reversed (bool) – If set to True, reversed translation is made.

    - strict (bool) – If given, all that are not found in the transliteration pack, are simply stripped out.

  Return str:

## Module contents

transliterate.detect_language(text, num_words=None, fail_silently=True, heavy_check=False)

  Detect the language from the value given.

  Detect the language from the value given based on ranges defined in active language packs.

  Parameters:

    - value (unicode) – Input string.

    - num_words (int) – Number of words to base decision on.

    - fail_silently (bool)

    - heavy_check (bool) – If given, heavy checks would be applied when simple checks don’t give any results. Heavy checks are language specific and do not apply to a common logic. Heavy language detection is defined in the `detect` method of each language pack.

  Return str:

    Language code.

transliterate.get_available_language_codes()

  Get list of language codes for registered language packs.

  Return list:

transliterate.get_available_language_packs()

  Get list of registered language packs.

  Return list:

transliterate.get_translit_function(language_code)

  Return translit function for the language given.

  Parameters:

    language_code (str)

  Return callable:

transliterate.slugify(text, language_code=None)

  Slugify the given text.

  If no `language_code` is given, auto-detect the language code from text given.

  Parameters:

    - text (str)

    - language_code (str)

  Return str:

transliterate.translit(value, language_code=None, reversed=False, strict=False)

  Transliterate the text for the language given.

  Language code is optional in case of reversed translations (from some script to latin).

  Parameters:

    - value (str)

    - language_code (str)

    - reversed (bool) – If set to True, reversed translation is made.

    - strict (bool) – If given, all that are not found in the transliteration pack, are simply stripped out.

  Return str: