tr8n 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,31 +4,5 @@ gem 'rails', '~> 3.0.0'
4
4
  gem 'will_paginate', "~> 3.0.pre2"
5
5
  gem 'will_filter', "~> 3.0.0"
6
6
 
7
- # Bundle edge Rails instead:
8
- # gem 'rails', :git => 'git://github.com/rails/rails.git'
9
-
10
- #gem 'sqlite3'
7
+ gem 'sqlite3'
11
8
  #gem 'will_filter', :path => '../will_filter'
12
-
13
- # Use unicorn as the web server
14
- # gem 'unicorn'
15
-
16
- # Deploy with Capistrano
17
- # gem 'capistrano'
18
-
19
- # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
20
- # gem 'ruby-debug'
21
- # gem 'ruby-debug19', :require => 'ruby-debug'
22
-
23
- # Bundle the extra gems:
24
- # gem 'bj'
25
- # gem 'nokogiri'
26
- # gem 'sqlite3-ruby', :require => 'sqlite3'
27
- # gem 'aws-s3', :require => 'aws/s3'
28
-
29
- # Bundle gems for the local environment. Make sure to
30
- # put test-only gems in this group so their generators
31
- # and rake tasks are available in development mode:
32
- # group :development, :test do
33
- # gem 'webrat'
34
- # end
data/Gemfile.lock CHANGED
@@ -64,8 +64,8 @@ GEM
64
64
  treetop (1.4.9)
65
65
  polyglot (>= 0.3.1)
66
66
  tzinfo (0.3.27)
67
- will_filter (1.0.1)
68
- rails (= 3.0.7)
67
+ will_filter (3.0.0)
68
+ rails (~> 3.0.0)
69
69
  will_paginate (~> 3.0.pre2)
70
70
  will_paginate (3.0.pre2)
71
71
 
@@ -73,7 +73,7 @@ PLATFORMS
73
73
  ruby
74
74
 
75
75
  DEPENDENCIES
76
- rails (= 3.0.7)
76
+ rails (~> 3.0.0)
77
77
  sqlite3
78
- will_filter (= 1.0.1)
78
+ will_filter (~> 3.0.0)
79
79
  will_paginate (~> 3.0.pre2)
data/README.rdoc CHANGED
@@ -1,12 +1,12 @@
1
1
  = Welcome to Tr8n Translation Engine
2
2
 
3
- Tr8n Translation Engine is a Rails engine plugin that provides a framework for crowd-source translations and management of any internationalized text
4
- throughout any Rails based application. The power of the engine comes from its simple and friendly user interface that allows site users
5
- to rapidly translate the site into hundreds of languages. The flexible and robust rules engine that powers Tr8n allows for any combination
6
- of language specific rules in any translatable sentence. Users themselves can provide information on what sentences depend on gender rules,
7
- number rules or other rules supported by the engine. The language specific rules can be registered and managed for any language in
8
- the advanced user interface. The engine provides a set of powerful admin tools that allow admins to manage any aspect of the engine;
9
- enabling and disabling its features and monitoring translation process.
3
+ Tr8n Translation Engine is a Rails Engine Gem that provides a framework for crowd-sourced translation and management of any content
4
+ for any Rails based application. The power of the engine comes from its simple and friendly user interface that allows site users
5
+ to rapidly translate the site into hundreds of languages. The flexible and robust rules engine that powers tr8n allows for any combination
6
+ of language specific rules in any translatable sentence. Users can provide information on what sentences depend on gender rules,
7
+ number rules or other rules configured for each language. The language specific context and case rules can be registered and managed for any language in
8
+ the advanced user interface. The engine provides a set of powerful administration tools that allow admins to manage any aspect of the engine;
9
+ enabling and disabling its features and monitoring translation progress.
10
10
 
11
11
  The Tr8n engine itself is based on a very robust and flexible pluggable architecture where rule types and the syntax of the "tr" tokens
12
12
  can be configured or extended for any application deployment.
@@ -17,7 +17,7 @@ Geni Inc, http://www.geni.com
17
17
 
18
18
  Yammer Inc, http://www.yammer.com
19
19
 
20
- You can visit their web sites and see how it is being used. If your company is using Tr8n, please let me know and i will add you to the list.
20
+ You can visit their web sites and see how it is being used. If your company is using Tr8n, please let me know and you will be added to the list.
21
21
 
22
22
  = Documentation
23
23
 
@@ -79,6 +79,22 @@ Live Tr8n sample application is running here:
79
79
 
80
80
  http://bit.ly/e9QhFY
81
81
 
82
+ = Tr8n Screenshots
83
+
84
+ Below are a few screenshots of what tr8n looks like:
85
+
86
+ http://wiki.tr8n.org/images/b/b7/Tr8n_screenshot_1.png
87
+
88
+ http://wiki.tr8n.org/images/5/55/Tr8n_screenshot_2.png
89
+
90
+ http://wiki.tr8n.org/images/3/3c/Tr8n_screenshot_3.png
91
+
92
+ http://wiki.tr8n.org/images/7/7b/Tr8n_screenshot_4.png
93
+
94
+ http://wiki.tr8n.org/images/9/91/Tr8n_screenshot_5.png
95
+
96
+ http://wiki.tr8n.org/images/8/8b/Tr8n_screenshot_6.png
97
+
82
98
  = External Links
83
99
 
84
100
  Yammer in Translation
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.2
1
+ 3.0.3
@@ -29,22 +29,10 @@ class Tr8n::HomeController < ApplicationController
29
29
 
30
30
  end
31
31
 
32
- def tokens
33
-
34
- end
35
-
36
- def rules
37
-
38
- end
39
-
40
32
  def license
41
33
 
42
34
  end
43
35
 
44
- def docs
45
-
46
- end
47
-
48
36
  def credits
49
37
 
50
38
  end
@@ -22,6 +22,5 @@
22
22
  #++
23
23
 
24
24
  module ApplicationHelper
25
- include Tr8n::HelperMethods
26
25
 
27
26
  end
@@ -218,6 +218,10 @@ class Tr8n::Language < ActiveRecord::Base
218
218
  @rule_classes ||= rules.collect{|r| r.class}.uniq
219
219
  end
220
220
 
221
+ def rule_class_names
222
+ @rule_class_names ||= rule_classes.collect{|r| r.name}
223
+ end
224
+
221
225
  def dependencies
222
226
  @dependencies ||= rule_classes.collect{|r| r.dependency}.uniq
223
227
  end
@@ -125,7 +125,7 @@ class Tr8n::Translation < ActiveRecord::Base
125
125
  rules.each do |rule|
126
126
  context_rules << "<strong>#{rule[:token]}</strong> #{rule[:rule].description}"
127
127
  end
128
- context_rules.join(" and ")
128
+ context_rules.join(" and ").html_safe
129
129
  end
130
130
  end
131
131
 
@@ -159,13 +159,13 @@ class Tr8n::TranslationKey < ActiveRecord::Base
159
159
  def language_rules_dependant_tokens(language = Tr8n::Config.current_language)
160
160
  toks = []
161
161
  included_token_hash = {}
162
-
162
+
163
163
  data_tokens.each do |token|
164
164
  next unless token.dependant?
165
165
  next if included_token_hash[token.name]
166
166
 
167
167
  token.language_rules.each do |rule_class|
168
- if language.rule_classes.include?(rule_class)
168
+ if language.rule_class_names.include?(rule_class.name)
169
169
  toks << token
170
170
  included_token_hash[token.name] = token
171
171
  end
@@ -307,16 +307,16 @@ class Tr8n::TranslationKey < ActiveRecord::Base
307
307
  find(:first, :offset => rand(count - 1))
308
308
  end
309
309
 
310
- # returns back grouped by context
310
+ # returns back grouped by context - used by API
311
311
  def find_all_valid_translations(translations)
312
312
  if translations.empty?
313
- return {:key => self.key, :label => self.label, :original => true}
313
+ return {:id => self.id, :key => self.key, :label => self.label, :original => true}
314
314
  end
315
315
 
316
316
  # if the first translation does not depend on any of the context rules
317
317
  # use it... we don't care about the rest of the rules.
318
318
  if translations.first.rules_hash.blank?
319
- return {:key => self.key, :label => translations.first.label}
319
+ return {:id => self.id, :key => self.key, :label => translations.first.label}
320
320
  end
321
321
 
322
322
  # build a context hash for every kind of context rules combinations
@@ -336,7 +336,7 @@ class Tr8n::TranslationKey < ActiveRecord::Base
336
336
 
337
337
  # always add the default one at the end, so if none of the rules matched, use the english one
338
338
  valid_translations << {:label => self.label} unless context_hash_matches[""]
339
- {:key => self.key, :labels => valid_translations}
339
+ {:id => self.id, :key => self.key, :labels => valid_translations}
340
340
  end
341
341
 
342
342
  def find_first_valid_translation(language, token_values)
@@ -450,7 +450,7 @@ class Tr8n::TranslationKey < ActiveRecord::Base
450
450
  end
451
451
 
452
452
  html = "<tr8n class='#{classes.join(' ')}' translation_key_id='#{id}'>"
453
- html << label
453
+ html << sanitized_label
454
454
  html << "</tr8n>"
455
455
  html.html_safe
456
456
  end
@@ -1,7 +1,5 @@
1
1
  <%= render :partial => "/tr8n/admin/common/header" %>
2
2
 
3
- <%=tr8n_client_sdk_scripts_tag %>
4
-
5
3
  <div class="section_title">
6
4
  <span style="font-size:12px; color:grey; float:right; padding-top:5px;">
7
5
  <strong>Make sure that key source tracking is enabled!</strong> And try not to register useless phrases in production.
@@ -34,7 +32,7 @@
34
32
  <%=link_to_function("<span>Translate Label</span>".html_safe, "translate();", :class => "tr8n_grey_button tr8n_pcb") %>
35
33
 
36
34
  <div style="margin-top:15px; padding:2px; text-align:center; border: 1px dotted #ccc;">
37
- <%=link_to_function("<span>View Examples</span>".html_safe, "tr8nLightbox.show('/tr8n/admin/clientsdk/lb_samples', {height:450});", :class => "tr8n_grey_button tr8n_pcb", :style=>"width:200px;") %><br>
35
+ <%=link_to_function("<span>View Examples</span>".html_safe, "tr8nLightbox.show('/tr8n/admin/clientsdk/lb_samples', {height:550});", :class => "tr8n_grey_button tr8n_pcb", :style=>"width:200px;") %><br>
38
36
  <%=link_to("<span>View Phrases</span>".html_safe, "/tr8n/phrases/index?section_key=clientsdk", :target => "_phrases", :class => "tr8n_grey_button tr8n_pcb", :style=>"width:200px;") %><br>
39
37
  <%=link_to_function("<span>Load Translations</span>".html_safe, "reloadTranslations();", :class => "tr8n_grey_button tr8n_pcb", :style=>"width:200px;") %><br>
40
38
  <%=link_to_function("<span>Clear Results</span>".html_safe, "clearResults();", :class => "tr8n_grey_button tr8n_pcb", :style=>"width:200px;") %><br>
@@ -55,6 +53,8 @@
55
53
  <tr>
56
54
  <td colspan="2" style="padding:2px;">
57
55
  <div style="font-weight:bold; padding-top:10px;">Translation <span style='color:grey'>- translated label with substituted tokens</span></div>
56
+ <div id="result_html" style="background:#F9F8F7; height:40px; overflow:auto; border:1px dotted #ccc; padding:10px;"></div>
57
+ <div style="font-weight:bold; padding-top:10px; color:grey;">Raw HTML:</div>
58
58
  <%=text_area_tag(:result, "", :style => "width:99%; background:#F9F8F7;", :readonly => true)%>
59
59
  </td>
60
60
  </tr>
@@ -65,20 +65,19 @@
65
65
  <div id="debugger" class="section_box colored" style="font-size:10px; border:1px solid black; height:230px; overflow:auto; padding: 2px;">
66
66
  </div>
67
67
 
68
+ <%=tr8n_translations_js_tag(:sources => ["clientsdk_examples"], :id => :tr8n_clientsdk_translations) %>
69
+ <%=tr8n_client_sdk_scripts_tag(
70
+ :default_source => "clientsdk_examples",
71
+ :debugger_element_id => "debugger",
72
+ :translations_element_id => "tr8n_clientsdk_translations",
73
+ :scheduler_interval => 5000
74
+ ) %>
75
+
68
76
  <script>
69
- var tr8nProxy = new Tr8n.Proxy({
70
- "debugger": "debugger",
71
- "source": "clientsdk",
72
- "decorations": {"bold": "<strong>{$0}</strong>", "italic": "<i>{$0}</i>", "link": "<a href='{$href}'>{$0}</a>"},
73
- "rules": {"number":{"token_suffixes":["count", "num"]},
74
- "gender":{"token_suffixes":["user", "profile", "actor", "target"]},
75
- "list":{"token_suffixes":["list"]}, "date":{"token_suffixes":["date"]}
76
- }
77
- });
78
-
79
77
  function clearResults() {
80
78
  Tr8n.element('debugger').innerHTML = '';
81
79
  Tr8n.element('result').value = '';
80
+ Tr8n.element('result_html').innerHTML = '';
82
81
  }
83
82
 
84
83
  function reloadTranslations() {
@@ -100,6 +99,7 @@
100
99
  }
101
100
 
102
101
  Tr8n.element('result').value = tr8nProxy.tr(Tr8n.value('label'), '', tokens);
