i18n-docs
i18n-docs copied to clipboard
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
- [x] Change the README for new functionalities
- [x] Update the gemspec for a new release
- [x] Update tests for the new versions
- [x] Enable oauth and store token (in translations.yml?) to avoid having to ask user to login every time they run a task
And more
- [x] sort keys by alphabetic order (could be done on Google Drive as well)
- [x] try if o_auth works as advertised on google-drive
- [x] 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
- [x] 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!
@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
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)
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)
FYI: https://github.com/local-ch/i18n-docs/releases/tag/v0.0.10
@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: https://github.com/AntoineInsa/i18n-docs/pull/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!
@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.
@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:
- All the refactorings/renamings (introducing the new classes to make google drive api possible)
- all changes in regards to adding google drive api
HTH
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.?
@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
Hey @AntoineInsa is this still a thing? There are still some conflicts.
Closing this due to inactivity.