Permalink
Browse files

Migrate stream subcommands to locales.

  • Loading branch information...
1 parent 734bb2a commit 3335fd79632fc9bad978368407a5e8d1dcb48a7c @amerine committed May 29, 2012
Showing with 27 additions and 13 deletions.
  1. +12 −0 lib/t/locales/en.yml
  2. +15 −13 lib/t/stream.rb
View
@@ -349,3 +349,15 @@ en:
stream:
desc: "Commands for streaming Tweets."
+
+ all:
+ desc: "Stream a random sample of all Tweets (Control-C to stop)"
+
+ search:
+ desc: "Stream Tweets that contain specified keywords, joined with logical ORs (Control-C to stop)"
+
+ timeline:
+ desc: "Stream your timeline (Control-C to stop)"
+
+ users:
+ desc: "Stream Tweets either from or in reply to specified users (Control-C to stop)"
View
@@ -5,8 +5,10 @@ module T
autoload :Printable, 't/printable'
autoload :RCFile, 't/rcfile'
autoload :Search, 't/search'
+ autoload :Translations, "t/translations"
class Stream < Thor
include T::Printable
+ include T::Translations
STATUS_HEADINGS_FORMATTING = [
"%-18s", # Add padding to maximum length of a Tweet ID
@@ -20,9 +22,9 @@ def initialize(*)
@rcfile = RCFile.instance
end
- desc "all", "Stream a random sample of all Tweets (Control-C to stop)"
- method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
- method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
+ desc "all", I18n.t("tasks.stream.all.desc")
+ method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => I18n.t("tasks.common_options.csv")
+ method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => I18n.t("tasks.common_options.long")
def all
require 'tweetstream'
client.on_inited do
@@ -52,7 +54,7 @@ def all
client.sample
end
- desc "matrix", "Unfortunately, no one can be told what the Matrix is. You have to see it for yourself."
+ desc "matrix", I18n.t("tasks.matrix.desc")
def matrix
require 'tweetstream'
client.on_timeline_status do |status|
@@ -61,9 +63,9 @@ def matrix
client.sample
end
- desc "search KEYWORD [KEYWORD...]", "Stream Tweets that contain specified keywords, joined with logical ORs (Control-C to stop)"
- method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
- method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
+ desc "search KEYWORD [KEYWORD...]", I18n.t("tasks.stream.search.desc")
+ method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => I18n.t("tasks.common_options.csv")
+ method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => I18n.t("tasks.common_options.long")
def search(keyword, *keywords)
keywords.unshift(keyword)
require 'tweetstream'
@@ -89,9 +91,9 @@ def search(keyword, *keywords)
client.track(keywords)
end
- desc "timeline", "Stream your timeline (Control-C to stop)"
- method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
- method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
+ desc "timeline", I18n.t("tasks.stream.timeline.desc")
+ method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => I18n.t("tasks.common_options.csv")
+ method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => I18n.t("tasks.common_options.long")
def timeline
require 'tweetstream'
client.on_inited do
@@ -116,9 +118,9 @@ def timeline
client.userstream
end
- desc "users USER_ID [USER_ID...]", "Stream Tweets either from or in reply to specified users (Control-C to stop)"
- method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
- method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
+ desc "users USER_ID [USER_ID...]", I18n.t("tasks.stream.users.desc")
+ method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => I18n.t("tasks.common_options.csv")
+ method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => I18n.t("tasks.common_options.long")
def users(user_id, *user_ids)
user_ids.unshift(user_id)
user_ids.map!(&:to_i)

0 comments on commit 3335fd7

Please sign in to comment.