gettext_simple 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d656c6c979ce8bab9ed66ae11e06f58b3aa00c9
4
- data.tar.gz: 3f32570dc0f6cf2469e40f4e3359d78b9cba8fc0
3
+ metadata.gz: c175117d02717c98b5d0e0ca0cc2209e55454bdb
4
+ data.tar.gz: 779101b352b8f53452f39fbb3fa75f06b2e516d1
5
5
  SHA512:
6
- metadata.gz: 23839f14a19b7acc1ead489d40f0ecc1e985377d9d9844e979c9ab899d952b52109bc71868561345550d4fe186746bb7894664e9a1d0ce012c1bfc5bb566a160
7
- data.tar.gz: 797cbb3c53ebf1cd2c99e6198574deaf653dcb1b1ce1c48606c963eaf7afa4e2c40b6c3bf7790afe6e101256e0aa5b39645bd98895822219f9185ad35ffebde4
6
+ metadata.gz: 717e09c91b277baa776384d4e1edbbb57f2167b93f58b7a300aa8f8515c736a8d695d907efc35ecf05b9d66b4afdc7a4bbd404d67a0e618b66da5cb256d1d98e
7
+ data.tar.gz: 34d877e509a0f9d443a70f74f6b0d59fcfec2052038e1d75cec6ab5930b81c10a2ac099bea49f36fb8eba0148de305634cac7012122a57147113f421ea27bfe2
data/README.md CHANGED
@@ -2,11 +2,18 @@
2
2
 
3
3
  A very simple implementation of Gettext for Ruby.
4
4
 
5
- This is how it could be initialized in Rails and take the locale from I18n.locale:
5
+ # Install
6
+
7
+ Start by putting this in your Gemfile:
8
+ ```ruby
9
+ gem 'gettext_simple'
10
+ ```
11
+
12
+ This is how it could be initialized in Rails and take the locale from I18n.locale by placing this code in `"#{Rails.root}/config/initializers/gettext_simple.rb`:
6
13
  ```ruby
7
14
  require "gettext_simple"
8
15
  gettext_simple = GettextSimple.new(:i18n => true)
9
- gettext_simple.load_dir("#{__dir__}/../../locales_gettext")
16
+ gettext_simple.load_dir("#{Rails.root}/locales_gettext")
10
17
  gettext_simple.register_kernel_methods
11
18
 
12
19
  puts _("Hello world")
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gettext_simple"
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = "2014-04-10"
12
+ s.date = "2014-04-11"
13
13
  s.description = "A very simple version of Gettext reading .po files directly."
14
14
  s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
@@ -69,9 +69,8 @@ class GettextSimple
69
69
  # str = "Hello" #=> "Hello"
70
70
  # gtext.trans("da_DK", str) #=> "Hej"
71
71
  def translate_with_locale(locale, str, replaces = nil)
72
- locale = locale.to_s
73
72
  str = str.to_s
74
- raise "Locale was not found: '#{locale}' in '#{@locales.keys.join(", ")}'." unless @locales.key?(locale)
73
+ raise ArgumentError, "Locale was not found: '#{locale}' in '#{@locales.keys.join(", ")}'." unless @locales.key?(locale)
75
74
 
76
75
  if !@locales[locale].key?(str)
77
76
  translated_str = str.to_s
@@ -90,6 +89,10 @@ class GettextSimple
90
89
  return translated_str
91
90
  end
92
91
 
92
+ def locale_exists?(locale)
93
+ @locales.key?(locale)
94
+ end
95
+
93
96
  def translate(str, replaces = nil)
94
97
  if @i18n
95
98
  locale = I18n.locale.to_s
@@ -163,7 +166,7 @@ private
163
166
  end
164
167
 
165
168
  def add_translation(locale, key, val)
166
- raise "No such language: '#{locale}'." unless @locales.key?(locale)
169
+ raise ArgumentError, "No such language: '#{locale}'." unless @locales.key?(locale)
167
170
 
168
171
  if !key.to_s.empty? && !val.to_s.empty?
169
172
  debug "Found translation for locale '#{locale}' '#{key}' which is: '#{val}'." if @debug
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec