rails-translator

command module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 8 Imported by: 0

README

Rails Language File Translator

Translate Rails internationalization files from one language to another using the power of OpenAI's GPT-3.5 Turbo. This tool is designed to handle nested YAML structures and ensures that HTML tags and placeholders are preserved during the translation process.

Features

  • Translates Rails language files while preserving HTML tags.
  • Does not translate placeholders surrounded by %%{ and }.
  • Supports nested YAML structures.
  • Automatically saves the translated file with the appropriate language code.

Installation

  1. Download Builder:

    Using Homebrew:

    brew tap jtarchie/translation https://github.com/jtarchie/rails-translator
    brew install rails-translator
    

Usage

  1. Translate the example from English to Japanese:

    rails-translator \
     --from-filename examples/en.yml \
     --from-language "British English" \
     --to-filename examples/jp.yml \
     --to-language "Japanese" \
     --openai-access-token $YOUR_OPENAI_API_TOKEN
    
  2. Check the file examples/jp.yml.

    English:

    en:
      welcome_html: "<b>Welcome %{username}!</b>"
      static_pages:
        index:
          welcome: "Welcome!"
          services_html: "We provide some fancy services to <em>good people</em>."
    

    Japanese (translation):

    jp:
      static_pages:
        index:
          services_html: 私たちは<em>善良な人々</em>にいくつかの華やかなサービスを提供します。
          welcome: ようこそ!
      welcome_html: <b>ようこそ %{username} さん!</b>
    

    Keeps the HTML and %{} placeholders.

Limitations

  • Ensure that your OpenAI API quota is sufficient for the number of translations.
  • The tool assumes that the provided YAML file is correctly formatted.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL