ripl-i18n 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.summary = "A ripl plugin que habla ta langue"
12
12
  s.description = "A ripl plugin that translates ripl to your preferred language."
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
- s.add_dependency 'ripl', '~> 0.4.0'
14
+ s.add_dependency 'ripl', '~> 0.4.1'
15
15
  s.add_development_dependency 'bacon', '>= 1.1.0'
16
16
  s.add_development_dependency 'bacon-bits'
17
17
  s.rubyforge_project = 'tagaholic'
data/CHANGELOG.rdoc CHANGED
@@ -1,2 +1,6 @@
1
+ == 0.2.0
2
+ * Auto-detect locale using $LANG
3
+ * More translations
4
+
1
5
  == 0.1.0
2
6
  * Initial release!
data/README.rdoc CHANGED
@@ -6,7 +6,11 @@ A ripl plugin that translates ripl to your preferred language.
6
6
  Add to your ~/.riplrc:
7
7
 
8
8
  require 'ripl/i18n'
9
- # Use your language: :es maps to es.yml
9
+
10
+ If a locale exists for your language and is set via your shell variable $LANG,
11
+ this plugin automatically uses it. Otherwise, explicitly set your language with:
12
+
13
+ # :es maps to es.yml
10
14
  Ripl.config[:i18n_locale] = :es
11
15
 
12
16
  If you want to load and use your own locale:
@@ -19,12 +23,14 @@ If you want to load and use your own locale:
19
23
  As I would like to make ripl available in as many languages as possible,
20
24
  please do add your own! Here's all you have to do:
21
25
 
22
- * Fork this project. It's dead-easy to do this with the {fork and edit
23
- button}[https://github.com/blog/844-forking-with-the-edit-button].
26
+ * Fork this project.
24
27
  * Create a .yml file under lib/ripl/i18n/locales/ for your language.
25
28
  If you're not sure what locale to use for your language, {see
26
29
  some examples}[https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale].
27
30
  * Be sure to translate all the keys in lib/ripl/i18n/locales/en.yml.
28
31
 
32
+ == Credits
33
+ * janlelis for auto locale + de.yml
34
+
29
35
  == Inspiration
30
36
  http://yugui.jp/articles/863
data/deps.rip CHANGED
@@ -1 +1 @@
1
- ripl ~>0.4.0
1
+ ripl ~>0.4.1
@@ -12,3 +12,7 @@ load_rc: Fehler beim Laden von %s
12
12
  parse_option: Ungültige Option
13
13
  prompt: Fehler beim Erstellen des Prompts
14
14
  print_result: Fehler beim Ergebnis ausgeben
15
+ usage: Benutzung
16
+ options: Optionen
17
+ args: ARGUMENTE
18
+ command: BEFEHL
@@ -13,3 +13,7 @@ load_rc: Error while loading %s
13
13
  parse_option: invalid option
14
14
  prompt: Error while creating prompt
15
15
  print_result: Error while printing result
16
+ usage: Usage
17
+ options: Options
18
+ args: ARGS
19
+ command: COMMAND
@@ -12,3 +12,7 @@ load_rc: Ocurrió un error mientras cargando %s
12
12
  parse_option: opción inválida
13
13
  prompt: Ocurrió un error mientras creando prompt
14
14
  print_result: Ocurrió un error impremiendo el resultado
15
+ usage: Uso
16
+ options: Opciones
17
+ args: ARGUMENTOS
18
+ command: COMANDO
@@ -1,5 +1,5 @@
1
1
  module Ripl
2
2
  module I18n
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
data/lib/ripl/i18n.rb CHANGED
@@ -32,6 +32,12 @@ module Ripl::I18n
32
32
  end
33
33
  end
34
34
 
35
+ def default_locale
36
+ ( lang = ENV["LANG"] && ENV["LANG"][0,2] ) &&
37
+ File.exists?( File.dirname(__FILE__) + "/i18n/locales/#{lang}.yml" ) ?
38
+ lang.to_sym : :en
39
+ end
40
+
35
41
  def internationalize
36
42
  Ripl::Runner::OPTIONS.each { |opt, val| locales[:en][opt] = val[1] }
