dikt 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. data/lib/dikt.rb +21 -1
  2. data/lib/dikt/version.rb +1 -1
  3. metadata +1 -1
@@ -1,2 +1,22 @@
1
1
  require "dikt/version"
2
- require 'dikt/translator' if defined?(Rails)
2
+ require 'yaml'
3
+
4
+ if defined?(Rails)
5
+ class String
6
+ def t(lang='pl')
7
+ if dict(lang).has_key? self
8
+ return dict(lang)[self]
9
+ else
10
+ return self
11
+ end
12
+ end
13
+
14
+ private
15
+ def dict(lang)
16
+ @dict = YAML::load(File.open("#{Rails.root}/config/dict.#{lang}.yml"))
17
+ end
18
+ end
19
+ else
20
+ raise "Can't use without Rails application"
21
+ end
22
+
@@ -1,3 +1,3 @@
1
1
  module Dikt
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dikt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease: !!null
6
6
  platform: ruby
7
7
  authors: