Skip to main content

Translate korean text

Project description

KR Translator

Translate a korean txt file.

Installation

You can install the package using pip:

pip install kr-translation

Usage

Getting GOOGLE_API_KEU

  1. Go to https://aistudio.google.com/apikey, follow instruction over there.

  2. Save the API KEY somewhere save.

Basic Translation

from kr_translator.caller import TextTranslator

translator = TextTranslator(
  api_key="your_api_key_here", 
  source_file_location="/path/to/file.txt"
)
output = translator.translate()

print(output)

Save Translation to a file

from kr_translator.caller import TextTranslator

translator = TextTranslator(
  api_key="your_api_key_here", 
  source_file_location="/path/to/file.txt"
)
translator.save_translation("output_file.txt")

Passing character information to improve translation

from kr_translator.caller import TextTranslator

translator = TextTranslator(
  api_key="your_api_key_here", 
  source_file_location="/path/to/file.txt"
)

character_info = """
Seo Dalmi, a girl.
Nam Dosan, a boy.
Han Jipyeong, a boy, team leader at SH venture capital.
"""

translator.save_translation(
    destination_file_location="output_file.txt",
    characters=character_info
)

Passing additional information to improve translation

from kr_translator.caller import TextTranslator

translator = TextTranslator(
  api_key="your_api_key_here", 
  source_file_location="/path/to/file.txt"
)

additonal_info = """
The story revolve around startups and venture capital, therefore there is gonna be company name
that might have direct english translation, in which DO NOT translate them into english but keep
the Korean name.
"""

translator.save_translation(
    destination_file_location="output_file.txt",
    additional_info=additonal_info
)

Using different Gemini model

By default, we are using experimental gemini-2.0-flash-exp, because it is a free model. However it comes with strict rate limit. Once we reach this limit, we need to use paid model such as gemini-2.0-flash.

from kr_translator.caller import TextTranslator

translator = TextTranslator(
  api_key="your_api_key_here", 
  source_file_location="/path/to/file.txt",
  model="gemini-2.0-flash"
)
output = translator.translate()

print(output)

Using OpenAI model

In order to use OpenAI model, we need OPENAI_API_KEY. Go to this page to get it.

from kr_translator.caller import TextTranslator

translator = TextTranslator(
  api_key="your_openai_api_key_here", 
  source_file_location="/path/to/file.txt",
  model_type="open_ai",
  model="gpt-4o-mini",  # required when model_type is open_ai
)
output = translator.translate()

print(output)

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

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

kr_translator-0.1.7.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

kr_translator-0.1.7-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file kr_translator-0.1.7.tar.gz.

File metadata

  • Download URL: kr_translator-0.1.7.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for kr_translator-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e26138401fdcf72d9ea7ec6cde9bfecda9b4bc8fbd61ea893772dfb1b2194e37
MD5 a56ef636246e27dbee9de001de17b64e
BLAKE2b-256 93080b230b2f0df3798cd64c7fa42392d9aa4362ff99c256b6106392c447d73a

See more details on using hashes here.

File details

Details for the file kr_translator-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: kr_translator-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for kr_translator-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1caf95607fd34a5dc2d90c566eeaab0cdd233a66e474ec6082277de6cae2d5f0
MD5 f6010ed3b92cb7e95138679ff850dafc
BLAKE2b-256 24ac8d61d66e67ff4d10e4cf3ba1d91f7c0d3cffa7fbab56096c8d0b45c9bc54

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