Skip to content

Instantly share code, notes, and snippets.

@chrismcg
Created May 2, 2012 16:25
Show Gist options
  • Save chrismcg/2577943 to your computer and use it in GitHub Desktop.
Save chrismcg/2577943 to your computer and use it in GitHub Desktop.
# To send to LA
@my_db_records.each do |r|
LocaleApp::MissingTranslations.add('en', "sometable.some_field.#{id}", r.content)
end
LocaleApp.sender.post_missing_translations
# This will post them up to the app. (They go onto resque first so there may be a short delay before they appear)
#To pull the translations down you could do something like (untested):
class MyPoller
include ::Localeapp::ApiCall
def poll
api_call :translations,
:url_options => { :query => { :updated_at => updated_at }},
:success => :handle_success,
:failure => :handle_failure,
:max_connection_attempts => 1
end
def handle_success(response)
data = Localeapp.load_yaml(response)
# loop through the updated data and push back to your database
end
def handle_failure(response)
# something
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment