local-ch/i18n-docs — pull request #22 by AntoineInsa (2014-11-29 02:07:41+00:00)
Title: Refactor project and add Google Drive import&export

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
- [x] Add a Google Drive module (using https://github.com/gimite/google-drive-ruby)
- [x] Both username/password and oauth authentication
- [x] file upload and download, including spreadsheets
- [x] Rename and modify translations.rb into translations_importer.rb
- [x] translations.rb into translations_importer.rb
- [x] translation_file_export.rb into translations_exporter.rb
- [x] csv_to_yaml.rb into sub_translation_converter.rb
- [x] store_translations.rake into manage_translations.rb
- [x] Move code from the rake task to translation_manager.rb (parent of both TranlsationsImporter and TranslationExporter to avoid duplicated code)
- [x] Move methods to private or protected whenever it was needed (including attr_accessors)
- [x] 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

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!