102
+ Tr8n.element('result_html').innerHTML = Tr8n.element('result').value;
103
103
  }
104
104
 
105
105
  function speedTest() {
@@ -11,6 +11,7 @@
11
11
  {:label => "Some [bold: decoration] stuff!", :tokens => "{'bold': '<strong>{$0}</strong>'}", :alt => "Uses decoration token."},
12
12
  {:label => "Using default [bold: decorations]!", :tokens => "", :alt => "Uses decoration token with a fallback default decoration."},
13
13
  {:label => "More default [italic: decorations]!", :tokens => "", :alt => "Uses decoration token with a fallback default decoration."},
14
+ {:label => "Even more [span: default decorations]!", :tokens => "{span: {style:'font-size:18px;font-weight:bold;color:blue;'}}", :alt => "Uses decoration token with a fallback default decoration."},
14
15
  {:label => "[link: Click here] is a link default decoration!", :tokens => "{'link':{'href':'http://www.google.com'}}", :alt => "Uses decoration token with a fallback default decoration."},
15
16
  {:label => "You have [link: {count|| message, messages}] in your mailbox!", :tokens => "{'link':{'href':'http://www.google.com'}, 'count': 5}", :alt => "Uses decoration and data tokens together."},
16
17
  ]
@@ -11,14 +11,6 @@
11
11
  <% if Tr8n::Config.enable_effects? %>
12
12
  <%=javascript_include_tag(Tr8n::Config.effects_library_path) -%>
13
13
  <% end %>
14
-
15
- <% if Tr8n::Config.enable_client_sdk? %>
16
- <%=javascript_include_tag("/tr8n/javascripts/tr8n_client_sdk.js") -%>
17
- <% tr8n_source = "#{@controller.controller_name}/#{@controller.action_name}" %>
18
- <script type="text/javascript">
19
- // initializeTr8nClientSDK("<%=tr8n_source%>");
20
- </script>
21
- <% end %>
22
14
 
23
15
  <% if Tr8n::Config.enable_google_suggestions? and Tr8n::Config.current_user_is_translator? %>
24
16
  <script type="text/javascript" src="<%=request.ssl? ? 'https' : 'http' %>://www.google.com/jsapi"></script>
@@ -58,7 +58,7 @@
58
58
  <tr>
59
59
  <td style="vertical-align:middle"><%=tr8n_help_icon_tag %></td>
60
60
  <td style="font-size:10px; font-family:arial; vertical-align:middle">&nbsp;
61
- <%=trla("Click this icon to view [link: translation help] in a new window.", "", :link => ["tr8n/help"])%>
61
+ <%=trla("Click this icon to view [link: translation help] in a new window.", "", :link => lambda{|value| link_to(value, "tr8n/help")})%>
62
62
  </td>
63
63
  </tr>
64
64
  </table>
@@ -16,7 +16,7 @@
16
16
  <td></td>
17
17
  <td style="color:grey; font-size:12px; padding-top:10px; padding-bottom:10px;">
18
18
  <%=tra("Leave your comments here if you would like to discuss translations for this particular phrase.")%>
19
- <%=tra("If you would like to discuss translations in general, leave your comments in the [link: language forum].", "", :link => ["/tr8n/forum"])%>
19
+ <%=tra("If you would like to discuss translations in general, leave your comments in the [link: language forum].", "", :link => lambda{|value| link_to(value, "/tr8n/forum")})%>
20
20
  </td>
21
21
  </tr>
22
22
  </table>
@@ -11,7 +11,7 @@
11
11
 
12
12
  defaults: &defaults
13
13
  enable_tr8n: true # enables the engine
14
- enable_key_source_tracking: false # builds the site map sources
14
+ enable_key_source_tracking: false # builds the site map sources - must be enabled for the API
15
15
  enable_key_caller_tracking: false # tracks all calls to labels with their traces - for debugging only
16
16
 
17
17
  enable_glossary_hints: true # shows glossary in the translator
@@ -76,8 +76,8 @@ defaults: &defaults
76
76
  #############################################################################
77
77
  caching:
78
78
  enabled: false
79
- adapter: ActiveSupport::Cache
80
- store: [mem_cache_store, 'localhost:11211']
79
+ adapter: "ActiveSupport::Cache"
80
+ store: ['mem_cache_store', 'localhost:11211']
81
81
  version: 1 # you can change the version to invalidate the cache
82
82
 
83
83
  #############################################################################
@@ -86,7 +86,7 @@ defaults: &defaults
86
86
  #############################################################################
87
87
  logger:
88
88
  enabled: true
89
- log_path: log/tr8n.log # location of the log file
89
+ log_path: "log/tr8n.log" # location of the log file
90
90
  enable_paranoia_mode: true # logs every translator action
91
91
 
92
92
  #############################################################################
@@ -112,14 +112,14 @@ defaults: &defaults
112
112
  class_name: User # class name for the User object type
113
113
  current_user_method: current_user # returns current user object
114
114
  methods: # User object methods mapping
115
- id: id
116
- name: name
117
- gender: gender
118
- admin: admin?
119
- guest: guest?
120
- mugshot: mugshot
121
- link: link
122
- locale: locale
115
+ id: "id"
116
+ name: "name"
117
+ gender: "gender"
118
+ admin: "admin?"
119
+ guest: "guest?"
120
+ mugshot: "mugshot"
121
+ link: "link"
122
+ locale: "locale"
123
123
 
124
124
  #############################################################################
125
125
  # Rules Engine Settings
@@ -130,33 +130,33 @@ defaults: &defaults
130
130
  decoration_token_classes: ["Tr8n::Tokens::DecorationToken"]
131
131
  allow_nil_token_values: true
132
132
  numeric_rule:
133
- token_suffixes: [count, num, age, hours, minutes, years, seconds]
134
- object_method: to_i
133
+ token_suffixes: ["count", "num", "age", "hours", "minutes", "years", "seconds"]
134
+ object_method: "to_i"
135
135
  gender_rule:
136
- token_suffixes: [user, profile, actor, target, partner, parent, child, sibling, manager]
137
- object_method: gender
136
+ token_suffixes: ["user", "profile", "actor", "target", "partner"]
137
+ object_method: "gender"
138
138
  method_values:
139
- female: female
140
- male: male
141
- neutral: neutral
142
- unknown: unknown
139
+ female: "female"
140
+ male: "male"
141
+ neutral: "neutral"
142
+ unknown: "unknown"
143
143
  list_rule: # use list_rule if your site does not support user genders
144
- object_method: size
145
- token_suffixes: [list]
144
+ object_method: "size"
145
+ token_suffixes: ["list"]
146
146
  gender_list_rule: # similiar to list rule, but works together with gender rule
147
- object_method: size
148
- token_suffixes: [list]
147
+ object_method: "size"
148
+ token_suffixes: ["list"]
149
149
  date_rule:
150
- token_suffixes: [date]
151
- object_method: to_date
150
+ token_suffixes: ["date"]
151
+ object_method: "to_date"
152
152
  value_rule:
153
153
  token_suffixes: "*"
154
- object_method: to_s
154
+ object_method: "to_s"
155
155
 
156
156
  # minimal rank makes the translation acceptable for subsitution and counts towards the translator rank
157
157
  translation_threshold: 1
158
158
 
159
- viewing_user_token: viewing_user
159
+ viewing_user_token: "viewing_user"
160
160
  translation_rank_styles:
161
161
  -1000..-5: "color:red;font-weight:bold;"
162
162
  -4..-1: "color:red;"
@@ -168,7 +168,7 @@ defaults: &defaults
168
168
  #############################################################################
169
169
  api:
170
170
  enabled: true
171
- response_encoding: json # options: xml, json
171
+ response_encoding: "json" # options: xml, json
172
172
  allow_key_registration: true
173
173
 
174
174
  #############################################################################
@@ -1,6 +1,6 @@
1
1
  #############################################################################
2
2
  #
3
- # Tr8n Data Tokens
3
+ # Tr8n Default Data Tokens
4
4
  #
5
5
  #############################################################################
6
6
 
@@ -1,6 +1,6 @@
1
1
  #############################################################################
2
2
  #
3
- # Tr8n Default Gender Rules
3
+ # Tr8n Default Decoration Tokens
4
4
  #
5
5
  #############################################################################
6
6
 
@@ -10,7 +10,7 @@ b: "<strong>{$0}</strong>"
10
10
  em: "<em>{$0}</em>"
11
11
  italic: "<i>{$0}</i>"
12
12
  i: "<i>{$0}</i>"
13
- link: "<a href='{$1}' style='{$2}'>{$0}</a>"
14
- link1: "<a href='{$1}' style='{$2}'>{$0}</a>"
15
- link2: "<a href='{$1}' style='{$2}'>{$0}</a>"
13
+ link: "<a href='{$href}'>{$0}</a>"
16
14
  br: "<br>{$0}"
15
+ div: "<div id='{$id}' class='{$class}' style='{$style}'>{$0}</div>"
16
+ span: "<span id='{$id}' class='{$class}' style='{$style}'>{$0}</span>"