ImmosquareTranslate is a versatile Ruby gem that leverages artificial intelligence to provide comprehensive translation capabilities across a variety of content types. From YAML files to arrays and web pages, it equips developers with the tools needed to easily make their applications multilingual.
-
Versatile Translations: Supports translating multiple content types, enabling broader application internationalization.
-
AI Integration: Offers integration with various AI services, allowing you to choose the best AI for your translation needs.
-
Easy Configuration: Simplifies setup with customizable options for seamless integration into Ruby applications.
-
Dynamic Content Management: Enables efficient translation updates and management for maintaining up-to-date multilingual content.
Stay tuned for more details on how to configure, install, and utilize ImmosquareTranslate to make your Ruby applications truly global.
Add this line to your application's Gemfile:
gem 'immosquare-translate'
And then execute:
bundle install
Or install it yourself as:
gem install immosquare-translate
Set up your OpenAI API key and specify the OpenAI model in a Rails initializer.
# config/initializers/immosquare-translate.rb
# =======================================
# Available models:
# https://platform.openai.com/docs/models/
# gpt-3.5-turbo-0125
# gpt-4-turbo
# gpt-4o
# =======================================
ImmosquareTranslate.config do |config|
config.openai_api_key = ENV.fetch("OPENAI_API_KEY", nil)
config.openai_model = "gpt-4o"
end
Translate your YAML files into the desired language with ease. Specify the file path and the target language code:
ImmosquareTranslate::YmlTranslator.translate("path/to/your/file.yml", "fr")
To reset translations in the target file before translating:
ImmosquareTranslate::YmlTranslator.translate("path/to/your/file.yml", "fr", reset_translations: true)
Effortlessly translate arrays of text from one language to multiple target languages. This feature also supports text correction by including the source language among the target languages. This allows for the correction of spelling and grammatical errors in the source text:
translated_data = ImmosquareTranslate::Translator.translate(["Bonjour", "Au revoir"], "fr", ["en", "es", "it"])
[{"en"=>"Hello", "es"=>"Hola", "it"=>"Ciao"}, {"en"=>"Goodbye", "es"=>"Adiós", "it"=>"Addio"}]
translated_data = ImmosquareTranslate::Translator.translate(["Bonjour mes ami", "O revoir"], "fr", ["en", "es", "fr", "it"])
[{"fr"=>"Bonjour mes amis", "en"=>"Hello my friends", "es"=>"Hola mis amigos", "it"=>"Ciao miei amici"}, {"fr"=>"Au revoir", "en"=>"Goodbye", "es"=>"Adiós", "it"=>"Arrivederci"}]
Simplify YML file management with provided rake tasks:
- Translation: Translates all translation files within your Rails application. By default,
SOURCE_LOCALE
is French (fr), andRESET_TRANSLATIONS
is false.
rake immosquare_translate:translate_rails_locales
rake immosquare_translate:translate_rails_locales SOURCE_LOCALE=en RESET_TRANSLATIONS=true
Contributions are welcome! Open an issue or submit a pull request on our GitHub repository.
This gem is available under the terms of the MIT License.