Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18n-ai

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-ai

  • 0.1.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

i18n-ai

i18n-ai is a gem that converts your rails locales into different languages automatically. Uses the en.yml file as base by default and creates accompanying es.yml, it.yml and others depending on your configuration.

Currently uses OpenAI (gpt4o-mini) to generate the translations but support for other AI models and APIs will be added soon.

Installation

Simply add to your gemfile:

gem "i18n-ai"

And do bundle install.

Configuration

To use I18nAi, you need to set the appropriate environment variables based on the AI service you wish to use.

OpenAi

If you are using OpenAI, set ENV["OPENAI_ACCESS_TOKEN"]

To configure and enable other locales, create a file config/initializers/i18n_aii.rb and add the following:

# config/initializers/i18n_ai.rb
I18nAi.configure do |config|
  config.ai_settings = {
    provider: "openai",
    model: "gpt-4o-mini",
    access_token: ENV["OPENAI_ACCESS_TOKEN"]
  }
  config.generate_locales = [:es, :it] # add your other supported locales to this array
end

Anthropic's Claude

If you prefer to use Anthropic's Claude, set ENV[ANTHROPIC_API_KEY]

To configure and enable other locales, create a file config/initializers/i18n_ai.rb and add the following:

I18nAi.configure do |config|
  config.ai_settings = {
    provider: "anthropic",
    model: "claude-3-haiku-20240307",
    access_token: ENV["ANTHROPIC_ACCESS_TOKEN"]
  }
  config.generate_locales = [:es]
end

Usage

Every page reload, the gem will check if the en.yml file changed and if it did, it will automatically generate the configured locale files.

The gem has been setup to generate a es.yml file by default.

To disable locale generation simply set the generate_locales to an empty array.

I18nAi.configure do |config|
  config.generate_locales = []
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the I18n::Ai project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 07 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc