i81n 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +44 -11
  2. data/VERSION +1 -1
  3. data/i81n.gemspec +64 -0
  4. data/lib/i81n.rb +3 -22
  5. metadata +49 -55
data/README.md CHANGED
@@ -3,27 +3,60 @@ i81n
3
3
 
4
4
  I81n is 'Internationalizaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaation'.
5
5
 
6
- It aims that make I18n easy to use.
6
+ I18n YAML ファイルを編集するのって面倒ですよね!
7
+ I81n を使うと(とりあえずは) YAML ファイルに翻訳テキストを書かなくても良くなります!
7
8
 
8
- It extends the I18n::Backend::Simple.
9
+ インストール
10
+ ----
11
+
12
+ 次のようにして gem コマンドでインストールすることができます。
13
+
14
+ gem install i81n
15
+
16
+ Rails をお使いの際は Gemfile に以下を追記して bundle install を実行してください。
17
+
18
+ gem 'i81n'
9
19
 
10
- Usage
20
+ I18n.backend を以下のように設定してください(Rails では config/initializers/i81n.rb 等に書いておくとよいでしょう)。
21
+
22
+ I18n.backend = I18n::Backend::I81n.new
23
+
24
+ 使い方
11
25
  ----
12
26
 
13
- en.yml
27
+ Rails のビューにメッセージを埋め込む場合、こんな感じで書けます。
28
+
29
+ <%= t('こんにちは!') %>
30
+
31
+ サービスを英語対応させたくなった時に翻訳ファイル(en.yml)を書けばいいのです。
32
+ その際、翻訳ファイルは以下のようになるでしょう。
14
33
 
15
- ---
16
34
  en:
17
- foo: FOO
35
+ "こんにちは!": "Hello!"
36
+
37
+ ### もうちょっと詳しく
38
+
39
+ 以下のような YAML ファイル(ja.yml)があった場合、
40
+
41
+ ---
42
+ ja:
43
+ foo: フー
18
44
 
19
- example:
45
+ このような出力になります。
20
46
 
21
47
  require 'i81n'
22
- I18n.t('foo') #=> 'FOO'
23
- I18n.t('bar') #=> 'bar' (as default text)
24
- I18n.t('%{n} times', :n => 10) #=> '10 times' (you can embed values into the default text)
48
+ I18n.backend = I18n::Backend::I81n.new
49
+ I18n.config.locale = :ja
50
+ I18n.t('foo') #=> 'フー'
51
+ I18n.t('バー') #=> 'バー'
52
+ I18n.t('%{n}個', :n => 10) #=> '10個'
53
+
54
+ 詳細
55
+ ----
56
+
57
+ I18n は I18n::Backend::Simple を拡張することによって上記の機能を実現しています。
25
58
 
26
- Copyright
59
+ コピーライト
27
60
  ----
28
61
 
29
62
  Copyright (c) 2011 jugyo. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "i81n"
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["jugyo"]
12
+ s.date = "2011-11-16"
13
+ s.description = "I81n aims that make I18n easy to use."
14
+ s.email = "jugyo.org@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "i81n.gemspec",
28
+ "lib/i81n.rb",
29
+ "test/fixtures/en.yml",
30
+ "test/helper.rb",
31
+ "test/test_i81n.rb"
32
+ ]
33
+ s.homepage = "http://github.com/jugyo/i81n"
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "1.8.11"
37
+ s.summary = "I81n is 'Internationalizaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaation'."
38
+ s.test_files = [
39
+ "test/helper.rb",
40
+ "test/test_i81n.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<i18n>, [">= 0"])
48
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
49
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
50
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
51
+ else
52
+ s.add_dependency(%q<i18n>, [">= 0"])
53
+ s.add_dependency(%q<shoulda>, [">= 0"])
54
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
55
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<i18n>, [">= 0"])
59
+ s.add_dependency(%q<shoulda>, [">= 0"])
60
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
62
+ end
63
+ end
64
+
@@ -1,25 +1,6 @@
1
1
  require 'i18n'
2
-
3
- module I18n
4
- module Backend
5
-
6
- # Usage:
7
- #
8
- # require 'i81n'
9
- # I18n.t('foo') #=> 'foo'
10
- # I18n.t('foo%{bar}', :bar => 'bar') #=> 'foobar'
11
- #
12
- module I81nize
13
- def self.included(base)
14
- base.class_eval do
15
- alias_method :old_lookup, :lookup
16
- def lookup(locale, key, scope = [], options = {})
17
- old_lookup(locale, key, scope, options) || key
18
- end
19
- end
20
- end
21
- end
2
+ class I18n::Backend::I81n < I18n::Backend::Simple
3
+ def lookup(locale, key, scope = [], options = {})
4
+ super || key.to_s
22
5
  end
23
6
  end
24
-
25
- I18n::Backend::Simple.send(:include, I18n::Backend::I81nize)
metadata CHANGED
@@ -1,72 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: i81n
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
4
5
  prerelease:
5
- version: 0.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - jugyo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-03-09 00:00:00 +09:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: i18n
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2156589080 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :runtime
25
23
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2156589080
25
+ - !ruby/object:Gem::Dependency
28
26
  name: shoulda
29
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2156587680 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
35
33
  type: :development
36
34
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2156587680
36
+ - !ruby/object:Gem::Dependency
39
37
  name: bundler
40
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &2156585220 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
40
+ requirements:
43
41
  - - ~>
44
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
45
43
  version: 1.0.0
46
44
  type: :development
47
45
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *2156585220
47
+ - !ruby/object:Gem::Dependency
50
48
  name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &2156584140 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
51
+ requirements:
54
52
  - - ~>
55
- - !ruby/object:Gem::Version
53
+ - !ruby/object:Gem::Version
56
54
  version: 1.5.2
57
55
  type: :development
58
56
  prerelease: false
59
- version_requirements: *id004
57
+ version_requirements: *2156584140
60
58
  description: I81n aims that make I18n easy to use.
61
59
  email: jugyo.org@gmail.com
62
60
  executables: []
63
-
64
61
  extensions: []
65
-
66
- extra_rdoc_files:
62
+ extra_rdoc_files:
67
63
  - LICENSE.txt
68
64
  - README.md
69
- files:
65
+ files:
70
66
  - .document
71
67
  - Gemfile
72
68
  - Gemfile.lock
@@ -74,41 +70,39 @@ files:
74
70
  - README.md
75
71
  - Rakefile
76
72
  - VERSION
73
+ - i81n.gemspec
77
74
  - lib/i81n.rb
78
75
  - test/fixtures/en.yml
79
76
  - test/helper.rb
80
77
  - test/test_i81n.rb
81
- has_rdoc: true
82
78
  homepage: http://github.com/jugyo/i81n
83
- licenses:
79
+ licenses:
84
80
  - MIT
85
81
  post_install_message:
86
82
  rdoc_options: []
87
-
88
- require_paths:
83
+ require_paths:
89
84
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
85
+ required_ruby_version: !ruby/object:Gem::Requirement
91
86
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: -3917386362667530896
96
- segments:
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ segments:
97
92
  - 0
98
- version: "0"
99
- required_rubygems_version: !ruby/object:Gem::Requirement
93
+ hash: -3596118889516772508
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
95
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: "0"
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
105
100
  requirements: []
106
-
107
101
  rubyforge_project:
108
- rubygems_version: 1.6.0
102
+ rubygems_version: 1.8.11
109
103
  signing_key:
110
104
  specification_version: 3
111
105
  summary: I81n is 'Internationalizaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaation'.
112
- test_files:
106
+ test_files:
113
107
  - test/helper.rb
114
108
  - test/test_i81n.rb