i18n_backend_database 0.0.1

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.
Files changed (67) hide show
  1. data/LICENSE +29 -0
  2. data/README.textile +125 -0
  3. data/data/locales.yml +4 -0
  4. data/generators/i18n_backend_database/i18n_backend_database_generator.rb +8 -0
  5. data/generators/i18n_backend_database/templates/migrate/create_i18n_tables.rb +25 -0
  6. data/init.rb +1 -0
  7. data/lib/controllers/locales_controller.rb +86 -0
  8. data/lib/controllers/translations_controller.rb +141 -0
  9. data/lib/ext/i18n.rb +68 -0
  10. data/lib/google_language.rb +33 -0
  11. data/lib/i18n_backend_database.rb +9 -0
  12. data/lib/i18n_backend_database/database.rb +263 -0
  13. data/lib/i18n_util.rb +148 -0
  14. data/lib/models/locale.rb +67 -0
  15. data/lib/models/translation.rb +46 -0
  16. data/lib/models/translation_option.rb +26 -0
  17. data/lib/public/images/custom1_bar.gif +0 -0
  18. data/lib/public/images/custom1_box.gif +0 -0
  19. data/lib/public/images/percentImage.png +0 -0
  20. data/lib/public/images/percentImage_back.png +0 -0
  21. data/lib/public/images/percentImage_back1.png +0 -0
  22. data/lib/public/images/percentImage_back2.png +0 -0
  23. data/lib/public/images/percentImage_back3.png +0 -0
  24. data/lib/public/images/percentImage_back4.png +0 -0
  25. data/lib/public/javascripts/jsProgressBarHandler.js +509 -0
  26. data/lib/routing.rb +15 -0
  27. data/lib/views/layouts/translations.html.erb +23 -0
  28. data/lib/views/locales/edit.html.erb +20 -0
  29. data/lib/views/locales/index.html.erb +22 -0
  30. data/lib/views/locales/new.html.erb +19 -0
  31. data/lib/views/locales/show.html.erb +14 -0
  32. data/lib/views/translations/asset_translations.html.erb +32 -0
  33. data/lib/views/translations/edit.html.erb +35 -0
  34. data/lib/views/translations/index.html.erb +27 -0
  35. data/lib/views/translations/new.html.erb +19 -0
  36. data/lib/views/translations/show.html.erb +32 -0
  37. data/lib/views/translations/translations.html.erb +28 -0
  38. data/lib/views/translations/update.rjs +7 -0
  39. data/routes.rb +3 -0
  40. data/spec/assets/public/es/favicons/favicon1.gif +0 -0
  41. data/spec/assets/public/es/images/icons/icon1.gif +0 -0
  42. data/spec/assets/public/es/images/image1.gif +0 -0
  43. data/spec/assets/public/favicons/favicon1.gif +0 -0
  44. data/spec/assets/public/favicons/favicon2.gif +0 -0
  45. data/spec/assets/public/images/icons/icon1.gif +0 -0
  46. data/spec/assets/public/images/icons/icon2.gif +0 -0
  47. data/spec/assets/public/images/image1.gif +0 -0
  48. data/spec/assets/public/images/image2.gif +0 -0
  49. data/spec/assets/public/images/promo/sfc08_140x400_3.gif +0 -0
  50. data/spec/assets/views/test_view1.html.erb +1 -0
  51. data/spec/assets/views/test_view2.html.erb +30 -0
  52. data/spec/caching_spec.rb +87 -0
  53. data/spec/controllers/locales_controller_spec.rb +173 -0
  54. data/spec/controllers/locales_routing_spec.rb +59 -0
  55. data/spec/controllers/translations_controller_spec.rb +189 -0
  56. data/spec/controllers/translations_routing_spec.rb +59 -0
  57. data/spec/database_spec.rb +199 -0
  58. data/spec/i18n_ext_spec.rb +40 -0
  59. data/spec/localize_spec.rb +66 -0
  60. data/spec/localize_text_spec.rb +76 -0
  61. data/spec/models/locale_spec.rb +111 -0
  62. data/spec/models/translation_spec.rb +44 -0
  63. data/spec/spec_helper.rb +16 -0
  64. data/spec/translate_asset_spec.rb +57 -0
  65. data/spec/translate_spec.rb +546 -0
  66. data/tasks/i18n.rake +60 -0
  67. metadata +155 -0
