Skip to content

Commit

Permalink
Use translation in handler actions
Browse files Browse the repository at this point in the history
  • Loading branch information
josacar committed Apr 4, 2014
1 parent a00be55 commit fd41dd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/lita/handlers/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Jobs < Handler
def job_list(response)
jobs = ::Twke::JobManager.list
if jobs[:active].length == 0 && jobs[:finished].length == 0
response.reply("No active or finished jobs.")
response.reply(t('job_list.no_job'))
else
str = ''
str << active_jobs(jobs[:active]) << finished_jobs(jobs[:finished])
Expand Down Expand Up @@ -45,9 +45,9 @@ def job_output(response)
def active_jobs(jobs)
"".tap do |str|
if jobs.length > 0
str << "> Active Jobs:\n"
str << "> #{t('job_list.active_jobs')}:\n"
jobs.each do |job|
str << " ID: %d Cmd: '%s' Started: %s\n" %
str << " ID: %d Cmd: '%s' #{t('job_list.started')}: %s\n" %
[job.pid, job.command, job.start_time.to_s]
end
str << "\n"
Expand All @@ -58,9 +58,9 @@ def active_jobs(jobs)
def finished_jobs(jobs)
"".tap do |str|
if jobs.length > 0
str << "> Finished Jobs:\n"
str << "> #{t('job_list.finished_jobs')}:\n"
jobs.each do |job|
str << " ID: %d Cmd: '%s' Started: %s, Finished: %s\n" %
str << " ID: %d Cmd: '%s' #{t('job_list.started')}: %s, #{t('job_list.finished')}: %s\n" %
[job.pid, job.command, job.start_time.to_s, job.end_time.to_s]
end
end
Expand All @@ -77,7 +77,7 @@ def in_job(response)
if job
yield(job)
else
response.reply("No such job: #{job_id}")
response.reply(t('in_job.no_job', job_id: job_id))
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ en:
job_kill: Kill an active job
job_tail: List last output for a job
job_output: List output for a job
job_list:
no_job: No active or finished jobs.
active_jobs: Active Jobs
started: Started
finished_jobs: Finished Jobs
finished: Finished
in_job:
no_job: "No such job: %{job_id}"

0 comments on commit fd41dd3

Please sign in to comment.