37
43
  Ripl::Runner::OPTIONS.instance_eval %[
@@ -47,5 +53,5 @@ module Ripl::I18n
47
53
  self.locales = {}
48
54
  end
49
55
 
50
- Ripl.config[:i18n_locale] ||= :en
56
+ Ripl.config[:i18n_locale] ||= Ripl::I18n.default_locale
51
57
  Ripl::I18n.init
data/test/i18n_test.rb CHANGED
@@ -33,7 +33,7 @@ describe Ripl::I18n do
33
33
  end
34
34
 
35
35
  it "with the correct number of translations" do
36
- Ripl::I18n.locales.values.each {|e| e.size.should == 13 }
36
+ Ripl::I18n.locales.values.each {|e| e.size.should == 17 }
37
37
  end
38
38
  end
39
39
 
@@ -59,42 +59,61 @@ describe Ripl::I18n do
59
59
  end
60
60
  after_all { Ripl.config[:i18n_locale] = :en }
61
61
  end
62
+ end
62
63
 
63
- describe ".translate" do
64
- before_all { Ripl::I18n.init }
65
- it "returns translation missing message for missing translation" do
66
- Ripl::I18n.translate('blah').should == "Translation missing: en.blah"
67
- end
64
+ describe ".translate" do
65
+ before_all { Ripl::I18n.init }
66
+ it "returns translation missing message for missing translation" do
67
+ Ripl::I18n.translate('blah').should == "Translation missing: en.blah"
68
+ end
68
69
 
69
- it "handles locales that haven't been defined yet" do
70
- Ripl.config[:i18n_locale] = :zzz
71
- Ripl::I18n.translate('-f').should =~ /^Translation missing/
72
- Ripl.config[:i18n_locale] = :en
73
- end
70
+ it "handles locales that haven't been defined yet" do
71
+ Ripl.config[:i18n_locale] = :zzz
72
+ Ripl::I18n.translate('-f').should =~ /^Translation missing/
73
+ Ripl.config[:i18n_locale] = :en
74
74
  end
75
+ end
75
76
 
76
- describe ".load" do
77
- def fixture(name)
78
- File.dirname(__FILE__) +"/fixtures/#{name}.yml"
79
- end
77
+ describe ".load" do
78
+ def fixture(name)
79
+ File.dirname(__FILE__) +"/fixtures/#{name}.yml"
80
+ end
80
81
 
81
- before { Ripl::I18n.locales = {} }
82
+ before { Ripl::I18n.locales = {} }
82
83
 
83
- it "prints warning for locale file with invalid syntax" do
84
- capture_stderr {
85
- Ripl::I18n.load(fixture('invalid_syntax'))
86
- }.should =~ /^Error while loading/
87
- end
84
+ it "prints warning for locale file with invalid syntax" do
85
+ capture_stderr {
86
+ Ripl::I18n.load(fixture('invalid_syntax'))
87
+ }.should =~ /^Error while loading/
88
+ end
88
89
 
89
- it "sets locale using basename of locale file" do
90
- Ripl::I18n.load fixture('rb')
91
- Ripl::I18n.locales[:rb].should == {'-f' => 'woah dudez' }
92
- end
90
+ it "sets locale using basename of locale file" do
91
+ Ripl::I18n.load fixture('rb')
92
+ Ripl::I18n.locales[:rb].should == {'-f' => 'woah dudez' }
93
+ end
93
94
 
94
- it "skips locale if invalid basename" do
95
- Ripl::I18n.load fixture('')
96
- Ripl::I18n.locales.should.be.empty
97
- end
95
+ it "skips locale if invalid basename" do
96
+ Ripl::I18n.load fixture('')
97
+ Ripl::I18n.locales.should.be.empty
98
+ end
99
+ end
100
+
101
+ describe '.default_locale' do
102
+ before { ENV['LANG'] = nil }
103
+
104
+ it "returns :en if no $LANG" do
105
+ ENV['LANG'] = nil
106
+ Ripl::I18n.default_locale.should == :en
107
+ end
108
+
109
+ it "returns :en if $LANG doesn't have an existing yml file" do
110
+ ENV['LANG'] = 'zzz'
111
+ Ripl::I18n.default_locale.should == :en
112
+ end
113
+
114
+ it "returns auto-detected locale if $LANG does have an existing yml file" do
115
+ ENV['LANG'] = 'es-PE'
116
+ Ripl::I18n.default_locale.should == :es
98
117
  end
99
118
  end
100
119
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripl-i18n
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.0
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
6
11
  platform: ruby
7
12
  authors:
8
13
  - Gabriel Horner
@@ -21,7 +26,12 @@ dependencies:
21
26
  requirements:
22
27
  - - ~>
23
28
  - !ruby/object:Gem::Version
24
- version: 0.4.0
29
+ hash: 13
30
+ segments:
31
+ - 0
32
+ - 4
33
+ - 1
34
+ version: 0.4.1
25
35
  type: :runtime
26
36
  version_requirements: *id001
27
37
  - !ruby/object:Gem::Dependency
@@ -32,6 +42,11 @@ dependencies:
32
42
  requirements:
33
43
  - - ">="
34
44
  - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 1
48
+ - 1
49
+ - 0
35
50
  version: 1.1.0
36
51
  type: :development
37
52
  version_requirements: *id002
@@ -43,6 +58,9 @@ dependencies:
43
58
  requirements:
44
59
  - - ">="
45
60
  - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
46
64
  version: "0"
47
65
  type: :development
48
66
  version_requirements: *id003
@@ -86,17 +104,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
104
  requirements:
87
105
  - - ">="
88
106
  - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
89
110
  version: "0"
90
111
  required_rubygems_version: !ruby/object:Gem::Requirement
91
112
  none: false
92
113
  requirements:
93
114
  - - ">="
94
115
  - !ruby/object:Gem::Version
116
+ hash: 23
117
+ segments:
118
+ - 1
119
+ - 3
120
+ - 6
95
121
  version: 1.3.6
96
122
  requirements: []
97
123
 
98
124
  rubyforge_project: tagaholic
99
- rubygems_version: 1.6.1
125
+ rubygems_version: 1.3.7
100
126
  signing_key:
101
127
  specification_version: 3
102
128
  summary: A ripl plugin que habla ta langue