polyglot_js 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.
data/README.md CHANGED
@@ -41,6 +41,12 @@ In your layout in head section add following instructions:
41
41
  <%= include_polyglot_js %>
42
42
  ```
43
43
 
44
+ In your application.js add:
45
+
46
+ ```javascript
47
+ //= require_tree ./locales
48
+ ```
49
+
44
50
  Now you can enjoy your translations in javascript code.
45
51
 
46
52
  ## Creating translations
@@ -0,0 +1,8 @@
1
+ module PolyglotJs
2
+ module ControllerAdapter
3
+ def set_polyglot_adapter options
4
+ require "gon"
5
+ gon.polyglot_js_locale = options[:current_language]
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module PolyglotJs
2
+ def include_polyglot_js
3
+ javascript_tag do
4
+ "var t = eval('window.' + gon.polyglot_js_locale);"
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module PolyglotJs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,22 @@
1
+ module PolyglotJs
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc 'Creates locales directory and copy empty files'
5
+ def initialize_empty_directory
6
+ empty_directory "app/assets/javascripts/locales"
7
+ end
8
+ def copy_empty_files
9
+ Dir.foreach("config/locales/") do |filename|
10
+ if filename.match(/[a-zA-Z]/)
11
+ name_js = filename.gsub(".yml", ".js.coffee")
12
+ locale = filename.split(".")
13
+ locale.delete_at(locale.size - 1)
14
+ create_file "app/assets/javascripts/locales/#{name_js}" do
15
+ "window.#{locale.reverse.join('.')} = {}"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
data/polyglot_js.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["dziamber@gmail.com"]
7
7
  gem.description = "i18n for JavaScript with Rails"
8
8
  gem.summary = "i18n for JavaScript with Rails"
9
- gem.homepage = "http://dziambersky.github.com"
9
+ gem.homepage = "http://github.com/dziambersky/polyglot_js"
10
10
  gem.files = `git ls-files`.split($\)
11
11
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyglot_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -40,9 +40,12 @@ files:
40
40
  - README.md
41
41
  - Rakefile
42
42
  - lib/polyglot_js.rb
43
+ - lib/polyglot_js/controller_adapter.rb
44
+ - lib/polyglot_js/polyglot_js.rb
43
45
  - lib/polyglot_js/version.rb
46
+ - lib/rails/generators/polyglot_js/install/install_generator.rb
44
47
  - polyglot_js.gemspec
45
- homepage: http://dziambersky.github.com
48
+ homepage: http://github.com/dziambersky/polyglot_js
46
49
  licenses: []
47
50
  post_install_message:
48
51
  rdoc_options: []