data/tasks/i18n.rake ADDED
@@ -0,0 +1,60 @@
1
+ def load_default_locales(path_to_file=nil)
2
+ path_to_file ||= File.join(File.dirname(__FILE__), "../data", "locales.yml")
3
+ data = YAML::load(IO.read(path_to_file))
4
+ data.each do |code, y|
5
+ Locale.create({:code => code, :name => y["name"]}) unless Locale.exists?(:code => code)
6
+ end
7
+ end
8
+
9
+ namespace :i18n do
10
+ desc 'Clear cache'
11
+ task :clear_cache => :environment do
12
+ I18n.backend.cache_store.clear
13
+ end
14
+
15
+ desc 'Install admin panel assets'
16
+ task :install_admin_assets => :environment do
17
+ images_dir = Rails.root + '/public/images/'
18
+ javascripts_dir = Rails.root + '/public/javascripts/'
19
+ images = Dir[File.join(File.dirname(__FILE__), '..') + '/lib/public/images/*.*']
20
+ scripts = Dir[File.join(File.dirname(__FILE__), '..') + '/lib/public/javascripts/*.*']
21
+ FileUtils.cp(images, images_dir)
22
+ FileUtils.cp(scripts, javascripts_dir)
23
+ end
24
+
25
+ namespace :populate do
26
+ desc 'Populate the locales and translations tables from all Rails Locale YAML files. Can set LOCALE_YAML_FILES to comma separated list of files to overide'
27
+ task :from_rails => :environment do
28
+ yaml_files = ENV['LOCALE_YAML_FILES'] ? ENV['LOCALE_YAML_FILES'].split(',') : I18n.load_path
29
+ yaml_files.each do |file|
30
+ I18nUtil.load_from_yml file
31
+ end
32
+ end
33
+
34
+ desc 'Populate the translation tables from translation calls within the application. This only works on basic text translations. Can set DIR to override starting directory.'
35
+ task :from_application => :environment do
36
+ dir = ENV['DIR'] ? ENV['DIR'] : "."
37
+ I18nUtil.seed_application_translations(dir)
38
+ end
39
+
40
+ desc 'Create translation records from all default locale translations if none exists.'
41
+ task :synchronize_translations => :environment do
42
+ I18nUtil.synchronize_translations
43
+ end
44
+
45
+ desc 'Populate default locales'
46
+ task :load_default_locales => :environment do
47
+ load_default_locales(ENV['LOCALE_FILE'])
48
+ end
49
+
50
+ desc 'Runs all populate methods in this order: load_default_locales, from_rails, from_application, synchronize_translations'
51
+ task :all => ["load_default_locales", "from_rails", "from_application", "synchronize_translations"]
52
+ end
53
+
54
+ namespace :translate do
55
+ desc 'Translate all untranslated values using Google Language Translation API. Does not translate interpolated strings, date formats, or YAML'
56
+ task :google => :environment do
57
+ I18nUtil.google_translate
58
+ end
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n_backend_database
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Dylan Stamat
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-22 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: i18n
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: A database backend for Rails i18n
34
+ email: dstamat@elctech.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - LICENSE
41
+ - README.textile
42
+ files:
43
+ - LICENSE
44
+ - README.textile
45
+ - data/locales.yml
46
+ - generators/i18n_backend_database/i18n_backend_database_generator.rb
47
+ - generators/i18n_backend_database/templates/migrate/create_i18n_tables.rb
48
+ - init.rb
49
+ - lib/controllers/locales_controller.rb
50
+ - lib/controllers/translations_controller.rb
51
+ - lib/ext/i18n.rb
52
+ - lib/google_language.rb
53
+ - lib/i18n_backend_database.rb
54
+ - lib/i18n_backend_database/database.rb
55
+ - lib/i18n_util.rb
56
+ - lib/models/locale.rb
57
+ - lib/models/translation.rb
58
+ - lib/models/translation_option.rb
59
+ - lib/public/images/custom1_bar.gif
60
+ - lib/public/images/custom1_box.gif
61
+ - lib/public/images/percentImage.png
62
+ - lib/public/images/percentImage_back.png
63
+ - lib/public/images/percentImage_back1.png
64
+ - lib/public/images/percentImage_back2.png
65
+ - lib/public/images/percentImage_back3.png
66
+ - lib/public/images/percentImage_back4.png
67
+ - lib/public/javascripts/jsProgressBarHandler.js
68
+ - lib/routing.rb
69
+ - lib/views/layouts/translations.html.erb
70
+ - lib/views/locales/edit.html.erb
71
+ - lib/views/locales/index.html.erb
72
+ - lib/views/locales/new.html.erb
73
+ - lib/views/locales/show.html.erb
74
+ - lib/views/translations/asset_translations.html.erb
75
+ - lib/views/translations/edit.html.erb
76
+ - lib/views/translations/index.html.erb
77
+ - lib/views/translations/new.html.erb
78
+ - lib/views/translations/show.html.erb
79
+ - lib/views/translations/translations.html.erb
80
+ - lib/views/translations/update.rjs
81
+ - routes.rb
82
+ - spec/assets/public/es/favicons/favicon1.gif
83
+ - spec/assets/public/es/images/icons/icon1.gif
84
+ - spec/assets/public/es/images/image1.gif
85
+ - spec/assets/public/favicons/favicon1.gif
86
+ - spec/assets/public/favicons/favicon2.gif
87
+ - spec/assets/public/images/icons/icon1.gif
88
+ - spec/assets/public/images/icons/icon2.gif
89
+ - spec/assets/public/images/image1.gif
90
+ - spec/assets/public/images/image2.gif
91
+ - spec/assets/public/images/promo/sfc08_140x400_3.gif
92
+ - spec/assets/views/test_view1.html.erb
93
+ - spec/assets/views/test_view2.html.erb
94
+ - spec/caching_spec.rb
95
+ - spec/controllers/locales_controller_spec.rb
96
+ - spec/controllers/locales_routing_spec.rb
97
+ - spec/controllers/translations_controller_spec.rb
98
+ - spec/controllers/translations_routing_spec.rb
99
+ - spec/database_spec.rb
100
+ - spec/i18n_ext_spec.rb
101
+ - spec/localize_spec.rb
102
+ - spec/localize_text_spec.rb
103
+ - spec/models/locale_spec.rb
104
+ - spec/models/translation_spec.rb
105
+ - spec/spec_helper.rb
106
+ - spec/translate_asset_spec.rb
107
+ - spec/translate_spec.rb
108
+ - tasks/i18n.rake
109
+ has_rdoc: true
110
+ homepage: http://github.com/dylanz/i18n_backend_database
111
+ licenses: []
112
+
113
+ post_install_message:
114
+ rdoc_options:
115
+ - --charset=UTF-8
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ segments:
124
+ - 0
125
+ version: "0"
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ requirements: []
135
+
136
+ rubyforge_project:
137
+ rubygems_version: 1.3.7
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: A database backend for Rails i18n
141
+ test_files:
142
+ - spec/caching_spec.rb
143
+ - spec/controllers/locales_controller_spec.rb
144
+ - spec/controllers/locales_routing_spec.rb
145
+ - spec/controllers/translations_controller_spec.rb
146
+ - spec/controllers/translations_routing_spec.rb
147
+ - spec/database_spec.rb
148
+ - spec/i18n_ext_spec.rb
149
+ - spec/localize_spec.rb
150
+ - spec/localize_text_spec.rb
151
+ - spec/models/locale_spec.rb
152
+ - spec/models/translation_spec.rb
153
+ - spec/spec_helper.rb
154
+ - spec/translate_asset_spec.rb
155
+ - spec/translate_spec.rb