Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Support for dotenv-rails, to load GOOGLE_TRANSLATE_API_KEY from .env.development #395

Open
ndbroadbent opened this issue Nov 5, 2021 · 5 comments

Comments

@ndbroadbent
Copy link

Hello, I use the dotenv-rails gem to define configuration vars in .env, .env.test, .env.development, etc. This doesn't seem to be working with i18n-tasks. I've set GOOGLE_TRANSLATE_API_KEY in my .env.development file, but it looks like i18n-tasks doesn't load the Rails environment, so I get this error:

$ i18n-tasks translate-missing
i18n-tasks: Set Google API key via GOOGLE_TRANSLATE_API_KEY environment variable or translation.google_translate_api_key in config/i18n-tasks.yml. Get the key at https://code.google.com/apis/console.

It would be nice if i18n-tasks could work together with dotenv-rails to load these env vars from .env files.

Also I realize that it's very difficult to maintain an open source project, so if this is too much work or no-one else wants it, then please feel free to close it. Thanks for all your work!

@lorenzk
Copy link

lorenzk commented Dec 15, 2021

@ndbroadbent Just an idea: I recently found https://direnv.net/, which is a more general solution to the same problem and should fix your problem as well.

@dssjoblom
Copy link

This would be good for DeepL as well, which can't be controlled by environment variables at all.

@fschwahn
Copy link

you can do the following to pick up variables from dotenv:

bundle exec dotenv -f ".env.development" i18n-tasks translate-missing

@glebm
Copy link
Owner

glebm commented Jun 15, 2022

This would be good for DeepL as well, which can't be controlled by environment variables at all.

conf[:deepl_api_key] = ENV['DEEPL_AUTH_KEY'] if ENV.key?('DEEPL_AUTH_KEY')
conf[:deepl_host] = ENV['DEEPL_HOST'] if ENV.key?('DEEPL_HOST')
conf[:deepl_version] = ENV['DEEPL_VERSION'] if ENV.key?('DEEPL_VERSION')

@dssjoblom
Copy link

@glebm ok, it's been there for years, apparently :D I think this should be mentioned in the README.md though, as it's only obvious from reading the source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants