whowish_word 0.4.0 → 0.5.0
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/lib/whowish_word/action_view/base.rb +2 -2
- data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +32 -6
- data/rails/app/controllers/application_controller.rb +5 -1
- data/rails/app/controllers/home_controller.rb +0 -1
- data/rails/app/views/home/index.html.erb +31 -15
- data/rails/app/views/home2/index.html.erb +2 -4
- data/rails/app/views/home2/test.html.erb +3 -0
- data/rails/config/locales/whowish_word/en.yml +1 -2
- data/rails/config/locales/whowish_word/home2/index_en.yml +5 -0
- data/rails/config/locales/whowish_word/home2/test_en.yml +5 -0
- data/rails/public/stylesheets/main.css +22 -0
- data/whowish_word.gemspec +1 -1
- metadata +5 -2
@@ -50,7 +50,7 @@ if defined?(ActionView) and defined?(ActionView::Base)
|
|
50
50
|
if @whowish_word_config.edit_mode == true
|
51
51
|
s = PREFIX + \
|
52
52
|
SEPARATOR + \
|
53
|
-
uid.to_s + \
|
53
|
+
scope_key_by_partial(uid.to_s) + \
|
54
54
|
SEPARATOR + \
|
55
55
|
previous_t(uid, *variables)
|
56
56
|
return "<dfn>#{s}</dfn>".html_safe
|
@@ -63,7 +63,7 @@ if defined?(ActionView) and defined?(ActionView::Base)
|
|
63
63
|
if @whowish_word_config.edit_mode == true
|
64
64
|
s = PREFIX + \
|
65
65
|
SEPARATOR + \
|
66
|
-
uid.to_s + \
|
66
|
+
scope_key_by_partial(uid.to_s) + \
|
67
67
|
SEPARATOR + \
|
68
68
|
previous_t(uid, *variables)
|
69
69
|
return s.html_safe
|
@@ -27,7 +27,23 @@ class WhowishWordController < ApplicationController
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def change_word
|
30
|
-
|
30
|
+
|
31
|
+
keys = params[:word_id].split(".")
|
32
|
+
uid = keys.pop
|
33
|
+
filename = "#{I18n.locale}.yml"
|
34
|
+
|
35
|
+
if keys.length > 1
|
36
|
+
filename = "#{keys[1..-1].join("_")}_#{filename}"
|
37
|
+
end
|
38
|
+
|
39
|
+
paths = [Rails.root, "config", "locales", "whowish_word"]
|
40
|
+
paths.push(keys[0]) if keys.length > 0
|
41
|
+
paths.push(filename)
|
42
|
+
|
43
|
+
locale_file = File.join(*paths)
|
44
|
+
FileUtils.mkdir_p(File.join(*paths[0..-2]))
|
45
|
+
|
46
|
+
translation_keys = I18n.normalize_keys(I18n.locale, params[:word_id], nil, ".")
|
31
47
|
|
32
48
|
file = nil
|
33
49
|
data = {}
|
@@ -48,8 +64,14 @@ class WhowishWordController < ApplicationController
|
|
48
64
|
data = {}
|
49
65
|
end
|
50
66
|
|
51
|
-
|
52
|
-
|
67
|
+
direct = data
|
68
|
+
translation_keys[0..-2].each { |k|
|
69
|
+
k = k.to_s
|
70
|
+
direct[k] ||= {}
|
71
|
+
direct = direct[k]
|
72
|
+
}
|
73
|
+
|
74
|
+
direct[translation_keys.last.to_s] = params[:content]
|
53
75
|
|
54
76
|
file.rewind
|
55
77
|
file.write(YAML.dump(data))
|
@@ -60,9 +82,13 @@ class WhowishWordController < ApplicationController
|
|
60
82
|
file.close
|
61
83
|
end
|
62
84
|
|
63
|
-
I18n.translations
|
64
|
-
|
65
|
-
|
85
|
+
direct = I18n.translations
|
86
|
+
translation_keys[0..-2].each { |k|
|
87
|
+
direct[k] ||= {}
|
88
|
+
direct = direct[k]
|
89
|
+
}
|
90
|
+
direct[translation_keys.last] = params[:content]
|
91
|
+
|
66
92
|
render :json=>{
|
67
93
|
:ok => true
|
68
94
|
}
|
@@ -5,7 +5,11 @@ class ApplicationController < ActionController::Base
|
|
5
5
|
before_filter :activate_whowish_word, :set_locale
|
6
6
|
|
7
7
|
def activate_whowish_word
|
8
|
-
if params[:edit_mode]
|
8
|
+
if params[:edit_mode]
|
9
|
+
session[:edit_mode] = params[:edit_mode]
|
10
|
+
end
|
11
|
+
|
12
|
+
if session[:edit_mode] == "yes"
|
9
13
|
whowish_word.activate_edit_mode
|
10
14
|
end
|
11
15
|
end
|
@@ -1,24 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<a href="/
|
4
|
-
|
1
|
+
<h1>
|
2
|
+
This is the test page for
|
3
|
+
<a href="http://www.github.com/tanin47/whowish_word">whowish_word</a>
|
4
|
+
</h1>
|
5
|
+
<h3>Choose the language</h3>
|
6
|
+
<ul class="Menu">
|
7
|
+
<li class="<%='Active' if I18n.locale == :en%>">
|
8
|
+
<a href="/home?locale=en">en</a>
|
9
|
+
</li>
|
10
|
+
<li class="<%='Active' if I18n.locale == :th%>">
|
11
|
+
<a href="/home?locale=th">th</a>
|
12
|
+
</li>
|
13
|
+
<li class="<%='Active' if I18n.locale == :jp%>">
|
14
|
+
<a href="/home?locale=jp">jp</a>
|
15
|
+
</li>
|
16
|
+
<li>
|
17
|
+
<%
|
18
|
+
if @whowish_word_config.edit_mode == true
|
19
|
+
%>
|
20
|
+
<a href="/home?edit_mode=no" style="font-weight: bold;color: green;">Edit-Mode: ON</a>
|
21
|
+
<%
|
22
|
+
else
|
23
|
+
%>
|
24
|
+
<a href="/home?edit_mode=yes" style="font-weight: bold;color: red;">Edit-Mode: OFF</a>
|
25
|
+
<%
|
26
|
+
end
|
27
|
+
%>
|
28
|
+
</li>
|
29
|
+
</ul>
|
30
|
+
|
5
31
|
<form autocomplete="off" onsubmit="return false;">
|
6
32
|
<div>
|
7
33
|
<span style="width:600px;">
|
8
34
|
<p>This is the page that tests every element.</p>
|
9
35
|
</span>
|
10
36
|
<span>
|
11
|
-
|
12
|
-
if @whowish_word_config.edit_mode == true
|
13
|
-
%>
|
14
|
-
<a href="/home">Dectivate edit mode</a>
|
15
|
-
<%
|
16
|
-
else
|
17
|
-
%>
|
18
|
-
<a href="/home?edit_mode=yes">Activate edit mode</a>
|
19
|
-
<%
|
20
|
-
end
|
21
|
-
%>
|
37
|
+
|
22
38
|
</span>
|
23
39
|
<span>
|
24
40
|
<b>Text: </b> <%=t :text%>
|
@@ -5,6 +5,28 @@ body, input, textarea, button, select, option, div, span {
|
|
5
5
|
line-height: 30px;
|
6
6
|
}
|
7
7
|
|
8
|
+
.Menu {
|
9
|
+
padding: 0px;
|
10
|
+
margin: 0px;
|
11
|
+
list-style: none;
|
12
|
+
}
|
13
|
+
|
14
|
+
.Menu > li {
|
15
|
+
display: inline-block;
|
16
|
+
padding: 10px;
|
17
|
+
margin: 0px;
|
18
|
+
}
|
19
|
+
|
20
|
+
.Menu > li.Active {
|
21
|
+
border: 1px solid #CCC;
|
22
|
+
background-color: #EFEFEF;
|
23
|
+
}
|
24
|
+
|
25
|
+
.Menu > li.Active > a {
|
26
|
+
font-weight: bold;
|
27
|
+
text-decoration: none;
|
28
|
+
}
|
29
|
+
|
8
30
|
body > form > div {
|
9
31
|
display:block;
|
10
32
|
margin-left:25px;
|
data/whowish_word.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whowish_word
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Inline internationlization for Rails 3.2.*
|
15
15
|
email:
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- rails/app/views/home/static_edit.html.erb
|
93
93
|
- rails/app/views/home/static_edit_select.html.erb
|
94
94
|
- rails/app/views/home2/index.html.erb
|
95
|
+
- rails/app/views/home2/test.html.erb
|
95
96
|
- rails/app/views/integration/attr.html.erb
|
96
97
|
- rails/app/views/integration/index.html.erb
|
97
98
|
- rails/app/views/integration/select.html.erb
|
@@ -113,6 +114,8 @@ files:
|
|
113
114
|
- rails/config/environment.rb
|
114
115
|
- rails/config/initializers/whowish_word.rb
|
115
116
|
- rails/config/locales/whowish_word/en.yml
|
117
|
+
- rails/config/locales/whowish_word/home2/index_en.yml
|
118
|
+
- rails/config/locales/whowish_word/home2/test_en.yml
|
116
119
|
- rails/config/locales/whowish_word/jp.yml
|
117
120
|
- rails/config/locales/whowish_word/th.yml
|
118
121
|
- rails/config/mongoid.rb
|