afalkear_translation_center 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +293 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/images/translation_center/badr_it.png +0 -0
  6. data/app/assets/images/translation_center/loading.gif +0 -0
  7. data/app/assets/images/translation_center/translation_center_logo.png +0 -0
  8. data/app/assets/javascripts/translation_center/application.js +75 -0
  9. data/app/assets/javascripts/translation_center/bootstrap.js +2025 -0
  10. data/app/assets/javascripts/translation_center/categories.js +18 -0
  11. data/app/assets/javascripts/translation_center/center.js +55 -0
  12. data/app/assets/javascripts/translation_center/inspector.js.erb +59 -0
  13. data/app/assets/javascripts/translation_center/jquery-ui.js +14912 -0
  14. data/app/assets/javascripts/translation_center/jquery.jeditable.mini.js +38 -0
  15. data/app/assets/javascripts/translation_center/routes.js +15 -0
  16. data/app/assets/javascripts/translation_center/spin.min.js +1 -0
  17. data/app/assets/javascripts/translation_center/translation_keys.js +31 -0
  18. data/app/assets/javascripts/translation_center/translations.js +245 -0
  19. data/app/assets/stylesheets/translation_center/application.css +49 -0
  20. data/app/assets/stylesheets/translation_center/bootstrap.css +5894 -0
  21. data/app/assets/stylesheets/translation_center/categories.css +29 -0
  22. data/app/assets/stylesheets/translation_center/center.css +28 -0
  23. data/app/assets/stylesheets/translation_center/inspector.css +110 -0
  24. data/app/assets/stylesheets/translation_center/translation_keys.css +48 -0
  25. data/app/assets/stylesheets/translation_center/translations.css +32 -0
  26. data/app/controllers/translation_center/application_controller.rb +42 -0
  27. data/app/controllers/translation_center/categories_controller.rb +61 -0
  28. data/app/controllers/translation_center/center_controller.rb +67 -0
  29. data/app/controllers/translation_center/translation_keys_controller.rb +93 -0
  30. data/app/controllers/translation_center/translations_controller.rb +78 -0
  31. data/app/helpers/translation_center/application_helper.rb +58 -0
  32. data/app/helpers/translation_center/categories_helper.rb +4 -0
  33. data/app/helpers/translation_center/center_helper.rb +19 -0
  34. data/app/helpers/translation_center/translation_keys_helper.rb +4 -0
  35. data/app/helpers/translation_center/translations_helper.rb +4 -0
  36. data/app/models/translation_center/activity_query.rb +46 -0
  37. data/app/models/translation_center/category.rb +46 -0
  38. data/app/models/translation_center/translation.rb +94 -0
  39. data/app/models/translation_center/translation_key.rb +188 -0
  40. data/app/views/layouts/translation_center/application.html.haml +82 -0
  41. data/app/views/translation_center/categories/_category.html.haml +11 -0
  42. data/app/views/translation_center/categories/index.html.haml +7 -0
  43. data/app/views/translation_center/categories/keys.js.haml +10 -0
  44. data/app/views/translation_center/categories/show.html.haml +32 -0
  45. data/app/views/translation_center/categories/show.js.haml +7 -0
  46. data/app/views/translation_center/center/_activity.html.haml +49 -0
  47. data/app/views/translation_center/center/dashboard.html.haml +102 -0
  48. data/app/views/translation_center/center/manage.js.haml +3 -0
  49. data/app/views/translation_center/center/search_activity.js.haml +1 -0
  50. data/app/views/translation_center/errors/exception.html.haml +50 -0
  51. data/app/views/translation_center/translation_keys/_form.html.haml +18 -0
  52. data/app/views/translation_center/translation_keys/_show.html.haml +27 -0
  53. data/app/views/translation_center/translation_keys/_show_keys.html.haml +25 -0
  54. data/app/views/translation_center/translation_keys/_translation_keys.html.haml +16 -0
  55. data/app/views/translation_center/translation_keys/destroy.js.haml +4 -0
  56. data/app/views/translation_center/translation_keys/show.html.haml +8 -0
  57. data/app/views/translation_center/translation_keys/translations.js.haml +3 -0
  58. data/app/views/translation_center/translations/_accept_translation.html.haml +6 -0
  59. data/app/views/translation_center/translations/_index.html.haml +9 -0
  60. data/app/views/translation_center/translations/_search_results.html.haml +30 -0
  61. data/app/views/translation_center/translations/_show.html.haml +35 -0
  62. data/app/views/translation_center/translations/accept.js.haml +18 -0
  63. data/app/views/translation_center/translations/destroy.js.haml +11 -0
  64. data/app/views/translation_center/translations/search.html.haml +2 -0
  65. data/app/views/translation_center/translations/search.js.haml +1 -0
  66. data/app/views/translation_center/translations/unaccept.js.haml +9 -0
  67. data/app/views/translation_center/translations/unvote.js.haml +1 -0
  68. data/app/views/translation_center/translations/vote.js.haml +1 -0
  69. data/config/routes.rb +34 -0
  70. data/lib/afalkear_translation_center.rb +12 -0
  71. data/lib/generators/translation_center/USAGE +6 -0
  72. data/lib/generators/translation_center/add_lang/add_lang_generator.rb +31 -0
  73. data/lib/generators/translation_center/add_lang/templates/migrations/add_lang_status_translation_keys.rb +5 -0
  74. data/lib/generators/translation_center/install/install_generator.rb +38 -0
  75. data/lib/generators/translation_center/install/templates/assets/translation_center_logo.png +0 -0
  76. data/lib/generators/translation_center/install/templates/config/translation_center.yml +55 -0
  77. data/lib/generators/translation_center/install/templates/migrations/create_translation_center_categories.rb +9 -0
  78. data/lib/generators/translation_center/install/templates/migrations/create_translation_center_translation_keys.rb +16 -0
  79. data/lib/generators/translation_center/install/templates/migrations/create_translation_center_translations.rb +32 -0
  80. data/lib/tasks/translation_center.rake +56 -0
  81. data/lib/translation_center/acts_as_translator.rb +22 -0
  82. data/lib/translation_center/engine.rb +15 -0
  83. data/lib/translation_center/locale/en.yml +75 -0
  84. data/lib/translation_center/translation_helpers.rb +133 -0
  85. data/lib/translation_center/translations_transfer.rb +131 -0
  86. data/lib/translation_center/version.rb +3 -0
  87. data/test/dummy/README.rdoc +261 -0
  88. data/test/dummy/Rakefile +7 -0
  89. data/test/dummy/app/assets/images/translation_center_logo.png +0 -0
  90. data/test/dummy/app/assets/javascripts/application.js +16 -0
  91. data/test/dummy/app/assets/javascripts/articles.js +2 -0
  92. data/test/dummy/app/assets/stylesheets/application.css +14 -0
  93. data/test/dummy/app/assets/stylesheets/articles.css +4 -0
  94. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  95. data/test/dummy/app/controllers/application_controller.rb +6 -0
  96. data/test/dummy/app/controllers/articles_controller.rb +85 -0
  97. data/test/dummy/app/helpers/application_helper.rb +2 -0
  98. data/test/dummy/app/helpers/articles_helper.rb +2 -0
  99. data/test/dummy/app/models/article.rb +7 -0
  100. data/test/dummy/app/models/user.rb +16 -0
  101. data/test/dummy/app/views/articles/_form.html.haml +16 -0
  102. data/test/dummy/app/views/articles/edit.html.haml +7 -0
  103. data/test/dummy/app/views/articles/index.html.haml +32 -0
  104. data/test/dummy/app/views/articles/new.html.haml +5 -0
  105. data/test/dummy/app/views/articles/show.html.haml +14 -0
  106. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  107. data/test/dummy/config/application.rb +60 -0
  108. data/test/dummy/config/boot.rb +10 -0
  109. data/test/dummy/config/database.yml +42 -0
  110. data/test/dummy/config/environment.rb +5 -0
  111. data/test/dummy/config/environments/development.rb +37 -0
  112. data/test/dummy/config/environments/production.rb +67 -0
  113. data/test/dummy/config/environments/test.rb +37 -0
  114. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  115. data/test/dummy/config/initializers/devise.rb +240 -0
  116. data/test/dummy/config/initializers/inflections.rb +15 -0
  117. data/test/dummy/config/initializers/mime_types.rb +5 -0
  118. data/test/dummy/config/initializers/secret_token.rb +7 -0
  119. data/test/dummy/config/initializers/session_store.rb +8 -0
  120. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  121. data/test/dummy/config/locales/ar.yml +6 -0
  122. data/test/dummy/config/locales/de.yml +2 -0
  123. data/test/dummy/config/locales/devise.en.yml +59 -0
  124. data/test/dummy/config/locales/en.yml +361 -0
  125. data/test/dummy/config/routes.rb +10 -0
  126. data/test/dummy/config/translation_center.yml +58 -0
  127. data/test/dummy/config.ru +4 -0
  128. data/test/dummy/db/migrate/20130410082611_devise_create_users.rb +46 -0
  129. data/test/dummy/db/migrate/20130410082701_create_articles.rb +10 -0
  130. data/test/dummy/db/migrate/20130410084711234392_create_translation_center_categories.rb +9 -0
  131. data/test/dummy/db/migrate/20130410084711235054_create_translation_center_translation_keys.rb +14 -0
  132. data/test/dummy/db/migrate/20130410084711235601_create_translation_center_translations.rb +13 -0
  133. data/test/dummy/db/migrate/20130410084711235602_install_audited.rb +28 -0
  134. data/test/dummy/db/migrate/20130410084711_acts_as_votable_migration.rb +23 -0
  135. data/test/dummy/db/migrate/20130410113111070575_add_de_status_translation_center_translation_keys.rb +5 -0
  136. data/test/dummy/db/migrate/20130417134539377014_add_ar_status_translation_center_translation_keys.rb +5 -0
  137. data/test/dummy/db/migrate/20130506103956_fix_translation_user_relation.rb +12 -0
  138. data/test/dummy/db/migrate/20130801102022_add_indicies.rb +8 -0
  139. data/test/dummy/db/schema.rb +110 -0
  140. data/test/dummy/log/test.log +0 -0
  141. data/test/dummy/public/404.html +26 -0
  142. data/test/dummy/public/422.html +26 -0
  143. data/test/dummy/public/500.html +25 -0
  144. data/test/dummy/public/favicon.ico +0 -0
  145. data/test/dummy/script/rails +6 -0
  146. data/test/dummy/spec/spec_helper.rb +38 -0
  147. data/test/dummy/test/fixtures/articles.yml +9 -0
  148. data/test/dummy/test/fixtures/posts.yml +9 -0
  149. data/test/dummy/test/fixtures/users.yml +11 -0
  150. data/test/dummy/test/functional/articles_controller_test.rb +49 -0
  151. data/test/dummy/test/functional/posts_controller_test.rb +49 -0
  152. data/test/dummy/test/unit/article_test.rb +7 -0
  153. data/test/dummy/test/unit/helpers/articles_helper_test.rb +4 -0
  154. data/test/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  155. data/test/dummy/test/unit/post_test.rb +7 -0
  156. data/test/dummy/test/unit/user_test.rb +7 -0
  157. data/test/fixtures/translation_center/categories.yml +7 -0
  158. data/test/fixtures/translation_center/translation_keys.yml +11 -0
  159. data/test/fixtures/translation_center/translations.yml +15 -0
  160. data/test/functional/translation_center/categories_controller_test.rb +51 -0
  161. data/test/functional/translation_center/center_controller_test.rb +9 -0
  162. data/test/functional/translation_center/translation_keys_controller_test.rb +51 -0
  163. data/test/functional/translation_center/translations_controller_test.rb +51 -0
  164. data/test/integration/navigation_test.rb +10 -0
  165. data/test/test_helper.rb +15 -0
  166. data/test/translation_center_test.rb +7 -0
  167. data/test/unit/helpers/translation_center/categories_helper_test.rb +6 -0
  168. data/test/unit/helpers/translation_center/center_helper_test.rb +6 -0
  169. data/test/unit/helpers/translation_center/translation_keys_helper_test.rb +6 -0
  170. data/test/unit/helpers/translation_center/translations_helper_test.rb +6 -0
  171. data/test/unit/translation_center/category_test.rb +9 -0
  172. data/test/unit/translation_center/translation_key_test.rb +9 -0
  173. data/test/unit/translation_center/translation_test.rb +9 -0
  174. metadata +418 -0
@@ -0,0 +1,3 @@
1
+ $('#operation_progress strong').text('Translations were transfered');
2
+ $('#operation_progress').addClass('alert-success');
3
+ $('#spinner').hide();
@@ -0,0 +1 @@
1
+ $('#activity').html("#{escape_javascript(render 'activity', translations_changes: @translations_changes)}");
@@ -0,0 +1,50 @@
1
+ .well
2
+
3
+ %h3
4
+ Opps an Error has Occured !
5
+ An error has occurred with
6
+ %a{href: "http://badrit.github.io/translation_center/"}
7
+ translation_center
8
+ , please help us fix this problem by hitting the send button below which will send the exception trace to us or you can open an issue on
9
+ %a{href: "https://github.com/BadrIT/translation_center/issues?state=open"}
10
+ github page of translation_center.
11
+ %br
12
+ %br
13
+
14
+ %form{:action => "http://translation-center.herokuapp.com/translation_center_feedbacks", :method => "POST"}
15
+ %fieldset
16
+ .control-group
17
+ %label.control-label{:for => "name"} Name (optional):
18
+ .controls
19
+ %input#name.input-xlarge{:name => "translation_center_feedback[name]", :placeholder => "", :type => "text"}/
20
+ .control-group
21
+ %label.control-label{:for => "email"} Email (optional):
22
+ .controls
23
+ %input#email.input-xlarge{:name => "translation_center_feedback[email]", :placeholder => " ", :type => "text"}/
24
+ .control-group
25
+ %label.control-label{:for => "subject"} Subject (optional):
26
+ .controls
27
+ %input#subject.input-xlarge{:name => "translation_center_feedback[subject]", :placeholder => "", :type => "text", value: "Translation Center Exception (version #{TranslationCenter::VERSION})"}/
28
+ .control-group
29
+ %label.control-label{:for => "subject"} Comments (optional):
30
+ .controls
31
+ %textarea#comments.input-xlarge{:name => "translation_center_feedback[comments]", :placeholder => "", :type => "text"}
32
+ .control-group
33
+ %label.control-label{:for => "message"} Message:
34
+ .controls
35
+ %textarea#message.input-xlarge{:name => "translation_center_feedback[message]", :placeholder => "Your message...", :rows => "3", :style => "margin: 0px; width: 99%; height: 130px; ", cols: 50}
36
+ = @path
37
+ 
38
+ = @exception.message
39
+ 
40
+ = "----------------------"
41
+ 
42
+ = @exception.backtrace.join("\n")
43
+ %br
44
+ .control-group
45
+ .controls
46
+ %script{:src => "http://www.google.com/recaptcha/api/challenge?k=6Leng90SAAAAAM9pUoRPnx-DO-qQI5XPkqqRTttl", :type => "text/javascript"}
47
+ %script{:src => "http://www.google.com/recaptcha/api/js/recaptcha.js", :type => "text/javascript"}
48
+
49
+ .form-actions
50
+ %button.btn.btn-warning.btn-large{:type => "submit"} SEND
@@ -0,0 +1,18 @@
1
+ = form_for(@translation_key) do |f|
2
+ - if @translation_key.errors.any?
3
+ #error_explanation
4
+ %h2
5
+ = pluralize(@translation_key.errors.count, "error")
6
+ prohibited this translation_key from being saved:
7
+ %ul
8
+ - @translation_key.errors.full_messages.each do |msg|
9
+ %li= msg
10
+ .field
11
+ = f.label :name
12
+ %br
13
+ = f.text_field :name
14
+ .field
15
+ = f.hidden_field :category_id, value: @category.id
16
+
17
+ .actions
18
+ = f.submit
@@ -0,0 +1,27 @@
1
+ %div{ class: "#{index == 0 ? 'tab-pane active' : 'tab-pane' }", id: translation_key.id }
2
+ %p
3
+ .tabbable
4
+ %ul.nav.nav-tabs
5
+
6
+ %li.active
7
+ %a.translations_tab{'data-key-id' => translation_key.id, "data-toggle" => "tab", :href => "#translations#{translation_key.id}"}
8
+ %span.badge.badge-info.pull-left.translations_count{ id: "translations_#{translation_key.id}_count"}
9
+ = translation_key.translations.in(to_lang).count
10
+ %span
11
+ = t('.translations')
12
+
13
+ %li
14
+ %a{"data-toggle" => "tab", :href => "#add_translations#{translation_key.id}"}
15
+ = t('.add_edit_translation')
16
+ .tab-content
17
+
18
+ .tab-pane.active{ id: "translations#{translation_key.id}" }
19
+ = render 'translation_center/translations/index', translations: translation_key.translations.order('created_at DESC').in(to_lang), translation_key: translation_key
20
+ .tab-pane{ id: "add_translations#{translation_key.id}" }
21
+
22
+ %em
23
+ %b
24
+ = t(translation_key.name)
25
+ %hr
26
+ %div{ class: "user_translation well well-small #{language_direction(to_lang)}", 'data-key-id' => translation_key.id }
27
+ = current_user.translation_for(translation_key, to_lang).value
@@ -0,0 +1,25 @@
1
+ %li{ class: "#{index == 0 ? 'well well-small active translation_key' : 'well well-small translation_key' }", 'data-key-id' => translation_key.id}
2
+ - if translation_key.accepted_in?(to_lang)
3
+ .translation_key_badge.badge-success{title: t('.translated')}
4
+ - elsif translation_key.no_translations_in?(to_lang)
5
+ .translation_key_badge.badge-important{title: t('.untranslated')}
6
+ - else
7
+ .translation_key_badge.badge-warning{title: t('.waiting_acceptance')}
8
+
9
+ - if translation_admin?
10
+ %div
11
+ = link_to '×', translation_key_path(translation_key), method: :delete, data: { confirm: t('translation_center.actions.are_you_sure', :default => 'Are you sure?') }, class: 'close', remote: true
12
+
13
+ %a{ href: "##{translation_key.id}", 'data-toggle' => "tab"}
14
+ %p
15
+ %b
16
+ %em
17
+ = t(translation_key.name)
18
+ %span
19
+ %em.created_time
20
+ = t('.created_on')
21
+ = format_date(translation_key.created_at)
22
+
23
+ %small
24
+ %div{ 'data-key-id' => translation_key.id, class: "#{translation_admin? ? 'key_editable' : '' }"}
25
+ = translation_key.name
@@ -0,0 +1,16 @@
1
+ - if translation_keys.empty?
2
+ .alert.alert-info
3
+ = t('.no_translation_keys')
4
+ - else
5
+ .tabbable.tabs-left.all_listing
6
+
7
+ %ul.nav.nav-tabs.translation_keys_listing
8
+ - translation_keys.each_with_index do |translation_key, index|
9
+ = render 'translation_center/translation_keys/show_keys', translation_key: translation_key, index: index
10
+
11
+
12
+ .tab-content.translations_listing
13
+ - translation_keys.each_with_index do |translation_key, index|
14
+ = render 'translation_center/translation_keys/show', translation_key: translation_key, index: index
15
+
16
+
@@ -0,0 +1,4 @@
1
+ moveToNextKey("#{@translation_key_id}")
2
+
3
+ decrement#{@key_status.camelize}();
4
+ decrementAll();
@@ -0,0 +1,8 @@
1
+ = link_to "#{t('.back_to_category')} #{@translation_key.category.name.titleize}", @translation_key.category, class: 'btn btn-primary'
2
+
3
+ %h1
4
+ = @translation_key.name
5
+ - if translation_admin?
6
+ = link_to t('.destroy'), @translation_key, method: :delete, data: { confirm: t('translation_center.actions.are_you_sure', :default => 'Are you sure?') }, class: 'btn btn-danger'
7
+
8
+ = render 'translation_center/translation_keys/show', translation_key: @translation_key, index: 0
@@ -0,0 +1,3 @@
1
+ $('#translations' + "#{@translation_key.id}").html("#{escape_javascript(render 'translation_center/translations/index', translations: @translations, translation_key: @translation_key)}")
2
+
3
+ $("#translations_#{@translation_key.id}_count").text("#{@translations.length}")
@@ -0,0 +1,6 @@
1
+ - if translation.accepted?
2
+ %button.unaccept_translation.btn.btn-success{ 'data-translation-id' => translation.id }
3
+ = t('.unaccept')
4
+ - else
5
+ %button.accept_translation.btn.btn-success{ 'data-translation-id' => translation.id }
6
+ = t('.accept')
@@ -0,0 +1,9 @@
1
+ = t('.sort_by')
2
+ %a.sort_by_date{ href: '#', 'data-key-id' => translation_key.id }
3
+ = t('.date')
4
+ %hr
5
+ - translations.each do |translation|
6
+ = render 'translation_center/translations/show', translation: translation
7
+ - if translation_key.translations.in(to_lang).empty?
8
+ .alert.alert-error
9
+ = t('.no_translations_available')
@@ -0,0 +1,30 @@
1
+ %h2= t('translation_center.center.search.title', value: params[:translation_value])
2
+
3
+ .pagination
4
+
5
+ - if @page != 1
6
+ = link_to t('pagination.first'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=1"
7
+ |
8
+ = link_to t('pagination.prev'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}&page=#{@page - 1}"
9
+ |
10
+
11
+ - if @total_pages != 1 && @page != @total_pages
12
+
13
+ = link_to t('pagination.next'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}&page=#{@page + 1}"
14
+ - if @page != @total_pages
15
+ |
16
+ = link_to t('pagination.last'), "#{request.protocol}#{request.host_with_port}#{request.fullpath.gsub('&page=' + @page.to_s, '')}?&page=#{@total_pages}"
17
+ = @page
18
+ = t('.of')
19
+ = @total_pages
20
+
21
+
22
+ %div
23
+ - translations.each do |translation|
24
+ %a.category{ href: translation_key_path(id: translation.key, lang_to: translation.lang), title: translation.key.name }
25
+ .category_name
26
+ = truncate(translation.key.name, length: 35)
27
+ %div
28
+ %span.label.label-success
29
+ = truncate(translation.value.to_s, length: 35)
30
+
@@ -0,0 +1,35 @@
1
+ .well.well-small.translation_box{ id: "translation_id_#{translation.id}", 'data-key-id' => translation.translation_key.id }
2
+
3
+ %div{class: "translation_info #{language_direction(to_lang)}"}
4
+ %span
5
+ = translation.value
6
+
7
+ - if translation_admin?
8
+ = link_to '×', translation_path(translation), method: :delete, data: { confirm: t('translation_center.actions.are_you_sure', :default => 'Are you sure?') }, class: 'close', remote: true
9
+ %br
10
+ %br
11
+ %small.pull-right
12
+ %em
13
+ = t('.by')
14
+ - if translation.translator == current_user
15
+ = t('.you')
16
+ - else
17
+ = translation.translator.send(TranslationCenter::CONFIG['identifier_type'])
18
+ = t('.on_date')
19
+ = format_date(translation.created_at)
20
+ %div.translation_voting
21
+ - if translation_admin?
22
+ = render 'translation_center/translations/accept_translation', translation: translation
23
+ .votes_count.badge.badge-success.pull-right
24
+ %span.count{ 'data-translation-id' => translation.id }
25
+
26
+ = t('.votings')
27
+ %a.pull-right{href: '#'}
28
+ - voted = current_user.voted_on?(translation)
29
+ %span.badge.pull-left.translations_vote{ class: "#{voted ? 'badge-success' : ''}", 'data-translation-id' => translation.id, voted: voted.to_s}
30
+ - if voted
31
+ = t('.unvote')
32
+ - else
33
+ = t('.vote')
34
+
35
+
@@ -0,0 +1,18 @@
1
+ - if(current_filter_is?('all'))
2
+ $('li.translation_key[data-key-id=' + "#{@translation.key.id}" + ']').children('div').removeClass('badge-warning').addClass('badge-success');
3
+ #{@translation_already_accepted}
4
+ - if(!@translation_already_accepted)
5
+ decrementPending();
6
+ incrementTranslated();
7
+ - elsif(current_filter_is?('pending'))
8
+ incrementTranslated();
9
+ decrementPending();
10
+ moveToNextKey($('#translation_id_' + "#{@translation.id}").attr('data-key-id'));
11
+
12
+
13
+ // TODO USE i18n for text
14
+ // changing existing unaccept to accept
15
+ $('button.unaccept_translation').addClass('accept_translation').removeClass('unaccept_translation').text('Accept');
16
+
17
+ // TODO USE i18n for text
18
+ $('#translation_id_' + "#{@translation.id}").find('.accept_translation').removeClass('accept_translation').addClass('unaccept_translation').text('Unaccept');
@@ -0,0 +1,11 @@
1
+ $('#translation_id_' + "#{@translation_id}").fadeOut();
2
+ var count = parseInt($('#translations_' + "#{@translation_key_id}" + '_count').text()) - 1;
3
+ $('#translations_' + "#{@translation_key_id}" + '_count').text(count);
4
+ decrement#{@translation_key_before_status.camelize}();
5
+ increment#{@translation_key_after_status.camelize}();
6
+
7
+ - if @translation_key_after_status != @translation_key_before_status
8
+ if(Filter.key() != 'all')
9
+ {
10
+ moveToNextKey("#{@translation_id}")
11
+ }
@@ -0,0 +1,2 @@
1
+ #translations_search_result
2
+ = render 'search_results', translations: @translations
@@ -0,0 +1 @@
1
+ $('#translations_search_result').html("#{escape_javascript(render 'search_results', translations: @translations)}")
@@ -0,0 +1,9 @@
1
+ - if(current_filter_is?('all'))
2
+ $('li.translation_key[data-key-id=' + "#{@translation.key.id}" + ']').children('div').removeClass('badge-success').addClass('badge-warning');
3
+
4
+ - else
5
+ moveToNextKey($('#translation_id_' + "#{@translation.id}").attr('data-key-id'));
6
+
7
+ incrementPending();
8
+ decrementTranslated();
9
+ $('#translation_id_' + "#{@translation.id}").find('.unaccept_translation').removeClass('unaccept_translation').addClass('accept_translation').text('Accept')
@@ -0,0 +1 @@
1
+ $(".count[data-translation-id=#{@translation.id}]").text("#{@translation.likes.count}")
@@ -0,0 +1 @@
1
+ $(".count[data-translation-id=#{@translation.id}]").text("#{@translation.likes.count}");
data/config/routes.rb ADDED
@@ -0,0 +1,34 @@
1
+ TranslationCenter::Engine.routes.draw do
2
+
3
+ resources :translations do
4
+ post :vote
5
+ post :unvote
6
+ post :accept
7
+ post :unaccept
8
+ collection do
9
+ get :search
10
+ end
11
+ end
12
+
13
+ resources :translation_keys, except: :create do
14
+ post :update_translation
15
+ get :translations
16
+ collection do
17
+ get :search
18
+ end
19
+ end
20
+
21
+ resources :categories do
22
+ get :more_keys
23
+ end
24
+
25
+ get '/dashboard' => 'center#dashboard', as: :dashboard
26
+ get '/search_activity' => 'center#search_activity', as: :search_activity
27
+ post '/manage_translations' => 'center#manage', as: :manage_translations
28
+
29
+ root to: 'categories#index'
30
+
31
+ # set the language from and to for the user
32
+ match "/set_language_from" => 'center#set_language_from', as: :set_lang_from, :via => :get
33
+ match "/set_language_to" => 'center#set_language_to', as: :set_lang_to, :via => :get
34
+ end
@@ -0,0 +1,12 @@
1
+ require "translation_center/engine"
2
+ require "translation_center/acts_as_translator"
3
+ require "translation_center/translation_helpers"
4
+ require "translation_center/translations_transfer"
5
+
6
+ module TranslationCenter
7
+
8
+ # add translations for translations center
9
+ I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'translation_center', 'locale', '*.yml')]
10
+ end
11
+
12
+
@@ -0,0 +1,6 @@
1
+ Description:
2
+ Run this generator to get the needed migrations and initializer to build the translation center
3
+
4
+ Example:
5
+ rails generate translation_center:install
6
+
@@ -0,0 +1,31 @@
1
+ module TranslationCenter
2
+
3
+ class AddLangGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+ source_root File.expand_path('../templates', __FILE__)
6
+ argument :langs, type: :array
7
+
8
+ def self.next_migration_number(path)
9
+ @migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S%6N").to_i.to_s
10
+ end
11
+
12
+ def add_lang
13
+ if langs.blank?
14
+ puts 'Please provide a language to add to the translation center'
15
+ return
16
+ end
17
+
18
+ langs.each do |lang|
19
+ @lang = lang
20
+ # check if language already supported
21
+ if(TranslationCenter::TranslationKey.column_names.include? "#{lang.downcase.gsub("-","_")}_status")
22
+ puts 'This language is already supported, just make sure it is listed in config/translation_center.yml'
23
+ return
24
+ end
25
+ # Generate migration templates for the models needed
26
+ migration_template 'migrations/add_lang_status_translation_keys.rb', "db/migrate/add_#{lang.downcase.gsub("-","_")}_status_translation_center_translation_keys.rb"
27
+ end
28
+ puts "Language(s) added, don't forget to add the language(s) to config/translation_center.yml"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ class Add<%= @lang.split("-").collect {|s| s.capitalize}.join %>StatusTranslationCenterTranslationKeys < ActiveRecord::Migration
2
+ def change
3
+ add_column :translation_center_translation_keys, :<%= @lang.downcase.gsub('-','_') %>_status, :string, default: 'untranslated'
4
+ end
5
+ end
@@ -0,0 +1,38 @@
1
+ module TranslationCenter
2
+
3
+ class InstallGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+ source_root File.expand_path('../templates', __FILE__)
6
+ argument :langs, type: :array, :default => ['en']
7
+
8
+ def self.next_migration_number(path)
9
+ @migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S%6N").to_i.to_s
10
+ end
11
+
12
+ def install_translation
13
+ # Generate migration templates for the models needed
14
+ migration_template 'migrations/create_translation_center_categories.rb', 'db/migrate/create_translation_center_categories.rb'
15
+ migration_template 'migrations/create_translation_center_translation_keys.rb', 'db/migrate/create_translation_center_translation_keys.rb'
16
+ migration_template 'migrations/create_translation_center_translations.rb', 'db/migrate/create_translation_center_translations.rb'
17
+
18
+ # generate votes if it doesn't already exist
19
+ unless ActiveRecord::Base.connection.table_exists? 'votes'
20
+ Rails::Generators.invoke('acts_as_votable:migration')
21
+ end
22
+
23
+ copy_file 'config/translation_center.yml', 'config/translation_center.yml'
24
+
25
+ # user can replace this logo to change the logo
26
+ copy_file 'assets/translation_center_logo.png', 'app/assets/images/translation_center_logo.png'
27
+
28
+ sleep(1) # to avoid duplicate migrations between acts_as_votable and auditable
29
+
30
+ unless ActiveRecord::Base.connection.table_exists? 'audits'
31
+ # we use audited for tracking activity
32
+ Rails::Generators.invoke('audited:install')
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,55 @@
1
+ common_atts: &common_atts
2
+ # what language to support and their display names
3
+ lang:
4
+ en:
5
+ name: 'English'
6
+ direction: 'ltr'
7
+ # ar:
8
+ # name: 'Arabic'
9
+ # direction: 'rtl'
10
+
11
+ # yaml imported translations created by translator email, usually User email
12
+ yaml_translator_identifier: 'coder@tc.com'
13
+
14
+ # when import translation from yaml to db set it to accepted by default
15
+ yaml2db_translations_accepted: true # default is false
16
+
17
+ # when admins add/edit translations they are considered accepted directly
18
+ accept_admin_translations: true
19
+
20
+ # identifier_type: 'email' # Uncomment and change the identifier if your User model has no email attribute
21
+ # translator_type: 'User' # Uncomment and change if you want to change the translator type
22
+
23
+ development:
24
+ enabled: true # default false
25
+
26
+ # Keys inspector allowed values:
27
+ # "missing" to inspect only untranslated keys
28
+ # "all" to enable inspector for translated and untranslated keys
29
+ # "off" to turn off keys inspector
30
+ inspector: 'missing' # default missing
31
+
32
+ # I18n.translate source
33
+ i18n_source: 'db' # can be db or yaml; default is db
34
+
35
+ # when a new key is added to db, the value of the key is added as the default translation in English
36
+ save_default_translation: true
37
+
38
+ <<: *common_atts
39
+
40
+ production:
41
+ enabled: true # default false
42
+
43
+ # Keys inspector allowed values:
44
+ # "missing" to inspect only untranslated keys
45
+ # "all" to enable inspector for translated and untranslated keys
46
+ # "off" to turn off keys inspector
47
+ inspector: 'off' # default missing
48
+
49
+ # I18n.translate source
50
+ i18n_source: 'yaml' # can be db or yaml; default is yaml
51
+
52
+ # when a new key is added to db, the value of the key is added as the default translation in English
53
+ save_default_translation: false
54
+
55
+ <<: *common_atts
@@ -0,0 +1,9 @@
1
+ class CreateTranslationCenterCategories < ActiveRecord::Migration
2
+ def change
3
+ create_table :translation_center_categories do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ class CreateTranslationCenterTranslationKeys < ActiveRecord::Migration
2
+ def change
3
+ create_table :translation_center_translation_keys do |t|
4
+ t.string :name
5
+ t.integer :category_id
6
+ t.datetime :last_accessed
7
+ <% langs.each do |lang| %>
8
+ t.string :<%= lang.downcase.gsub('-','_') %>_status, default: 'untranslated'
9
+ <% end %>
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ add_index :translation_center_translation_keys, :name
15
+ end
16
+ end
@@ -0,0 +1,32 @@
1
+ class CreateTranslationCenterTranslations < ActiveRecord::Migration
2
+ def change
3
+ # if mysql
4
+ if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter).present? && ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
5
+
6
+ create_table :translation_center_translations, options: 'CHARACTER SET=utf8' do |t|
7
+ t.integer :translation_key_id
8
+ t.text :value
9
+ t.string :lang
10
+ t.references :translator, polymorphic: true
11
+ t.string :status, default: 'pending'
12
+
13
+ t.timestamps
14
+ end
15
+
16
+ else
17
+
18
+ create_table :translation_center_translations do |t|
19
+ t.integer :translation_key_id
20
+ t.text :value
21
+ t.string :lang
22
+ t.references :translator, polymorphic: true
23
+ t.string :status, default: 'pending'
24
+
25
+ t.timestamps
26
+ end
27
+
28
+ end
29
+
30
+ add_index :translation_center_translations, :translation_key_id
31
+ end
32
+ end
@@ -0,0 +1,56 @@
1
+ require "uri"
2
+ require "net/http"
3
+
4
+ namespace :translation_center do
5
+
6
+ def send_exception(exception)
7
+ puts "An error has ocurred while performing this rake, would you like to send the exception to us so we may fix this problem ? press [Y/n]"
8
+ confirm = $stdin.gets.chomp
9
+
10
+ if confirm.blank? || confirm == 'y' || confirm == 'yes'
11
+ puts 'Sending ...'
12
+ params = {message: "#{exception.message} #{exception.backtrace.join("\n")}"}
13
+ Net::HTTP.post_form(URI.parse('http://translation-center.herokuapp.com/translation_center_feedbacks/create_rake'), params)
14
+ puts 'We have received your feedback. Thanks!'
15
+ end
16
+
17
+ # show the exception message
18
+ puts exception.message
19
+ puts exception.backtrace.join("\n")
20
+ end
21
+
22
+ desc "Insert yaml translations in db"
23
+ task :yaml2db, [:locale ] => :environment do |t, args|
24
+ begin
25
+ TranslationCenter.yaml2db(args[:locale])
26
+ rescue Exception => e
27
+ send_exception(e)
28
+ end
29
+ end
30
+
31
+ desc "Export translations from db to yaml"
32
+ task :db2yaml, [:locale ] => :environment do |t, args|
33
+ begin
34
+ TranslationCenter.db2yaml(args[:locale])
35
+ rescue Exception => e
36
+ send_exception(e)
37
+ end
38
+ end
39
+
40
+ desc "Calls yaml2db then db2yaml"
41
+ task :synch, [:locale ] => :environment do |t, args|
42
+ begin
43
+ if TranslationCenter::Category.any?
44
+ puts "WARNING: You already have translations stored in the db, do you want to destroy them? press [Y|n]"
45
+ confirm = $stdin.gets.chomp
46
+
47
+ TranslationCenter::Category.destroy_all if confirm.blank? || confirm == 'y' || confirm == 'yes'
48
+ end
49
+ TranslationCenter.yaml2db(args[:locale])
50
+ TranslationCenter.db2yaml(args[:locale])
51
+ rescue Exception => e
52
+ send_exception(e)
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,22 @@
1
+ module ActsAsTranslator
2
+ def acts_as_translator
3
+ has_many :translations, foreign_key: :translator_id, class_name: 'TranslationCenter::Translation'
4
+ acts_as_voter
5
+
6
+ include InstanceMethods
7
+ end
8
+
9
+ module InstanceMethods
10
+ # returns the translation a user has made for a certain key in a certain language
11
+ def translation_for(key, lang)
12
+ self.translations.find_or_initialize_by_translation_key_id_and_lang_and_translator_type(key.id, lang.to_s, self.class.name)
13
+ end
14
+
15
+ # returns true if the user can admin translations
16
+ def can_admin_translations?
17
+ true
18
+ end
19
+ end
20
+ end
21
+
22
+ ActiveRecord::Base.extend ActsAsTranslator