Skip to main content

A Python package for translating large texts with advanced features.

Project description

OctoLingo

OctoLingo is a powerful and versatile Python package designed to simplify text translation and language processing tasks. Built with developers in mind, OctoLingo provides a seamless interface for translating text, detecting languages, and handling large-scale translation tasks efficiently. Whether you're building a multilingual application, analyzing global content, or automating translation workflows, OctoLingo has you covered.

Key Features

🌍 Multi-Language Support

  • Translate text between 100+ languages with high accuracy.
  • Automatically detect the language of input text.

🚀 Efficient Large-Text Handling

  • Split large texts into manageable chunks to overcome API limitations.
  • Translate large documents or datasets without hassle.
  • Batch translation for large-scale projects.

Asynchronous Translation

  • Perform non-blocking translations using async/await for improved performance.

📚 Custom Glossaries

  • Define custom terms and their translations for domain-specific use cases.
  • Ensure consistent translations for specialized vocabulary.

📂 Bulk File Translation

  • Translate entire text files (e.g., .txt, .csv) with a single command.

📜 Translation History

  • Log and retrieve translation history for auditing and analysis.

🛠️ Developer-Friendly

  • Easy-to-use API with comprehensive documentation.
  • Modular design for seamless integration into existing projects.

Installation

Install OctoLingo via pip:

pip install octolingo

Usage

Language Validation

from UniversalTranslator.translator import UniversalTranslator

translator = UniversalTranslator()
print(translator.validate_language('es'))  # Should return True
try:
    print(translator.validate_language('xx'))  # Should raise TranslationError
except Exception as e:
    print(e)

Translating Text

from UniversalTranslator.translator import UniversalTranslator

translator = UniversalTranslator()
translated_text, confidence = translator.translate("Hello, world!", 'es')
print(f"Translated Text: {translated_text}, Confidence: {confidence}")

Batch Translation

from UniversalTranslator.translator import UniversalTranslator

translator = UniversalTranslator()
texts = ["Hello", "Goodbye"]
results = translator.translate_batch(texts, 'es')
for translated_text, confidence in results:
    print(f"Translated Text: {translated_text}, Confidence: {confidence}")

Asynchronous Translation

import asyncio
from octolinguo.translator import OctoLingo

async def translate_async():
    translator = OctoLingo()
    translated_text, confidence = await translator.translate_async("Hello, world!", 'es')
    print(translated_text)  # Output: "¡Hola, mundo!"

asyncio.run(translate_async())

Detecting Language

from UniversalTranslator.translator import UniversalTranslator

translator = UniversalTranslator()
lang, confidence = translator.detect_language("Hola, cómo estás?")
print(f"Detected Language: {lang}, Confidence: {confidence}")

Custom Glossaries

from UniversalTranslator.glossary import Glossary

glossary = Glossary()
glossary.add_term("Hello", "Hola")
result = glossary.apply_glossary("Hello, world!")
print(result)  # Should print "Hola, world!"

Bulk File Translation

from UniversalTranslator.translator import UniversalTranslator
from UniversalTranslator.file_handler import FileHandler

# Write test content to a file
FileHandler.write_file('input.txt', "Hello, world!")

# Translate the file content
translator = UniversalTranslator()
text = FileHandler.read_file('input.txt')
translated_text, _ = translator.translate(text, 'es')
FileHandler.write_file('output.txt', translated_text)

# Read and print the translated content
print(FileHandler.read_file('output.txt'))  # Should print the translated text

Translation History

from UniversalTranslator.history import TranslationHistory

history = TranslationHistory()
history.log_translation("Hello", "Hola", "en", "es")
print(history.get_history())  # Should print the logged translation

Contributing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

octolingo-0.1.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

octolingo-0.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file octolingo-0.1.1.tar.gz.

File metadata

  • Download URL: octolingo-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for octolingo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a2a11eab89f8084c1750d9ffcaa8604775c1ee03dff71a545699cb2356c524a1
MD5 6bed177782657b32bd268a1013bea86e
BLAKE2b-256 030676289207ce21fee60cbd85acd9c65706d515bcfb695d571d1fd0f9288133

See more details on using hashes here.

File details

Details for the file octolingo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: octolingo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for octolingo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c3ea642b8daf3693be43ae385136c15bc1c155abc7f3c9064a20df721c8764a0
MD5 49d7884c9958ee23a1929b9bc2f248fa
BLAKE2b-256 70ccff1aa5a07137f5b9c1df0a8ca42a5565e394fe51404c4d6ffb11c057b40f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page