Package Api Documentation for potranslator

API Reference for the classes in potranslator.potranslator.py

Main module.

class potranslator.potranslator.PoTranslator(pot_dir=None, locale_dir=None)[源代码]

This is the main class of this library. This class manages all translation tasks.

参数:
  • pot_dir -- string. Path to the pot directory.
  • locale_dir -- string. Path to the locale directory.
translate(file_name, target_lang='auto', src_lang='auto', encoding='utf-8', auto_save=False, compiled=False)[源代码]

Translates the given po file in the specified target language.

参数:
  • file_name -- string. Path to the filename of the file to translate.
  • target_lang -- string. Target language for translation.
  • src_lang -- string. Source language for translation.
  • encoding -- string. Encoding for saving the po files.
  • auto_save -- bool. Toggles auto save feature.
  • compiled -- bool. Toggles compilation to mo files.
返回:

tuple. A tuple containing the translated version of the original catalog and the status of the POFile.

translate_all_locale(src_lang='auto', encoding='utf-8', auto_save=False, compiled=False)[源代码]

Translates all the po files in the found languages in the locale folder.

参数:
  • src_lang -- string. Source language for translation.
  • encoding -- string. Encoding for saving the po files.
  • auto_save -- bool. Toggles auto save feature.
  • compiled -- bool. Toggles compilation to mo files.
返回:

Dictionary. A dictionary of po files.

translate_from_pot(filename, status, target_langs, src_lang='auto', encoding='utf-8', auto_save=False, compiled=False)[源代码]

Translates the given pot file in the specified target languages.

参数:
  • filename -- string. Path to the filename of the file to translate.
  • target_langs -- sequence of strings. Target language for translation.
  • src_lang -- string. Source language for translation.
  • encoding -- string. Encoding for saving the po files.
  • auto_save -- bool. Toggles auto save feature.
  • compiled -- bool. Toggles compilation to mo files.
返回:

Dictionary. A dictionary of po files.

translate_all_pot(target_langs, src_lang='auto', encoding='utf-8', auto_save=False, compiled=False)[源代码]

Translates all the pot files in the pot folder in the specified target languages.

参数:
  • target_langs -- sequence of strings. Target language for translation.
  • src_lang -- string. Source language for translation.
  • encoding -- string. Encoding for saving the po files.
  • auto_save -- bool. Toggles auto save feature.
  • compiled -- bool. Toggles compilation to mo files.
返回:

Dictionary. A dictionary of po files.