Skip to content

Commit

Permalink
More work on APSTUD-4212 Externalize UI strings in bundle-dev ruble
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Mar 15, 2012
1 parent eb1490f commit 998c73c
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 25 deletions.
5 changes: 2 additions & 3 deletions bundle.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
require 'ruble'
require 'ruble/platform'

bundle do |bundle|
bundle.author = "Christopher Williams, Andrew Shebanow"
bundle.copyright = '(C) Copyright 2011 Appcelerator Inc. Distributed under the MIT license.'
bundle.display_name = 'Bundle Development'
bundle.description = "A bundle to help develop your own bundles, grab 3rd-party bundles, convert TextMate bundles, and see scope/theme information."
bundle.display_name = t(:toplevel_menu)
bundle.description = t(:bundle_description)
bundle.repository = 'git://github.com/aptana/bundle-dev.ruble.git'

# This command should show regardless of scope, so we don't define one.
Expand Down
6 changes: 3 additions & 3 deletions commands/convert_bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
FileUtils.makedirs(bundles_dir)

# Open a dialog asking for location of textmate bundle
bundle_to_convert_path = Ruble::UI.request_file(:only_directories => false, :title => 'Select bundle to convert', :directory => '~/Library/Application Support/TextMate/Bundles')
bundle_to_convert_path = Ruble::UI.request_file(:only_directories => false, :title => t(:select_bundle_to_convert), :directory => '~/Library/Application Support/TextMate/Bundles')

context.exit_show_tool_tip("No bundle selected") if bundle_to_convert_path.nil? || bundle_to_convert_path.empty?
context.exit_show_tool_tip(t(:no_bundle_selected)) if bundle_to_convert_path.nil? || bundle_to_convert_path.empty?

# Now set up variables to choose input/output
bundle_to_convert = java.io.File.new(bundle_to_convert_path)
Expand All @@ -29,7 +29,7 @@
proj = Ruble::Project.create(base_name, :location => converted_bundle_path)
proj.open

"Please note that this bundle conversion process is really meant as a starting point for converting bundles over to rubles.\nNearly every bundle will need additional work, and often many commands will work better or require less code if converted from shell scripts to in-process ruby (block invocation).\nSee https://radrails.tenderapp.com/faqs/radrails-3/ruble-programming-guide"
t(:bundle_convert_msg)
end
end
end
14 changes: 8 additions & 6 deletions commands/flush_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
bundle_dir = File.join(bundles_dir, filename)
bundle_dir = File.readlink(bundle_dir) if File.symlink?(bundle_dir)
Dir.chdir(bundle_dir) do |dir|
cache_file = File.join(Dir.pwd, 'cache.yml')
begin
File.delete(cache_file)
str << "Deleted: #{cache_file}\n"
rescue
# ignore?
Dir.glob("cache*.yml").each do |cache_filename|
cache_file = File.join(Dir.pwd, cache_filename)
begin
File.delete(cache_file)
str << t(:deleted_0, :cache_file => cache_file)
rescue
# ignore?
end
end
end
end
Expand Down
13 changes: 6 additions & 7 deletions commands/install_bundle.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'ruble'
#require 'ruble/project'

# HEY! Want your Ruble included here? Send us a pull request on github!
RubleInfo = Struct.new(:display_name, :directory_name, :repository) unless defined?(RubleInfo)
Expand Down Expand Up @@ -36,17 +35,17 @@
options = {}
options[:items] = uninstalled_rubles
if uninstalled_rubles.length == 1
options[:button1]= "Install"
options[:title] = "Install Bundle"
options[:prompt] = "Install #{items.first} Bundle?"
options[:button1]= t(:install)
options[:title] = t(:install_bundle)
options[:prompt] = t(:install_0_bundle, :bundle_name =>items.first)
chosen = Ruble::UI.request_confirmation(options) ? uninstalled_rubles.first : nil
elsif uninstalled_rubles.length == 0
context.exit_show_tool_tip("There are no bundles to install.")
context.exit_show_tool_tip(t(:no_bundles_to_install))
else
options[:title] = "Select Bundle to Install"
options[:title] = t(:select_bundle_to_install)
chosen = Ruble::UI.request_item(options)
end
context.exit_show_tool_tip("No Bundle selected") if chosen.nil?
context.exit_show_tool_tip(t(:no_bundle_selected)) if chosen.nil?

chosen_ruble = INSTALLABLE_RUBLES.select {|r| r.display_name == chosen}.first

Expand Down
2 changes: 1 addition & 1 deletion commands/show_theme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
matching_selector = com.aptana.scope.ScopeSelector.bestMatch(selectors, scope)
matching_rule = rules.find {|rule| rule.getScopeSelector.equals(matching_selector) }

"Scope: #{scope}\nRule: #{matching_rule.to_s}"
t(:scope_0_rule_0, :scope => scope, :rule => matching_rule.to_s)
end
end

6 changes: 3 additions & 3 deletions commands/validate_snippets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@

# Spit out failures
if failures.size > 0
puts "The following snippets failed validation."
puts t(:snippets_failed_validation)
failures.each do |bundle_path, fails|
puts "Bundle: #{bundle_path}"
puts t(:bundle_0, :bundle_path => bundle_path)
puts " #{fails.join("\n ")}\n\n"
end
else
puts "No snippets failed validation"
puts t(:no_snippets_failed_validation)
end
nil
end
Expand Down
16 changes: 16 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
en:
toplevel_menu: "Bundle Development"
bundle_description: "A bundle to help develop your own bundles, grab 3rd-party bundles, convert TextMate bundles, and see scope/theme information."
show_scope: "Show Scope"
copy_scope: "Copy Scope"
show_scope_and_theme_rule: "Show Scope and Matching Theme Rule"
Expand Down Expand Up @@ -28,3 +29,18 @@ en:
updating_user_bundles_title: "Updating user bundles..."
updating_rubles: "Updating rubles"
updating_ruble_filename: "Updating %{filename}"
ruble_template: "Ruble Template"
ruble_template_description: "A simple Ruble sample"
snippets_failed_validation: "The following snippets failed validation."
bundle_0: "Bundle: %{bundle_path}"
no_snippets_failed_validation: "No snippets failed validation"
deleted_0: "Deleted: %{cache_file}\n"
scope_0_rule_0: "Scope: %{scope}\nRule: %{rule}"
select_bundle_to_convert: 'Select bundle to convert'
no_bundle_selected: "No bundle selected"
bundle_convert_msg: "Please note that this bundle conversion process is really meant as a starting point for converting bundles over to rubles.\nNearly every bundle will need additional work, and often many commands will work better or require less code if converted from shell scripts to in-process ruby (block invocation).\nSee https://radrails.tenderapp.com/faqs/radrails-3/ruble-programming-guide"
install: "Install"
install_0_bundle: "Install %{bundle_name} Bundle?"
no_bundles_to_install: "There are no bundles to install."
select_bundle_to_install: "Select Bundle to Install"

4 changes: 2 additions & 2 deletions templates/template.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'ruble'

project_template "Ruble Template" do |t|
project_template t(:ruble_template) do |t|
t.type = :ruby
t.location = "templates/ruble_template.zip"
t.description = "A simple Ruble sample"
t.description = t(:ruble_template_description)
t.replace_parameters = true
end

0 comments on commit 998c73c

Please sign in to comment.