glebm / i18n-tasks

Manage translation and localization with static analysis, for Ruby i18n
http://glebm.github.io/i18n-tasks
MIT License
2.08k stars 264 forks source link

Bad language pair when trying to translate with Google #273

Open Adsidera opened 6 years ago

Adsidera commented 6 years ago

gems/ruby-2.4.2/gems/easy_translate-0.5.0/lib/easy_translate/request.rb:47:in `perform_raw': Bad language pair: en|en (EasyTranslate::EasyTranslateException)

bundle exec i18n-tasks translate-missing
warning: parser/current is loading parser/ruby24, which recognizes
warning: 2.4.0-compliant syntax, but you are running 2.4.2.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
/Users/adsidera/.rvm/gems/ruby-2.4.2/gems/easy_translate-0.5.0/lib/easy_translate/request.rb:47:in `perform_raw': Bad language pair: en|en (EasyTranslate::EasyTranslateException)
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/easy_translate-0.5.0/lib/easy_translate/translation.rb:34:in `request_translations'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/easy_translate-0.5.0/lib/easy_translate/threadable.rb:24:in `block in threaded_process'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/easy_translate-0.5.0/lib/easy_translate/threadable.rb:24:in `map'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/easy_translate-0.5.0/lib/easy_translate/threadable.rb:24:in `threaded_process'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/easy_translate-0.5.0/lib/easy_translate/translation.rb:20:in `translate'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/i18n-tasks-0.9.19/lib/i18n/tasks/google_translation.rb:40:in `fetch_google_translations'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/i18n-tasks-0.9.19/lib/i18n/tasks/google_translation.rb:30:in `block in google_translate_list'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/i18n-tasks-0.9.19/lib/i18n/tasks/google_translation.rb:29:in `each'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/i18n-tasks-0.9.19/lib/i18n/tasks/google_translation.rb:29:in `map'
    from /Users/adsidera/.rvm/gems/ruby-2.4.2/gems/i18n-tasks-0.9.19/lib/i18n/tasks/google_translation.rb:29:in `google_translate_list'
    from /Users/adsidera/.rvm/gem
kleinjm commented 2 years ago

I had this issue come up when I removed a key in my en.yml file but it was still present in all the other language files. Running i18n-tasks remove-unused solved the issue.

I think the problem here is just a very vague error message.

paterlinimatias commented 1 year ago

same here

viktorsmari commented 1 month ago

I have the same issue on 1.0.14 I am using google_translate_api.

I get this error if I do: i18n-tasks translate-missing --verbose

locales inferred from data: en, da, de, en-GB, es, fr, is, it, nl, no, pt, sv
task: translate-missing(locales: ["en", "da", "de", "en-GB", "es", "fr", "is", "it", "nl", "no", "pt", "sv"], from: "en", format: "terminal-table", backend: "google", pattern: nil, arguments: [])
bundler: failed to load command: i18n-tasks (/home/viktor/.rbenv/versions/3.3.5/bin/i18n-tasks)
/home/viktor/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/easy_translate-0.5.1/lib/easy_translate/request.rb:47:in `perform_raw': Bad language pair: en|en (EasyTranslate::EasyTranslateException)
    from /home/viktor/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/easy_translate-0.5.1/lib/easy_translate/translation.rb:34:in `request_translations'
    from /home/viktor/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/easy_translate-0.5.1/lib/easy_translate/threadable.rb:24:in `block in threaded_process'

But if I use -l to list all my languages, it works without issues. i18n-tasks translate-missing -l es is ... works perfectly.

How can I use translate-missing without having to list all my languages?

Bad language pair: en|en

Do I need to skip translating en is that possible in the config?

davidwessman commented 1 month ago

@viktorsmari Could you add your config file?

viktorsmari commented 1 month ago

Output of i18n-tasks config

internal_locale: en
base_locale: en
locales:
- en
- da
- de
- en-GB
- es
- fr
- is
- it
- nl
- 'no'
- pt
- sv
data:
  adapter: I18n::Tasks::Data::FileSystem
  read:
  - config/locales/%{locale}.yml
  write:
  - config/locales/%{locale}.yml
  yaml:
    write:
      line_width: -1
  sort: true
search:
  paths:
  - app/
  relative_exclude_method_name_paths: []
  relative_roots:
  - app/controllers
  - app/helpers
  - app/mailers
  - app/presenters
  - app/views
  scanners:
  - - "::I18n::Tasks::Scanners::RubyAstScanner"
    - only:
      - "*.rb"
  - - "::I18n::Tasks::Scanners::ErbAstScanner"
    - only:
      - "*.html.erb"
  - - "::I18n::Tasks::Scanners::PatternWithScopeScanner"
    - exclude:
      - "*.html.erb"
      - "*.rb"
  ast_matchers: []
  strict: true
  exclude:
  - app/assets/images
  - app/assets/fonts
  - app/assets/videos
  - app/assets/builds
translation:
  google_translate_api_key: xxx