locale_js 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  html/
2
2
  pkg/
3
+ *.gem
4
+ .DS_Store
data/README.markdown ADDED
@@ -0,0 +1,59 @@
1
+ # Locale JS
2
+
3
+ A fairly simple rails engine that takes your Rails locale and makes it available
4
+ in your Javascript.
5
+ All you have to do is add this to your Gemfile, mount the engine and include the javascript locale in
6
+ your page.
7
+
8
+ ## Examples
9
+
10
+ add the gem to your Gemfile
11
+
12
+ ```
13
+ gem 'locale_js'
14
+ ```
15
+
16
+ mount the engine in our routes.rb
17
+
18
+ ```
19
+ mount LocaleJs::Engine => '/i18n'
20
+ ```
21
+
22
+ then add this to your application layout
23
+
24
+ ```
25
+ <script src="/i18n/locale/<%= I18n.locale %>.js"></script>
26
+ ```
27
+
28
+ Populate your locale file as normal..
29
+
30
+ ```
31
+ en:
32
+ hello: "Hello World"
33
+ foo: "%{foo} test"
34
+ bar:
35
+ baz: "The craic is %{craic}"
36
+ ```
37
+
38
+ You can then translate strings in your JS just like I18n...
39
+
40
+ ```
41
+ I18n.t('hello')
42
+ => 'Hello World'
43
+
44
+ I18n.t('foo', {foo: 'bar'})
45
+ => 'bar test'
46
+
47
+ I18n.t('bar.baz', {craic: 'mighty!'})
48
+ => 'The craic is mighty!'
49
+ ```
50
+
51
+ ## Requirements
52
+
53
+ Rails 3.0 or greater
54
+
55
+ ## Copyright
56
+
57
+ Copyright (c) 2012 John Butler
58
+
59
+ See LICENSE.txt for details.
Binary file
@@ -1,4 +1,4 @@
1
- class LocaleController < ApplicationController
1
+ class LocaleJs::LocaleController < ApplicationController
2
2
 
3
3
  # remember to add the locales route
4
4
  # map.connect '/locale/:action.:format', :controller => :locale
Binary file
data/config/routes.rb CHANGED
@@ -1,3 +1,3 @@
1
- Rails.application.routes.draw do
1
+ LocaleJs::Engine.routes.draw do
2
2
  match 'locale/:action', :controller => :locale
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'rails'
2
2
 
3
- module LocaleJS
3
+ module LocaleJs
4
4
  class Engine < Rails::Engine
5
-
5
+ isolate_namespace LocaleJs
6
6
  end
7
7
  end
@@ -1,4 +1,4 @@
1
- module LocaleJS
1
+ module LocaleJs
2
2
  # locale_js version
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
data/locale_js.gemspec CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/locale_js/version', __FILE__)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "locale_js"
7
- gem.version = LocaleJS::VERSION
7
+ gem.version = LocaleJs::VERSION
8
8
  gem.summary = %q{Make Rails i18n available in javascript}
9
9
  gem.description = %q{Make Rails i18n available in javascript}
10
10
  gem.license = "MIT"
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'locale_js'
3
3
 
4
- describe LocaleJS do
4
+ describe LocaleJs do
5
5
  it "should have a VERSION constant" do
6
6
  subject.const_get('VERSION').should_not be_empty
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -2,4 +2,4 @@ gem 'rspec', '~> 2.4'
2
2
  require 'rspec'
3
3
  require 'locale_js/version'
4
4
 
5
- include LocaleJS
5
+ include LocaleJs
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locale_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-26 00:00:00.000000000 +01:00
12
+ date: 2012-06-28 00:00:00.000000000 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubygems-tasks
17
- requirement: &70110792044140 !ruby/object:Gem::Requirement
17
+ requirement: &70352734811280 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0.2'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70110792044140
25
+ version_requirements: *70352734811280
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rdoc
28
- requirement: &70110792043540 !ruby/object:Gem::Requirement
28
+ requirement: &70352734810760 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70110792043540
36
+ version_requirements: *70352734810760
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &70110792042960 !ruby/object:Gem::Requirement
39
+ requirement: &70352734810020 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '2.4'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70110792042960
47
+ version_requirements: *70352734810020
48
48
  description: Make Rails i18n available in javascript
49
49
  email:
50
50
  executables: []
@@ -56,10 +56,12 @@ files:
56
56
  - .rspec
57
57
  - ChangeLog.rdoc
58
58
  - LICENSE.txt
59
- - README.rdoc
59
+ - README.markdown
60
60
  - Rakefile
61
61
  - app/.DS_Store
62
- - app/controllers/locale_controller.rb
62
+ - app/controllers/.DS_Store
63
+ - app/controllers/locale_js/locale_controller.rb
64
+ - app/views/.DS_Store
63
65
  - app/views/locale/i18n.js.erb
64
66
  - config/routes.rb
65
67
  - lib/locale_js.rb
data/README.rdoc DELETED
@@ -1,26 +0,0 @@
1
- = locale_js
2
-
3
- * {Homepage}[https://rubygems.org/gems/locale_js]
4
- * {Documentation}[http://rubydoc.info/gems/locale_js/frames]
5
-
6
- == Description
7
-
8
- TODO: Description
9
-
10
- == Features
11
-
12
- == Examples
13
-
14
- require 'locale_js'
15
-
16
- == Requirements
17
-
18
- == Install
19
-
20
- $ gem install locale_js
21
-
22
- == Copyright
23
-
24
- Copyright (c) 2012 jbutler
25
-
26
- See LICENSE.txt for details.