Open arusa opened 3 years ago
Would be great to have this. Although I can't get it to work as is.
I followed the instructions from the readme and added the credentials to config/i18n-tasks.yml, but running bundle exec i18n-tasks told me to install the deepl-rb gem. Doing that it still complains about authorization failed. Key is working. A curl command and an instance of DeepL in rails console are giving me translations. Using the same settings in i18n-tasks.yml however gives me authorization failed. My config in i18n-tasks.yml: translation: deepl_api_key: "a630.....:fx" [censored] deepl_host: "https://api-free.deepl.com" deepl_version: "v2"
@schepens83 You may need to use the main branch instead of the latest release for this to work
I've just released v0.9.35 from the current main
Thanks for the quick help, that did indeed fix it!
Hey,
I have installed version 0.9.35
and it's not possible to connect with deepl api. I have a pro account, but non of standard or free api is working.
First try:
translation:
deepl_api_key: 24c1ee...
deepl_host: https://api-free.deepl.com
deepl_version: v2
Error:
.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/deepl-rb-2.3.1/lib/deepl/requests/base.rb:65:in validate_response!': Authorization failed. Please supply a valid auth_key parameter. (DeepL::Exceptions::AuthorizationFailed)
Next try
translation:
deepl_api_key: 24c1ee...
deepl_host: https://api.deepl.com
deepl_version: v2
Error:
.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/deepl-rb-2.3.1/lib/deepl/requests/base.rb:68:in validate_response!': Unknown error. (DeepL::Exceptions::RequestError)
Tried with:
i18n-tasks translate-missing --backend=deepl
and bundle exec i18n-tasks translate-missing --backend=deepl
.
I also tried with DEEPL_AUTH_KEY
set in .env file. And this DEEPL_AUTH_KEY=24c1ee... bundle exec i18n-tasks translate-missing --backend=deepl
I remember it worked last time, but it's month ago :)
Thank you for your help
@simonfranzen I don't think your comment is related to this issue in any way? Please open a separate issue.
Hoping to see Rails Credentials supported.
When I even have in a comment in i18n-config.yml
the following:
# <%= Rails.application.credentials.translation.google_api_key %>
While ENV
variables work; they are clunky and insecure, IMO, especially since we do this translations on our own machines. I prefer to just have things hermetically sealed up, at it were.
I imagine the task is not running in context to rails
, though?
I get the following stacktrace
(eval):108:in `file_config': uninitialized constant I18n::Tasks::Configuration::Rails (NameError) from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/configuration.rb:25:in `eval' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/configuration.rb:25:in `file_config' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/configuration.rb:47:in `config=' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/base_task.rb:44:in `initialize' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:68:in `new' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:68:in `base_task' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:49:in `run' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:18:in `block in start' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:211:in `auto_output_coloring' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:17:in `start' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/lib/i18n/tasks/cli.rb:11:in `start' from /Users/wwv/.gem/ruby/3.2.2/gems/i18n-tasks-1.0.13/bin/i18n-tasks:15:in `<top (required)>' from /Users/wwv/.gem/ruby/3.2.2/bin/i18n-tasks:25:in `load' from /Users/wwv/.gem/ruby/3.2.2/bin/i18n-tasks:25:in `<top (required)>' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/cli.rb:492:in `exec' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/cli.rb:28:in `start' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:45:in `block in <top (required)>' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors' from /Users/wwv/.rubies/ruby-3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:33:in `<top (required)>' from /Users/wwv/.rubies/ruby-3.2.2/bin/bundle:25:in `load' from /Users/wwv/.rubies/ruby-3.2.2/bin/bundle:25:in `<main>'
Yeah, i18n-tasks does not load Rails, it's a standalone binary. You could try to figure out how to load just the credentials module, if such a thing is possible.
I couldn't find a way to use encrypted rails credentials to set the deepl api key.
After searching through the source code I found something that isn't documented in the README.md:
That way I could probably inject the deepl_api_key into my pipeline.
But how can I configure the deepl_api_key in development without having to commit it plaintext to git?
Maybe also check something like Rails.application.credentials.deepl_api_key or configure i18n-tasks using a class and an rb-file?