Skip to content

Commit

Permalink
Merge pull request moredip#63 from dnonnenm/master
Browse files Browse the repository at this point in the history
Frank is not working with an operating system not using English as system language
  • Loading branch information
moredip committed Jan 6, 2012
2 parents 0c71813 + f24c3d4 commit ad4ce02
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 8 deletions.
1 change: 1 addition & 0 deletions gem/frank-cucumber.gemspec
Expand Up @@ -20,6 +20,7 @@ Gem::Specification.new do |s|
s.add_dependency( "cucumber" )
s.add_dependency( "rspec", [">=2.0"] )
s.add_dependency( "sim_launcher" )
s.add_dependency( "i18n" )
s.add_dependency( "plist" )
s.add_dependency( "json" ) # TODO: figure out how to be more permissive as to which JSON gems we allow
end
17 changes: 9 additions & 8 deletions gem/lib/frank-cucumber/frank_helper.rb
@@ -1,5 +1,6 @@
require 'net/http'
require 'json'
require 'frank-cucumber/frank_localize'

module Frank module Cucumber

Expand Down Expand Up @@ -219,37 +220,37 @@ def simulator_hardware_menu_press( menu_label )
%x{osascript<<APPLESCRIPT
activate application "iPhone Simulator"
tell application "System Events"
click menu item "#{menu_label}" of menu "Hardware" of menu bar of process "iPhone Simulator"
click menu item "#{menu_label}" of menu "#{Localize.t(:hardware)}" of menu bar of process "#{Localize.t(:iphone_simulator)}"
end tell
APPLESCRIPT}
end

def press_home_on_simulator
simulator_hardware_menu_press "Home"
simulator_hardware_menu_press Localize.t(:home)
end

def rotate_simulator_left
simulator_hardware_menu_press "Rotate Left"
simulator_hardware_menu_press Localize.t(:rotate_left)
end

def rotate_simulator_right
simulator_hardware_menu_press "Rotate Right"
simulator_hardware_menu_press Localize.t(:rotate_right)
end

def shake_simulator
simulator_hardware_menu_press "Shake Gesture"
simulator_hardware_menu_press Localize.t(:shake_gesture)
end

def simulate_memory_warning
simulator_hardware_menu_press "Simulate Memory Warning"
simulator_hardware_menu_press Localize.t(:simulate_memory_warning)
end

def toggle_call_status_bar
simulator_hardware_menu_press "Toggle In-Call Status Bar"
simulator_hardware_menu_press Localize.t(:toggle_call_status_bar)
end

def simulate_hardware_keyboard
simulator_hardware_menu_press "Simulate Hardware Keyboard"
simulator_hardware_menu_press Localize.t(:simulate_hardware_keyboard)
end
end

Expand Down
31 changes: 31 additions & 0 deletions gem/lib/frank-cucumber/frank_localize.rb
@@ -0,0 +1,31 @@
require 'i18n'

module Frank
module Cucumber
module Localize

def self.system_locale
case ENV['LANG']
when /^fr_/
:fr
else
:en
end
end

def self.load_translations
if I18n.backend.send(:translations).size == 0
I18n.locale = self.system_locale
I18n.load_path = [ File.join(File.dirname(__FILE__), 'localize.yml') ]
I18n.backend.load_translations
end
end

def self.t(key)
self.load_translations
I18n.t(key)
end

end
end
end
21 changes: 21 additions & 0 deletions gem/lib/frank-cucumber/localize.yml
@@ -0,0 +1,21 @@
en:
iphone_simulator: iPhone Simulator
hardware: Hardware
home: Home
rotate_left: Rotate Left
rotate_right: Rotate Right
shake_gesture: Shake Gesture
simulate_memory_warning: Simulate Memory Warning
toggle_in_call_status_bar: Toggle In-Call Status Bar
simulate_hardware_keyboard: Simulate Hardware Keyboard

fr:
iphone_simulator: Simulateur iOS
hardware: Matériel
home: Écran d’accueil
rotate_left: Rotation à gauche
rotate_right: Rotation à droite
shake_gesture: Secousse
simulate_memory_warning: Simuler un avertissement de mémoire
toggle_in_call_status_bar: Afficher/Masquer la barre d'état d'appel en cour
simulate_hardware_keyboard: Simuler un clavier matériel

0 comments on commit ad4ce02

Please sign in to comment.