i18n-coffee 0.1.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21bb26d4844d86756477408e3a077e88916739b5
4
- data.tar.gz: b4ad47d14ba5c5dcae41626388c8458fc28d0b22
3
+ metadata.gz: 71aeee90b6d8634470881d9fa7fe239165bd0a5b
4
+ data.tar.gz: e3e8cec698f748cad2077f78117cee3a3218497d
5
5
  SHA512:
6
- metadata.gz: 701fa65ad549fb1b690e1eec64977e9aab0cb70da57e46552f531450d7e68c0205939a825cfc3ee7392220aa13d0708a78544614c221460122d7e55ce256b413
7
- data.tar.gz: ddea996bd44ed2ef8e14a44feea18bd479c711fe349835c66b661ca8f0470e262d2131590e9f9e135c53c1e56a8464ec4bcd394f6aef79f8567f2183351a3b98
6
+ metadata.gz: 8408ec7b16f8649cf3fdad5299d0f4e6c0b4970457086b11af71e5cca439a321558b00f3fc150057b473d72f8d1b85fcab6446394272ccf4fcdb8f49c61903aa
7
+ data.tar.gz: bc54e9fbb3583db676edc7b9d7f375c4db4ec65a97bbd9b9aa11d70ca09439433891964749d10a1d171e7a8a601adadec345867dd8121d281eb1b47806f1304a
data/README.md CHANGED
@@ -1,41 +1,56 @@
1
- i18n-coffee
2
- ===========
1
+ #i18n-coffee
3
2
 
4
3
  Client Side Localisation for Rails
5
4
 
6
5
 
7
- Usages
8
- ------
6
+ ##Usage
9
7
 
10
8
  In your Gemfile add
11
9
 
12
- `gem 'i18n-coffee', '~> 0.1.0'`
10
+ gem 'i18n-coffee', '~> 0.1.1'
13
11
 
14
-
15
- Setup locale translations
16
- -------------------------
12
+ ##Setup locale translations
17
13
 
18
14
  By default, it looks for `javascripts` node in your {locale}.yml.
19
15
 
20
16
  **For example**
21
17
 
22
- <pre><code>
23
- # locales/en.yml
24
- en:
25
- javascripts:
26
- hello: "Hello"
27
- </code></pre>
18
+ # config/locales/en.yml
19
+ en:
20
+ javascripts:
21
+ hello: "Hello"
22
+
23
+ ##On the client-side
28
24
 
25
+ In your `app/asssets/javascripts/application.js` file include i18n
29
26
 
30
- On the client-side
31
- ------------------
27
+ ```javascript
28
+ //= require i18n
29
+ ```
32
30
 
33
- You can try in Firebug or Chrome developer tools with
31
+ You can now try it in Firebug or Chrome developer tools with
34
32
 
35
- `window.t('javascripts.hello'); // "Hello"`
33
+ ```javascript
34
+ window.t('javascripts.hello'); // "Hello"
35
+ ```
36
36
 
37
37
  based on `I18n.locale` in Rails it will load the corresponding translations from your locale files.
38
38
 
39
+ ###Passing variables to translation
40
+
41
+ You can use variables to generate dynamic content in the client-side translations the same way that Rails does.
42
+
43
+ ```javascript
44
+ window.t('javascripts.greeting', { name: "Mann" });
45
+ ```
46
+
47
+ # config/locales/en.yml
48
+ en:
49
+ javascripts:
50
+ greeting: "Hello %{name}!"
51
+
52
+
53
+
39
54
 
40
55
 
41
56
 
data/i18n-coffee.gemspec CHANGED
@@ -1,6 +1,10 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "i18n/coffee/version"
4
+
1
5
  Gem::Specification.new do |s|
2
6
  s.name = "i18n-coffee"
3
- s.version = "0.1.1"
7
+ s.version = I18n::Coffee::Version.dup
4
8
  s.authors = ["Chanmann Lim"]
5
9
  s.email = "chanmannlim@gmail.com"
6
10
  s.homepage = "https://rubygems.org/gems/i18n-coffee"
@@ -11,6 +15,7 @@ Gem::Specification.new do |s|
11
15
  s.require_paths = ["lib"]
12
16
 
13
17
  s.add_dependency "rails"
14
- s.add_dependency "coffee-rails"
15
18
  s.add_dependency "i18n"
19
+ s.add_dependency "coffee-rails"
20
+ s.add_dependency "jquery-rails"
16
21
  end
data/lib/i18n-coffee.rb CHANGED
@@ -1,21 +1,26 @@
1
1
  module I18n
2
2
  module Coffee
3
- DEFAULT_TRANSLATIONS_ROOT = :javascripts
3
+ DEFAULT_TRANSLATIONS_ROOT = 'javascripts'
4
4
 
5
5
  # Rails engine
6
6
  class Engine < Rails::Engine
7
7
  config.before_configuration do
8
- config.i18n_js_root = I18n::Coffee::DEFAULT_TRANSLATIONS_ROOT
8
+ config.i18n_translations_root = I18n::Coffee::DEFAULT_TRANSLATIONS_ROOT
9
9
  end
10
10
  end
11
11
 
12
12
  # Translation
13
13
  def self.translations
14
- { translations_root => I18n.t(translations_root) }
14
+ translations = I18n.t(translations_root)
15
+
16
+ return translations if translations_root == '.'
17
+ { translations_root.gsub(/\./, '_') => translations }
15
18
  end
16
19
 
20
+ # translations_root value
21
+ # '.' = get all translations in {locale}.yml
17
22
  def self.translations_root
18
- Rails.configuration.i18n_js_root
23
+ Rails.configuration.i18n_translations_root.to_s
19
24
  end
20
25
  end
21
26
  end
@@ -0,0 +1,5 @@
1
+ module I18n
2
+ module Coffee
3
+ Version = "0.1.2".freeze
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-coffee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chanmann Lim
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: i18n
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: coffee-rails
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: i18n
56
+ name: jquery-rails
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - '>='
@@ -67,6 +81,7 @@ files:
67
81
  - config/routes.rb
68
82
  - i18n-coffee.gemspec
69
83
  - lib/i18n-coffee.rb
84
+ - lib/i18n/coffee/version.rb
70
85
  homepage: https://rubygems.org/gems/i18n-coffee
71
86
  licenses: []
72
87
  metadata: {}