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

Refactor project and add Google Drive import&export #22

Closed
wants to merge 61 commits into from

Conversation

AntoineInsa
Copy link

Hi there,

I've found your gem pretty good, and I really like its concept. I wanted to add it to one of my project, but as Google Docs was replace by Google Drive, they changed their API and it was not possible to make any download.
Here's what I did

  • Add a Google Drive module (using https://github.com/gimite/google-drive-ruby)
    • Both username/password and oauth authentication
    • file upload and download, including spreadsheets
  • Rename and modify translations.rb into translations_importer.rb
    • translations.rb into translations_importer.rb
    • translation_file_export.rb into translations_exporter.rb
    • csv_to_yaml.rb into sub_translation_converter.rb
    • store_translations.rake into manage_translations.rb
  • Move code from the rake task to translation_manager.rb (parent of both TranlsationsImporter and TranslationExporter to avoid duplicated code)
  • Move methods to private or protected whenever it was needed (including attr_accessors)
  • Rename module to fit gems specifications
  • Refactor missing_key_finder
  • Change the README for new functionalities
  • Update the gemspec for a new release
  • Update tests for the new versions
  • Enable oauth and store token (in translations.yml?) to avoid having to ask user to login every time they run a task

And more

  • sort keys by alphabetic order (could be done on Google Drive as well)
  • try if o_auth works as advertised on google-drive
  • create new directories and files on initialization
  • parse and convert following caracters
    • boolean (true/false become 'true'/'false')
    • numbers (3 becomes '3')
    • empty string ('' becomes nil), could be replaced by '_' in Google Spreadsheet
  • specify ENV options when running tasks (given locales, or sub-translations/file pattern) without having to change their translations.yml
    • given locales only
    • given sub-translations/file pattern only
    • not removing tmp files
    • not downloading/uploading files
  • Add "debugging mode" for file upload to google docs when having a xml error
    • try to update column by column (ie. one locale after the other) to pinpoint the upload error

You could give the gem a try by adding the following to your gemfile:

gem 'i18n-docs', :github => 'AntoineInsa/i18n-docs', :ref => '62881b972ed35e6f9891e8aa0da4ff0082255798'

And here is what the new translations.yml looks like. Note that you can specify google-drive spreadsheet titles directly, without any url. You need to specify as well a way to authenticate to google, either by username/password or by oauth.

files:
  standard.yml: "google-drive|standard.csv"
  event.yml: "www.my-special-url.com/export?format=csv"

google_drive_credentials:
  classic_auth:
    username: "xxxx"
    password: "yyyy"
  o_auth:
    client_id: "wwww"
    client_secret: "zzzz"

or using oauth (see https://github.com/gimite/google-drive-ruby#how-to-use for more details)

files:
  standard.yml: "google-drive|standard.csv"
  event.yml: "www.my-special-url.com/export?format=csv"

google_drive_credentials:
  o_auth:
    client_id: "wwww"
    client_secret: "zzzz"

I hope that even if I did a mess and move things around, I've still helped to go forward.
Let me know what you think about it. If you think it is still possible to merge it with modifications, I'll be happy to do them. On the other hand, if this version is too far from what you expect the gem to do, I can continue on my own and publish myself, but it would to bad.

Hope to hear from you, and have a good week-end!

AntoineInsa and others added 30 commits November 28, 2014 14:31
Deleted TranslationExporter, TranslationImporter and
SubTranslationConverter to only have a collection manager
(TranslationManager) and a collection element (SubTranslation)
…o preserve values with commas and colons"

This reverts commit 137718e.
Add oauth and google worksheets
@AntoineInsa
Copy link
Author

@somebox @batiste could you have a look at this PR, code review it, and if everything is fine, merge it into master? You can have a look as well here https://github.com/AntoineInsa/i18n-docs (for badges, tests and documentation). The next step would be to update the gem on rubygems if that works for you.
Cheers, Antoine

@skaestle
Copy link
Contributor

Hi @AntoineInsa. What an epic pull request. Thanks a lot for the effort you've put into this! I'm currently going to draft up a new release because we're lagging back quite a bit with the released version (additionally there is a bit of chaos going on with the versions).

Two feedbacks:

  • the PR is really big, it would be much much easier to move forward with multiple PRs each having a clear focus (refactor / add google drive /
  • the functionality breaks down if you do not have a config file that contains the key 'google_drive_credentials'. In my opinion the gem should keep working even if the config file only contains the files key (this way you can keep on using arbitrary csv files from wherever the link points to)

@skaestle
Copy link
Contributor

i took the liberty and created a PR just for the module rename (which will hopefully make your work easier).
that should get merged into v.0.0.10 (which I intend to release before the weekend)

@skaestle
Copy link
Contributor

@AntoineInsa
Copy link
Author

@skaestle thanks a lot for coming back to me! I really liked the concept of i18n-docs and our project required to deal with a lot of different languages, and I didn't feel to use https://www.localeapp.com/, though it could be possible to integrate it as a different translation source (but not in a close future, at least for me!). Here's the translation tool comparison I did one year ago http://stackoverflow.com/questions/3201317/any-suggestion-for-ruby-on-rails-multilingual-translation-management

I will be busy at work, but I really hope that we can work together to make i18n-docs usable and handy again, as its original intent. If you have time, I invite you to read my master README https://github.com/AntoineInsa/i18n-docs/blob/master/README.md to get an idea of what problematic I've tried to solve.

I've created a new pull to address the 'google_drive_credentials' option, and some others small problems as well: AntoineInsa#10. I still have to remove the dependency to the config file if not existing.

Let me know how you'd like to see the big PR split into smaller ones, and I'll try to adapt if possible, to facilitate discussion and integration.

BTW, do you have owner access to the gem on rubygems? It will help to publish it there once we'll be done!

Let's keep in touch and make it rock!

@AntoineInsa
Copy link
Author

@skaestle I've just noticed new code on https://github.com/local-ch/i18n-docs/releases/tag/v0.0.10 that I haven't seen before. I'll see if I can solve the conflicts, and I'll keep you posted.

It will use the same structure, wherever the options are coming from
(ruby_options, ENV, config).
@skaestle
Copy link
Contributor

@AntoineInsa thanks for the update. yeah. sorry to spring all the new code on the project. I needed to integrate a branch we had used privately. necessary evil to get back on track with this gem.

About splitting this PR up:

  1. All the refactorings/renamings (introducing the new classes to make google drive api possible)
  2. all changes in regards to adding google drive api

HTH

@elsurudo
Copy link

This looks awesome. Any chance of getting this merged in? If not, @AntoineInsa how is your branch working for you? Which version of Rails have you tested it with etc.?

@AntoineInsa
Copy link
Author

@elsurudo my branch is working like a charm, we're still using it at work, for both Rails (still 3 though, not sure for 4), and non Rails projects (see below).
https://github.com/Anthony-Gaudino/jekyll-multiple-languages-plugin
https://github.com/fnando/i18n-js

@schmijos
Copy link
Member

schmijos commented Oct 3, 2018

Hey @AntoineInsa is this still a thing? There are still some conflicts.

@coorasse coorasse assigned schmijos and unassigned AntoineInsa Dec 1, 2022
@schmijos
Copy link
Member

schmijos commented Dec 2, 2022

Closing this due to inactivity.

@schmijos schmijos closed this Dec 2, 2022
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

Successfully merging this pull request may close these issues.

None yet

6 participants