Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upload native strings for translations.

  • Loading branch information...
commit 90de73362e467c615f474081a99c20ac676cb16b 1 parent 0b406b7
Waseem Ahmad authored mmangino committed
View
9 lib/facebooker/parser.rb
@@ -296,6 +296,12 @@ def self.process(data)
end
end
+ class UploadNativeStrings < Parser#:nodoc:
+ def self.process(data)
+ element('intl_uploadNativeStrings_response', data).content.strip
+ end
+ end
+
class PublishActionOfUser < Parser#:nodoc:
def self.process(data)
element('feed_publishActionOfUser_response', data).content.strip
@@ -962,7 +968,8 @@ class Parser
'facebook.dashboard.multiClearNews' => DashboardMultiClearNews,
'facebook.dashboard.publishActivity' => DashboardPublishActivity,
'facebook.dashboard.removeActivity' => DashboardRemoveActivity,
- 'facebook.dashboard.getActivity' => DashboardGetActivity
+ 'facebook.dashboard.getActivity' => DashboardGetActivity,
+ 'facebook.intl.uploadNativeStrings' => UploadNativeStrings
}
end
end
View
15 lib/facebooker/session.rb
@@ -533,6 +533,21 @@ def publish_user_action(bundle_id,data={},target_ids=nil,body_general=nil,story_
post("facebook.feed.publishUserAction", parameters)
end
+ ##
+ # Upload strings in native locale to facebook for translations.
+ #
+ # e.g. facebook_session.upload_native_strings([:text => "Welcome {user}", :description => "Welcome message to currently logged in user."])
+ # returns the number of strings uploaded
+ #
+ # See http://wiki.developers.facebook.com/index.php/Intl.uploadNativeStrings for method options
+ #
+ def upload_native_strings(native_strings)
+ raise ArgumentError, "You must provide strings to upload" if native_strings.nil?
+
+ post('facebook.intl.uploadNativeStrings', :native_strings => Facebooker.json_encode(native_strings)) do |response|
+ response
+ end
+ end
##
# Send email to as many as 100 users at a time
View
12 test/facebooker_test.rb
@@ -292,6 +292,11 @@ def test_can_upload_photo
assert_equal "Under the sunset", @session.user.upload_photo(f).caption
end
+ def test_can_upload_native_strings
+ expect_http_posts_with_responses(example_upload_native_string_xml)
+ assert_equal "1", @session.upload_native_strings([:text => "Hello!", :description => "A common salutation."])
+ end
+
def test_can_get_photo_tags
expect_http_posts_with_responses(example_photo_tags_xml)
assert_instance_of Facebooker::Tag, @session.get_tags(:pids => 97503428461115571 ).first
@@ -1161,6 +1166,13 @@ def example_upload_video_xml
</video_upload_response>
XML
end
+
+ def example_upload_native_string_xml
+ <<-XML
+ <?xml version="1.0" encoding="UTF-8"?>
+ <intl_uploadNativeStrings_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</intl_uploadNativeStrings_response>
+ XML
+ end
def example_revoke_authorization_true
"1"
Please sign in to comment.
Something went wrong with that request. Please try again.