mini-i18n 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/.gemspec +11 -0
  2. data/LICENSE +20 -0
  3. data/README.md +2 -0
  4. data/lib/mini-i18n.rb +22 -0
  5. metadata +50 -0
@@ -0,0 +1,11 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = "mini-i18n"
3
+ gem.version = "0.0.1"
4
+ gem.summary = "Minimal I18n"
5
+ gem.description = "Minimal I18n"
6
+ gem.authors = ["CarlosIPe"]
7
+ gem.email = ["carlos2@compendium.com.ar"]
8
+ gem.homepage = "http://github.com/carlosipe/mini-i18n"
9
+ gem.files = ["LICENSE","README.md","lib/mini-i18n.rb",".gemspec"]
10
+ gem.licenses = ['MIT']
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 CarlosIPe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ [![Gem Version](https://badge.fury.io/rb/mini-i18n.png)](http://badge.fury.io/rb/mini-i18n)
2
+ # Minimal I18n
@@ -0,0 +1,22 @@
1
+ require 'yaml'
2
+ class MiniI18n
3
+ attr_reader :locale
4
+ def initialize
5
+ @index = {}
6
+ @locale = 'en'
7
+ end
8
+
9
+ def locale=(locale)
10
+ @locale = locale.to_s
11
+ end
12
+
13
+ def load_yml(path)
14
+ @index = YAML.load_file(path)
15
+ end
16
+
17
+ def translate(key)
18
+ keys = [locale] + key.split('.')
19
+ translation = keys.reduce(@index) {|hash, key| hash.fetch(key.to_s)}
20
+ translation.to_s
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mini-i18n
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - CarlosIPe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-22 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Minimal I18n
15
+ email:
16
+ - carlos2@compendium.com.ar
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/mini-i18n.rb
24
+ - .gemspec
25
+ homepage: http://github.com/carlosipe/mini-i18n
26
+ licenses:
27
+ - MIT
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 1.8.23
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: Minimal I18n
50
+ test_files: []