i18n-coffee 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +4 -0
- data/app/assets/javascripts/i18n.coffee +19 -0
- data/app/controllers/i18n/translations_controller.rb +6 -0
- data/config/routes.rb +4 -0
- data/i18n-coffee.gemspec +14 -0
- data/lib/i18n-coffee.rb +21 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7df1cac51926ede5425e1c368cc36483d2ac81c4
|
4
|
+
data.tar.gz: e6473655ddef31bcd40498ea1d4f473ab54f9694
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5471e6ccfa869eb74627ac940fa83376524f992870319d87cfe3c85346214151b761999102805944988d1445690ab74f25974f18515edc6a45d1ebc7d104e2ac
|
7
|
+
data.tar.gz: 9d13b859605e09330dc4904d74299c9976a744b4f96a31648c369d76c95b67eec5861ec279a7764e3365d0aa7c55c0f7e47b302ac0dcaa94e6e3952eaa974e91
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 mann
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class @I18n
|
2
|
+
constructor: (@translations = {}) ->
|
3
|
+
|
4
|
+
@translate: (name, options) ->
|
5
|
+
window.i18n.translate name, options unless window.i18n is undefined
|
6
|
+
|
7
|
+
translate: (name, options) =>
|
8
|
+
result = @_getRawTranslation result ? @translations, text for text in name.split '.'
|
9
|
+
result = result.replace new RegExp("%{" + key + "}", 'g'), value for key, value of options
|
10
|
+
result ? text
|
11
|
+
|
12
|
+
_getRawTranslation: (dataset, text) ->
|
13
|
+
dataset[text]
|
14
|
+
|
15
|
+
$.get "/translations", (data) ->
|
16
|
+
window.i18n = new I18n data
|
17
|
+
|
18
|
+
window.translate = window.t = I18n.translate
|
19
|
+
|
data/config/routes.rb
ADDED
data/i18n-coffee.gemspec
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "i18n-coffee"
|
3
|
+
s.version = "0.1.0"
|
4
|
+
s.authors = ["Chanmann Lim"]
|
5
|
+
s.email = "chanmannlim@gmail.com"
|
6
|
+
s.summary = "Rails client-side i18n translation"
|
7
|
+
|
8
|
+
s.files = `git ls-files`.split("\n")
|
9
|
+
s.require_paths = ["lib"]
|
10
|
+
|
11
|
+
s.add_dependency "rails"
|
12
|
+
s.add_dependency "coffee-rails"
|
13
|
+
s.add_dependency "i18n"
|
14
|
+
end
|
data/lib/i18n-coffee.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module I18n
|
2
|
+
module Coffee
|
3
|
+
DEFAULT_TRANSLATIONS_ROOT = :javascripts
|
4
|
+
|
5
|
+
# Rails engine
|
6
|
+
class Engine < Rails::Engine
|
7
|
+
config.before_configuration do
|
8
|
+
config.i18n_js_root = I18n::Coffee::DEFAULT_TRANSLATIONS_ROOT
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Translation
|
13
|
+
def self.translations
|
14
|
+
{ translations_root => I18n.t(translations_root) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.translations_root
|
18
|
+
Rails.configuration.i18n_js_root
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: i18n-coffee
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chanmann Lim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coffee-rails
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: i18n
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email: chanmannlim@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- .gitignore
|
62
|
+
- Gemfile
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- app/assets/javascripts/i18n.coffee
|
66
|
+
- app/controllers/i18n/translations_controller.rb
|
67
|
+
- config/routes.rb
|
68
|
+
- i18n-coffee.gemspec
|
69
|
+
- lib/i18n-coffee.rb
|
70
|
+
homepage:
|
71
|
+
licenses: []
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.0.14
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Rails client-side i18n translation
|
93
|
+
test_files: []
|