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

Incomplete translations with Google Translate #480

Closed
basicfeatures opened this issue Oct 27, 2022 · 6 comments
Closed

Incomplete translations with Google Translate #480

basicfeatures opened this issue Oct 27, 2022 · 6 comments

Comments

@basicfeatures
Copy link

i18n-tasks (1.0.12) and easy_translate (0.5.1) with Google Translate API (credit card added), only half of my language files seem to get translated:

$ bundle exec i18n-tasks add-missing
$ bundle exec i18n-tasks translate-missing --from=en is
$ cat config/locales/is.yml
---
is:
  account_locked: Reikningnum þínum hefur verið læst vegna óhóflegrar misheppnaðar innskráningartilrauna.
  add_a_comment: Add a comment
  add_new_post: Add new post
  add_photos: Add photos
  age: Age
  anonymous: Anonymous
  are_you_sure: Are you sure
  avatar: Avatar
  back: Back
  bio: Bio
  body: Body
  browse: Browse
  browse_all_restaurants: Browse all restaurants
  cancel: Cancel
  cancel_account: Hætta við reikning
  change_password: Breyta lykilorðinu mínu
  clear_search: Clear search
  [...]

$ cat config/i18n-tasks.yml
base_locale: en

locales: [is, da, fi, nl, de, fr, it, pt]

data:
  read:
    - config/locales/%{locale}.yml
  yaml:
    write:
      # Do not wrap lines at 80 characters
      line_width: -1

search:
  paths:
    - "app/controllers"
    - "app/helpers"
    - "app/presenters"
    - "app/views"

ignore_unused:
  - activerecord.*
  - date.*
  - simple_form.*
  - time.*

translation:
  google_translate_api_key: XXX

Am I missing something obvious?

Many thanks!

@glebm
Copy link
Owner

glebm commented Oct 27, 2022

Sounds like a bug either in i18n-tasks or in easy_translate.

Perhaps you can print out the values being passed around in https://github.com/glebm/i18n-tasks/blob/main/lib/i18n/tasks/translators/base_translator.rb to debug this?

@basicfeatures
Copy link
Author

Yes, I will get around to it ASAP 👍

@basicfeatures
Copy link
Author

I can confirm that https://github.com/glebm/i18n-tasks/blob/main/lib/i18n/tasks/translators/base_translator.rb#L44-L46 returns a proper, full list of translated keys.

On subsequent tries I've been getting:

$ bundle exec i18n-tasks translate-missing --from=en is
#StandWithUkraine
/home/dev/.bundle/ruby/3.1/gems/easy_translate-0.5.1/lib/easy_translate/request.rb:47:in `perform_raw': Invalid Value (EasyTranslate::EasyTranslateException)

At https://github.com/seejohnrun/easy_translate/blob/master/lib/easy_translate/request.rb#L38-L50 I get:

[1] pry(#<EasyTranslate::Translation::TranslationRequest>)> response.code
=> "200"
[2] pry(#<EasyTranslate::Translation::TranslationRequest>)> response.body
=> "{\"data\":{\"translations\":[{\"translatedText\":\"Reikningnum \xC3\xBE\xC3\xADnum hefur veri\xC3\xB0 l\xC3\xA6st vegna \xC3\xB3h\xC3\xB3flegrar misheppna\xC3\xB0ar innskr\xC3\xA1ningartilrauna.\"},{\"translatedText\":\"B\xC3\xA6ta vi\xC3\xB0 athugasemd\"},{\"translatedText\":\"B\xC3\xA6ta vi\xC3\xB0 n\xC3\xBDrri f\xC3\xA6rslu\"},{\"translatedText\":\"B\xC3\xA6ttu vi\xC3\xB0 myndum\"},{\"translatedText\":\"Aldur\"},{\"translatedText\":\"Nafnlaus\"},{\"translatedText\":\"Ertu viss\"} [...]

@basicfeatures
Copy link
Author

Ended up removing config/i18n-tasks.yml and config/locales/* and then just:

export GOOGLE_TRANSLATE_API_KEY=XXX
bundle exec i18n-tasks add-missing
bundle exec i18n-tasks translate-missing --from=en is
bundle exec i18n-tasks translate-missing --from=en da
bundle exec i18n-tasks translate-missing --from=en fi

Somehow that did it 👍

@basicfeatures
Copy link
Author

Actually that's not it :(

@basicfeatures basicfeatures reopened this Nov 8, 2022
@davidwessman
Copy link
Collaborator

@basicfeatures I will close this, but please get back to use if you are still experiencing this issue or find a way to reproduce it.

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

3 participants