motiro 0.6.3
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/LICENSE +280 -0
- data/README +28 -0
- data/README.en +175 -0
- data/README.pt-br +175 -0
- data/Rakefile +10 -0
- data/app/controllers/account_controller.rb +62 -0
- data/app/controllers/application.rb +72 -0
- data/app/controllers/edition_controller.rb +13 -0
- data/app/controllers/javascript_controller.rb +21 -0
- data/app/controllers/report_controller.rb +79 -0
- data/app/controllers/root_controller.rb +7 -0
- data/app/controllers/wiki_controller.rb +102 -0
- data/app/core/cache_reporter.rb +53 -0
- data/app/core/cache_reporter_fetcher.rb +33 -0
- data/app/core/chief_editor.rb +69 -0
- data/app/core/reporter.rb +105 -0
- data/app/core/reporter_driver.rb +36 -0
- data/app/core/reporter_fetcher.rb +39 -0
- data/app/core/settings.rb +43 -0
- data/app/core/version.rb +1 -0
- data/app/core/wiki_page_not_found.rb +33 -0
- data/app/core/wiki_reporter.rb +83 -0
- data/app/helpers/account_helper.rb +2 -0
- data/app/helpers/application_helper.rb +68 -0
- data/app/helpers/default_page_provider.rb +28 -0
- data/app/helpers/report_helper.rb +2 -0
- data/app/helpers/root_helper.rb +2 -0
- data/app/helpers/wiki_helper.rb +3 -0
- data/app/models/change.rb +96 -0
- data/app/models/diff_table_builder.rb +285 -0
- data/app/models/event.rb +18 -0
- data/app/models/headline.rb +109 -0
- data/app/models/page.rb +114 -0
- data/app/models/page_sweeper.rb +26 -0
- data/app/models/user.rb +85 -0
- data/app/ports/chdir_runner.rb +36 -0
- data/app/ports/reporter_loader.rb +9 -0
- data/app/ports/runner.rb +64 -0
- data/app/reporters/darcs_connection.rb +54 -0
- data/app/reporters/darcs_reporter.rb +104 -0
- data/app/reporters/darcs_settings.rb +9 -0
- data/app/reporters/darcs_temp_repo.rb +40 -0
- data/app/reporters/events_reporter.rb +28 -0
- data/app/reporters/features_reporter.rb +24 -0
- data/app/reporters/subversion_reporter.rb +203 -0
- data/app/reporters/svn_connection.rb +62 -0
- data/app/reporters/svn_settings.rb +40 -0
- data/app/views/account/_authorization.rhtml +54 -0
- data/app/views/account/_availability.rhtml +5 -0
- data/app/views/account/availability.rhtml +1 -0
- data/app/views/account/login.rhtml +22 -0
- data/app/views/account/logout.rhtml +10 -0
- data/app/views/javascript/motiro.rjs +132 -0
- data/app/views/javascript/niftycube.rjs +300 -0
- data/app/views/layouts/_bottom.rhtml +5 -0
- data/app/views/layouts/_header.rhtml +7 -0
- data/app/views/layouts/_top.rhtml +25 -0
- data/app/views/layouts/application.rhtml +3 -0
- data/app/views/layouts/scaffold.rhtml +13 -0
- data/app/views/layouts/wiki_edit.rhtml +26 -0
- data/app/views/report/list.rhtml +32 -0
- data/app/views/report/older.rhtml +26 -0
- data/app/views/report/rss.rxml +29 -0
- data/app/views/report/show.rhtml +20 -0
- data/app/views/root/index.rhtml +33 -0
- data/app/views/wiki/_editbar.rhtml +26 -0
- data/app/views/wiki/_properties_edit.rhtml +5 -0
- data/app/views/wiki/_properties_show.rhtml +5 -0
- data/app/views/wiki/edit.rhtml +56 -0
- data/app/views/wiki/properties_edit.rhtml +1 -0
- data/app/views/wiki/show.rhtml +9 -0
- data/bin/motiro +44 -0
- data/config/boot.rb +19 -0
- data/config/database.yml +14 -0
- data/config/environment.rb +64 -0
- data/config/environments/development.rb +20 -0
- data/config/environments/production.rb +19 -0
- data/config/environments/test.rb +19 -0
- data/config/motiro.yml +43 -0
- data/config/routes.rb +79 -0
- data/db/migrate/005_globalize_migration.rb +11363 -0
- data/db/migrate/006_remove_headline_title.rb +14 -0
- data/db/migrate/007_stretch_rid.rb +11 -0
- data/db/migrate/008_add_page_editors.rb +12 -0
- data/db/migrate/009_add_page_original_author.rb +12 -0
- data/db/migrate/010_remove_empty_string_defaults_from_pages.rb +17 -0
- data/db/migrate/011_add_title_and_kind_to_pages.rb +13 -0
- data/db/migrate/012_page_modification_info.rb +13 -0
- data/db/migrate/013_nullify_initial_page_attributes.rb +21 -0
- data/db/migrate/014_events_are_wiki_pages.rb +13 -0
- data/db/migrate/015_migrate_previous_event_data.rb +23 -0
- data/db/migrate/1_initial_structure.rb +36 -0
- data/db/migrate/2_add_authentication.rb +12 -0
- data/db/migrate/3_drop_articles.rb +26 -0
- data/db/migrate/4_add_page_editing.rb +14 -0
- data/db/motirodb.sqlite.initial +0 -0
- data/db/schema_version +1 -0
- data/db/translation/pt-BR.rb +76 -0
- data/doc/README_FOR_APP +2 -0
- data/installer/rails_installer_defaults.yml +5 -0
- data/lib/import_translations.rb +154 -0
- data/lib/login_system.rb +89 -0
- data/lib/relative_time.rb +48 -0
- data/lib/string_extensions.rb +10 -0
- data/lib/stub_hash.rb +22 -0
- data/lib/tasks/packaging.rake +93 -0
- data/lib/tasks/testing.rake +32 -0
- data/lib/tick_daemon.rb +41 -0
- data/lib/translator.rb +67 -0
- data/lib/wiki_renderer.rb +42 -0
- data/lib/wiki_url_generator.rb +29 -0
- data/log/.keepdir +0 -0
- data/public/404.html +8 -0
- data/public/500.html +8 -0
- data/public/dispatch.cgi +10 -0
- data/public/dispatch.fcgi +24 -0
- data/public/dispatch.rb +10 -0
- data/public/favicon.ico +0 -0
- data/public/images/calendar.png +0 -0
- data/public/images/rss.png +0 -0
- data/public/javascripts/controls.js +750 -0
- data/public/javascripts/dragdrop.js +584 -0
- data/public/javascripts/effects.js +854 -0
- data/public/javascripts/prototype.js +1785 -0
- data/public/robots.txt +1 -0
- data/public/stylesheets/motiro.css +269 -0
- data/public/stylesheets/niftyCorners.css +35 -0
- data/public/stylesheets/scaffold.css +74 -0
- data/script/about +3 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/plugin +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/process/spinner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/script/ticker +29 -0
- data/test/acceptance/account_test.rb +186 -0
- data/test/acceptance/darcs_test.rb +62 -0
- data/test/acceptance/events_test.rb +47 -0
- data/test/acceptance/main_page_test.rb +92 -0
- data/test/acceptance/subversion_test.rb +319 -0
- data/test/acceptance/ts_all_suites.rb +27 -0
- data/test/acceptance/wiki_test.rb +202 -0
- data/test/contract/darcs_test.rb +51 -0
- data/test/contract/remote_darcs_test.rb +61 -0
- data/test/contract/svn_test.rb +53 -0
- data/test/fixtures/changes.yml +25 -0
- data/test/fixtures/headlines.yml +45 -0
- data/test/fixtures/pages.yml +98 -0
- data/test/fixtures/users.yml +31 -0
- data/test/functional/account_controller_test.rb +96 -0
- data/test/functional/report_controller_test.rb +113 -0
- data/test/functional/report_features_test.rb +38 -0
- data/test/functional/report_subversion_test.rb +79 -0
- data/test/functional/root_controller_test.rb +127 -0
- data/test/functional/wiki_controller_test.rb +280 -0
- data/test/lib/acceptance_test_case.rb +43 -0
- data/test/lib/configuration.rb +53 -0
- data/test/lib/darcs_excerpts.rb +181 -0
- data/test/lib/darcs_repo.rb +77 -0
- data/test/lib/live_mode_test.rb +51 -0
- data/test/lib/local_svn.rb +157 -0
- data/test/lib/netutils.rb +42 -0
- data/test/lib/platform_thread.rb +62 -0
- data/test/lib/repoutils.rb +23 -0
- data/test/lib/selenium_extensions.rb +32 -0
- data/test/lib/stubio.rb +37 -0
- data/test/lib/svn_excerpts.rb +288 -0
- data/test/lib/test_configuration.rb +14 -0
- data/test/lib/webserver.rb +71 -0
- data/test/meta/configuration_test.rb +72 -0
- data/test/meta/darcs_repo_test.rb +118 -0
- data/test/meta/local_svn_test.rb +125 -0
- data/test/meta/platform_thread_test.rb +46 -0
- data/test/meta/stubio_test.rb +44 -0
- data/test/mocks/headline.rb +34 -0
- data/test/mocks/svn_reporter.rb +29 -0
- data/test/stubs/svn_settings.rb +19 -0
- data/test/stubs/url_generator.rb +24 -0
- data/test/test_helper.rb +36 -0
- data/test/unit/cache_reporter_fetcher_test.rb +46 -0
- data/test/unit/cache_reporter_test.rb +97 -0
- data/test/unit/caching_test.rb +78 -0
- data/test/unit/change_test.rb +152 -0
- data/test/unit/chdir_runner_test.rb +77 -0
- data/test/unit/chief_editor_test.rb +234 -0
- data/test/unit/darcs_connection_test.rb +109 -0
- data/test/unit/darcs_reporter_test.rb +146 -0
- data/test/unit/darcs_settings_test.rb +37 -0
- data/test/unit/darcs_temp_repo_test.rb +51 -0
- data/test/unit/default_page_provider_test.rb +46 -0
- data/test/unit/diff_table_builder_test.rb +602 -0
- data/test/unit/headline_test.rb +259 -0
- data/test/unit/page_test.rb +145 -0
- data/test/unit/relative_time_test.rb +56 -0
- data/test/unit/reporter_driver_test.rb +85 -0
- data/test/unit/reporter_fetcher_test.rb +31 -0
- data/test/unit/reporter_test.rb +81 -0
- data/test/unit/runner_test.rb +93 -0
- data/test/unit/settings_test.rb +55 -0
- data/test/unit/string_extensions_test.rb +10 -0
- data/test/unit/svn_connection_test.rb +183 -0
- data/test/unit/svn_reporter_interaction_test.rb +38 -0
- data/test/unit/svn_reporter_test.rb +286 -0
- data/test/unit/svn_settings_test.rb +86 -0
- data/test/unit/translator_test.rb +96 -0
- data/test/unit/user_test.rb +125 -0
- data/test/unit/wiki_renderer_test.rb +87 -0
- data/test/unit/wiki_reporter_test.rb +94 -0
- data/test/unit/wiki_url_generator_test.rb +31 -0
- data/vendor/motiro-installer.rb +159 -0
- data/vendor/plugins/globalize/LICENSE +9 -0
- data/vendor/plugins/globalize/README +49 -0
- data/vendor/plugins/globalize/data/country_data.csv +240 -0
- data/vendor/plugins/globalize/data/language_data.csv +188 -0
- data/vendor/plugins/globalize/data/translation_data.csv +3421 -0
- data/vendor/plugins/globalize/generators/globalize/USAGE +10 -0
- data/vendor/plugins/globalize/generators/globalize/globalize_generator.rb +42 -0
- data/vendor/plugins/globalize/generators/globalize/templates/migration.rb.gz +0 -0
- data/vendor/plugins/globalize/generators/globalize/templates/tiny_migration.rb.gz +0 -0
- data/vendor/plugins/globalize/init.rb +30 -0
- data/vendor/plugins/globalize/lib/globalize/localization/core_ext.rb +170 -0
- data/vendor/plugins/globalize/lib/globalize/localization/core_ext_hooks.rb +33 -0
- data/vendor/plugins/globalize/lib/globalize/localization/db_translate.rb +494 -0
- data/vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb +152 -0
- data/vendor/plugins/globalize/lib/globalize/localization/locale.rb +173 -0
- data/vendor/plugins/globalize/lib/globalize/localization/rfc_3066.rb +40 -0
- data/vendor/plugins/globalize/lib/globalize/models/country.rb +24 -0
- data/vendor/plugins/globalize/lib/globalize/models/currency.rb +188 -0
- data/vendor/plugins/globalize/lib/globalize/models/language.rb +84 -0
- data/vendor/plugins/globalize/lib/globalize/models/model_translation.rb +4 -0
- data/vendor/plugins/globalize/lib/globalize/models/translation.rb +9 -0
- data/vendor/plugins/globalize/lib/globalize/models/view_translation.rb +14 -0
- data/vendor/plugins/globalize/lib/globalize/rails/action_mailer.rb +125 -0
- data/vendor/plugins/globalize/lib/globalize/rails/action_view.rb +79 -0
- data/vendor/plugins/globalize/lib/globalize/rails/active_record.rb +129 -0
- data/vendor/plugins/globalize/lib/globalize/rails/active_record_helper.rb +33 -0
- data/vendor/plugins/globalize/populators/pop_dates.rb +81 -0
- data/vendor/plugins/globalize/populators/pop_migration.rb +18 -0
- data/vendor/plugins/globalize/populators/pop_pluralization.rb +26 -0
- data/vendor/plugins/globalize/populators/pop_seps.rb +32 -0
- data/vendor/plugins/globalize/tasks/data.rake +130 -0
- data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en-US.plain.text.rhtml +1 -0
- data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en.plain.text.rhtml +1 -0
- data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.he.plain.text.rhtml +1 -0
- data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.plain.text.rhtml +1 -0
- data/vendor/plugins/globalize/test/action_mailer_test.rb +54 -0
- data/vendor/plugins/globalize/test/config/database.yml.default +16 -0
- data/vendor/plugins/globalize/test/config/database.yml.example +22 -0
- data/vendor/plugins/globalize/test/core_ext_test.rb +61 -0
- data/vendor/plugins/globalize/test/currency_test.rb +141 -0
- data/vendor/plugins/globalize/test/date_helper_test.rb +634 -0
- data/vendor/plugins/globalize/test/db/schema.rb +90 -0
- data/vendor/plugins/globalize/test/db_translation_test.rb +374 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_categories.yml +7 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_categories_products.yml +7 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_countries.yml +41 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_languages.yml +64 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_manufacturers.yml +5 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_products.yml +29 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_simples.yml +5 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_translations.yml +354 -0
- data/vendor/plugins/globalize/test/locale_test.rb +27 -0
- data/vendor/plugins/globalize/test/mime_responds_test.rb +358 -0
- data/vendor/plugins/globalize/test/model_test.rb +17 -0
- data/vendor/plugins/globalize/test/standard_data_test_helper.rb +33 -0
- data/vendor/plugins/globalize/test/test_helper.rb +19 -0
- data/vendor/plugins/globalize/test/test_standard_data.rb +54 -0
- data/vendor/plugins/globalize/test/validation_test.rb +29 -0
- data/vendor/plugins/globalize/test/view_picking_test.rb +49 -0
- data/vendor/plugins/globalize/test/view_translation_test.rb +237 -0
- data/vendor/plugins/globalize/test/views/layouts/standard.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rxml +1 -0
- data/vendor/plugins/globalize/test/views/test.he-IL.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/test.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/test2.he.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/test2.rhtml +1 -0
- data/vendor/plugins/test_xml/MIT-LICENSE +20 -0
- data/vendor/plugins/test_xml/README +20 -0
- data/vendor/plugins/test_xml/Rakefile +22 -0
- data/vendor/plugins/test_xml/init.rb +7 -0
- data/vendor/plugins/test_xml/lib/xml_assertions.rb +22 -0
- data/vendor/plugins/test_xml/test/test_xml_test.rb +40 -0
- metadata +505 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Search for translated templates or fall back to the default one
|
|
2
|
+
module ActionView # :nodoc: all
|
|
3
|
+
class Base
|
|
4
|
+
alias_method :globalize_old_render_file, :render_file
|
|
5
|
+
|
|
6
|
+
# Name of file extensions which are handled internally in rails. Other types
|
|
7
|
+
# like liquid has to register through register_handler.
|
|
8
|
+
@@re_extension = /\.(rjs|rhtml|rxml)$/
|
|
9
|
+
|
|
10
|
+
@@globalize_path_cache = {}
|
|
11
|
+
|
|
12
|
+
def render_file(template_path, use_full_path = true, local_assigns = {})
|
|
13
|
+
if Globalize::Locale.active?
|
|
14
|
+
localized_path = locate_globalize_path(template_path, use_full_path)
|
|
15
|
+
# don't use_full_path -- we've already expanded the path
|
|
16
|
+
globalize_old_render_file(localized_path, false, local_assigns)
|
|
17
|
+
else
|
|
18
|
+
globalize_old_render_file(template_path, use_full_path, local_assigns)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
# Override because the original version is too minimalist
|
|
25
|
+
def path_and_extension(template_path) #:nodoc:
|
|
26
|
+
template_path_without_extension = template_path.sub(@@re_extension, '')
|
|
27
|
+
[ template_path_without_extension, $1 ]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def locate_globalize_path(template_path, use_full_path)
|
|
31
|
+
|
|
32
|
+
active_locale = Globalize::Locale.active
|
|
33
|
+
locale_code = active_locale.code
|
|
34
|
+
|
|
35
|
+
cache_key = "#{locale_code}:#{template_path}"
|
|
36
|
+
cached = @@globalize_path_cache[cache_key]
|
|
37
|
+
return cached if cached
|
|
38
|
+
|
|
39
|
+
if use_full_path
|
|
40
|
+
template_path_without_extension, template_extension = path_and_extension(template_path)
|
|
41
|
+
|
|
42
|
+
if template_extension
|
|
43
|
+
template_file_name = full_template_path(template_path_without_extension, template_extension)
|
|
44
|
+
else
|
|
45
|
+
template_extension = pick_template_extension(template_path).to_s
|
|
46
|
+
template_file_name = full_template_path(template_path, template_extension)
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
template_file_name = template_path
|
|
50
|
+
template_extension = template_path.split('.').last
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
pn = Pathname.new(template_file_name)
|
|
54
|
+
dir, filename = pn.dirname, pn.basename('.' + template_extension)
|
|
55
|
+
|
|
56
|
+
# first try "en-US" style
|
|
57
|
+
localized_path = dir +
|
|
58
|
+
(filename.to_s + '.' + locale_code + '.' + template_extension)
|
|
59
|
+
|
|
60
|
+
catch :found do
|
|
61
|
+
throw :found if localized_path.exist?
|
|
62
|
+
|
|
63
|
+
# then try "en" style
|
|
64
|
+
if active_language = Globalize::Locale.active.language
|
|
65
|
+
localized_path = dir +
|
|
66
|
+
(filename.to_s + '.' + active_language.code +
|
|
67
|
+
'.' + template_extension)
|
|
68
|
+
throw :found if localized_path.exist?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# otherwise use default
|
|
72
|
+
localized_path = template_file_name
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
@@globalize_path_cache[cache_key] = localized_path.to_s
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
module ActiveRecord # :nodoc:
|
|
2
|
+
|
|
3
|
+
# Overrode Errors methods to handle numbers correctly for translation, and
|
|
4
|
+
# to automatically translate error messages. Messages are translated after
|
|
5
|
+
# the field names have been substituted.
|
|
6
|
+
class Errors
|
|
7
|
+
|
|
8
|
+
# Like the regular #add, but automatically translates the error message.
|
|
9
|
+
# Takes an extra +num+ argument to support pluralization.
|
|
10
|
+
def add(attribute, msg = @@default_error_messages[:invalid], num = nil)
|
|
11
|
+
@errors[attribute.to_s] = [] if @errors[attribute.to_s].nil?
|
|
12
|
+
@errors[attribute.to_s] << [ msg, num ]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Like the regular add_to_base, but automatically translates the error message.
|
|
16
|
+
# Takes an extra +num+ argument to support pluralization.
|
|
17
|
+
def add_to_base(msg, num = nil)
|
|
18
|
+
add(:base, msg, num)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Like the regular add_on_boundary_breaking, but automatically translates the error message.
|
|
22
|
+
def add_on_boundary_breaking(attributes, range,
|
|
23
|
+
too_long_msg = @@default_error_messages[:too_long],
|
|
24
|
+
too_short_msg = @@default_error_messages[:too_short])
|
|
25
|
+
for attr in [attributes].flatten
|
|
26
|
+
value = @base.respond_to?(attr.to_s) ? @base.send(attr.to_s) : @base[attr.to_s]
|
|
27
|
+
add(attr, too_short_msg, range.begin) if value && value.length < range.begin
|
|
28
|
+
add(attr, too_long_msg, range.end) if value && value.length > range.end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def full_messages # :nodoc:
|
|
33
|
+
full_messages = []
|
|
34
|
+
|
|
35
|
+
@errors.each_key do |attr|
|
|
36
|
+
@errors[attr].each do |msg|
|
|
37
|
+
next if msg.nil?
|
|
38
|
+
msg = [ msg ].flatten
|
|
39
|
+
msg_text, msg_num = msg
|
|
40
|
+
if attr == "base"
|
|
41
|
+
full_messages << msg_text / msg_num
|
|
42
|
+
else
|
|
43
|
+
full_messages <<
|
|
44
|
+
(@base.class.human_attribute_name(attr) + " " + msg_text) / msg_num
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return full_messages
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# * Returns nil, if no errors are associated with the specified +attribute+.
|
|
53
|
+
# * Returns the error message, if one error is associated with the specified +attribute+.
|
|
54
|
+
# * Returns an array of error messages, if more than one error is associated with the specified +attribute+.
|
|
55
|
+
def on(attribute)
|
|
56
|
+
if @errors[attribute.to_s].nil?
|
|
57
|
+
return nil
|
|
58
|
+
else
|
|
59
|
+
msgs = @errors[attribute.to_s]
|
|
60
|
+
txt_msgs = msgs.map {|msg| msg.kind_of?(Array) ? msg.first / msg.last : msg.first.t }
|
|
61
|
+
return txt_msgs.length == 1 ? txt_msgs.first : txt_msgs
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
module Validations # :nodoc: all
|
|
68
|
+
module ClassMethods
|
|
69
|
+
def validates_length_of(*attrs)
|
|
70
|
+
# Merge given options with defaults.
|
|
71
|
+
options = {
|
|
72
|
+
:too_long => ActiveRecord::Errors.default_error_messages[:too_long],
|
|
73
|
+
:too_short => ActiveRecord::Errors.default_error_messages[:too_short],
|
|
74
|
+
:wrong_length => ActiveRecord::Errors.default_error_messages[:wrong_length]
|
|
75
|
+
}.merge(DEFAULT_VALIDATION_OPTIONS)
|
|
76
|
+
options.update(attrs.pop.symbolize_keys) if attrs.last.is_a?(Hash)
|
|
77
|
+
|
|
78
|
+
# Ensure that one and only one range option is specified.
|
|
79
|
+
range_options = ALL_RANGE_OPTIONS & options.keys
|
|
80
|
+
case range_options.size
|
|
81
|
+
when 0
|
|
82
|
+
raise ArgumentError, 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.'
|
|
83
|
+
when 1
|
|
84
|
+
# Valid number of options; do nothing.
|
|
85
|
+
else
|
|
86
|
+
raise ArgumentError, 'Too many range options specified. Choose only one.'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Get range option and value.
|
|
90
|
+
option = range_options.first
|
|
91
|
+
option_value = options[range_options.first]
|
|
92
|
+
|
|
93
|
+
case option
|
|
94
|
+
when :within, :in
|
|
95
|
+
raise ArgumentError, ":#{option} must be a Range" unless option_value.is_a?(Range)
|
|
96
|
+
|
|
97
|
+
too_short = options[:too_short]
|
|
98
|
+
too_long = options[:too_long]
|
|
99
|
+
|
|
100
|
+
validates_each(attrs, options) do |record, attr, value|
|
|
101
|
+
if value.nil? or value.size < option_value.begin
|
|
102
|
+
record.errors.add(attr, too_short, option_value.begin)
|
|
103
|
+
elsif value.size > option_value.end
|
|
104
|
+
record.errors.add(attr, too_long, option_value.end)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
when :is, :minimum, :maximum
|
|
108
|
+
raise ArgumentError, ":#{option} must be a nonnegative Integer" unless option_value.is_a?(Integer) and option_value >= 0
|
|
109
|
+
|
|
110
|
+
# Declare different validations per option.
|
|
111
|
+
validity_checks = { :is => "==", :minimum => ">=", :maximum => "<=" }
|
|
112
|
+
message_options = { :is => :wrong_length, :minimum => :too_short, :maximum => :too_long }
|
|
113
|
+
|
|
114
|
+
message = options[:message] || options[message_options[option]]
|
|
115
|
+
|
|
116
|
+
validates_each(attrs, options) do |record, attr, value|
|
|
117
|
+
record.errors.add(attr, message, option_value) unless !value.nil? and value.size.method(validity_checks[option])[option_value]
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class ActiveRecord::Base # :nodoc:
|
|
126
|
+
include Globalize::DbTranslate
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module ActionView
|
|
2
|
+
module Helpers
|
|
3
|
+
module ActiveRecordHelper
|
|
4
|
+
# Returns a string with a div containing all the error messages for the object located as an instance variable by the name
|
|
5
|
+
# of <tt>object_name</tt>. This div can be tailored by the following options:
|
|
6
|
+
#
|
|
7
|
+
# * <tt>header_tag</tt> - Used for the header of the error div (default: h2)
|
|
8
|
+
# * <tt>id</tt> - The id of the error div (default: errorExplanation)
|
|
9
|
+
# * <tt>class</tt> - The class of the error div (default: errorExplanation)
|
|
10
|
+
#
|
|
11
|
+
# NOTE: This is a pre-packaged presentation of the errors with embedded strings and a certain HTML structure. If what
|
|
12
|
+
# you need is significantly different from the default presentation, it makes plenty of sense to access the object.errors
|
|
13
|
+
# instance yourself and set it up. View the source of this method to see how easy it is.
|
|
14
|
+
#
|
|
15
|
+
# Retrofitted for Globalize by Andr� Camargo
|
|
16
|
+
def error_messages_for(object_name, options = {})
|
|
17
|
+
options = options.symbolize_keys
|
|
18
|
+
object = instance_variable_get("@#{object_name}")
|
|
19
|
+
unless object.errors.empty?
|
|
20
|
+
content_tag("div",
|
|
21
|
+
content_tag(
|
|
22
|
+
options[:header_tag] || "h2",
|
|
23
|
+
"%d errors prohibited this #{object_name.to_s.gsub("_", " ").t} from being saved" / object.errors.count
|
|
24
|
+
) +
|
|
25
|
+
content_tag("p", "There were problems with the following fields:".t) +
|
|
26
|
+
content_tag("ul", object.errors.full_messages.collect { |msg| content_tag("li", msg) }),
|
|
27
|
+
"id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = 'development'
|
|
2
|
+
require 'config/environment'
|
|
3
|
+
require 'date'
|
|
4
|
+
include Globalize
|
|
5
|
+
|
|
6
|
+
def save(lang, key, val)
|
|
7
|
+
vt = ViewTranslation.pick(key, lang, 1)
|
|
8
|
+
if vt
|
|
9
|
+
vt.update_attribute(:text, val)
|
|
10
|
+
else
|
|
11
|
+
ViewTranslation.create!(:tr_key => key, :language_id => lang.id,
|
|
12
|
+
:pluralization_index => 1, :text => val)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
files = Dir.glob("D:/projects/test/lib/multilingual/locales/lang-data/*.rb")
|
|
17
|
+
files.each do |fp|
|
|
18
|
+
sections = fp.split '/'
|
|
19
|
+
fn = sections.last
|
|
20
|
+
code, ext = fn.split '.'
|
|
21
|
+
|
|
22
|
+
if %w(ar_IQ zh_CN bn_BD).include?(code)
|
|
23
|
+
lg, ct = code.split '_'
|
|
24
|
+
code = lg
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
next if code =~ /_/
|
|
28
|
+
|
|
29
|
+
lang = Language.pick(code)
|
|
30
|
+
if !lang
|
|
31
|
+
puts "ERROR: can't find #{code}"
|
|
32
|
+
next
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
lang_id = lang.id
|
|
36
|
+
|
|
37
|
+
str = File.read(fp)
|
|
38
|
+
eval str
|
|
39
|
+
|
|
40
|
+
if lang.code == 'he'
|
|
41
|
+
@lang_data = {
|
|
42
|
+
:days => [ 'יום ראשון', 'יום שני', 'יום שלישי', 'יום רביעי', 'יום חמישי', 'יום ששי', 'יום שבת' ],
|
|
43
|
+
:abdays => [ 'יום א\'', 'יום ב\'', 'יום ג\'', 'יום ד\'', 'יום ה\'', 'יום ו\'', 'שבת' ],
|
|
44
|
+
:months => [ 'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר' ],
|
|
45
|
+
:abmonths => [ 'ינו\'', 'פבר\'', 'מרץ', 'אפר\'', 'מאי', 'יונ\'', 'יול\'', 'אוג\'', 'ספט\'', 'אוק\'', 'נוב\'', 'דצמ\'' ]
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
days = @lang_data[:days]
|
|
50
|
+
days.each_index do |idx|
|
|
51
|
+
key = "#{Date::DAYNAMES[idx]} [weekday]"
|
|
52
|
+
val = days[idx]
|
|
53
|
+
save(lang, key, val)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
abdays = @lang_data[:abdays]
|
|
58
|
+
abdays.each_index do |idx|
|
|
59
|
+
key = "#{Date::ABBR_DAYNAMES[idx]} [abbreviated weekday]"
|
|
60
|
+
val = abdays[idx]
|
|
61
|
+
save(lang,key,val)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
months = @lang_data[:months]
|
|
65
|
+
months.each_index do |idx|
|
|
66
|
+
key = "#{Date::MONTHNAMES[idx + 1]} [month]"
|
|
67
|
+
val = months[idx]
|
|
68
|
+
save(lang,key,val)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
abmonths = @lang_data[:abmonths]
|
|
72
|
+
abmonths.each_index do |idx|
|
|
73
|
+
key = "#{Date::ABBR_MONTHNAMES[idx + 1]} [abbreviated month]"
|
|
74
|
+
val = abmonths[idx]
|
|
75
|
+
save(lang,key,val)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
puts "updated #{lang.english_name} [id=#{lang_id}]"
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = 'development'
|
|
2
|
+
require 'config/environment'
|
|
3
|
+
include Globalize
|
|
4
|
+
|
|
5
|
+
# This isn't currently being used
|
|
6
|
+
|
|
7
|
+
model = Language
|
|
8
|
+
items = model.find(:all)
|
|
9
|
+
fields = model.column_names
|
|
10
|
+
|
|
11
|
+
recs = []
|
|
12
|
+
items.each do |i|
|
|
13
|
+
atts = i.attributes_before_type_cast
|
|
14
|
+
ary = fields.map {|f| atts[f] }
|
|
15
|
+
recs.push(ary.inspect)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
puts "[\n " + recs.join(",\n ") + "\n]"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = 'development'
|
|
2
|
+
require 'config/environment'
|
|
3
|
+
|
|
4
|
+
include Globalize
|
|
5
|
+
|
|
6
|
+
def update_list(list, pl)
|
|
7
|
+
list.each do |lang|
|
|
8
|
+
lm = Language.pick(lang)
|
|
9
|
+
if !lm
|
|
10
|
+
puts "can't find #{lang}"
|
|
11
|
+
next
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
lm.update_attribute(:pluralization, pl)
|
|
15
|
+
puts "updated #{lm.english_name}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
update_list(%w(hu ja ko tr), 'c = 1')
|
|
20
|
+
update_list(%w(da nl en de no sv et fi fr el he it pt es eo), 'c == 1 ? 1 : 2')
|
|
21
|
+
update_list(%w(ga gd), 'c==1 ? 1 : c==2 ? 2 : 3')
|
|
22
|
+
update_list(%w(hr cs ru sk uk), 'c%10==1 && c%100!=11 ? 1 : c%10>=2 && c%10<=4 && (c%100<10 || c%100>=20) ? 2 : 3')
|
|
23
|
+
update_list(['lv'], 'c%10==1 && c%100!=11 ? 1 : c != 0 ? 2 : 3')
|
|
24
|
+
update_list(['lt'], 'c%10==1 && c%100!=11 ? 1 : c%10>=2 && (c%100<10 || c%100>=20) ? 2 : 3')
|
|
25
|
+
update_list(['pl'], 'c==1 ? 1 : c%10>=2 && c%10<=4 && (c%100<10 || c%100>=20) ? 2 : 3')
|
|
26
|
+
update_list(['sl'], 'c%100==1 ? 1 : c%100==2 ? 2 : c%100==3 || c%100==4 ? 3 : 4')
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = 'development'
|
|
2
|
+
require 'config/environment'
|
|
3
|
+
require 'date'
|
|
4
|
+
include Globalize
|
|
5
|
+
|
|
6
|
+
files = Dir.glob("D:/projects/temp/old-mlr/lib/globalize/locales/country-data/*.rb")
|
|
7
|
+
files.each do |fp|
|
|
8
|
+
sections = fp.split '/'
|
|
9
|
+
fn = sections.last
|
|
10
|
+
code, ext = fn.split '.'
|
|
11
|
+
code.upcase!
|
|
12
|
+
|
|
13
|
+
country = Country.pick(code)
|
|
14
|
+
|
|
15
|
+
if !country
|
|
16
|
+
puts "ERROR: can't find #{code}"
|
|
17
|
+
next
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
str = File.read(fp)
|
|
22
|
+
eval str
|
|
23
|
+
|
|
24
|
+
country.thousands_sep = @country_data[:mon_thousands_sep]
|
|
25
|
+
country.decimal_sep = @country_data[:mon_decimal_point]
|
|
26
|
+
|
|
27
|
+
country.save!
|
|
28
|
+
|
|
29
|
+
puts "updated #{country.english_name}"
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Reads a CSV file from the data/ dir.
|
|
2
|
+
require 'csv'
|
|
3
|
+
|
|
4
|
+
def csv_file filename
|
|
5
|
+
path = File.join File.dirname( __FILE__ ), '../data', "#{filename}.csv"
|
|
6
|
+
File.open( path ).read
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Loads CSV data into the appropriate table.
|
|
10
|
+
def load_from_csv table_name, data
|
|
11
|
+
column_clause = nil
|
|
12
|
+
is_header = false
|
|
13
|
+
cnx = ActiveRecord::Base.connection
|
|
14
|
+
|
|
15
|
+
ActiveRecord::Base.silence do
|
|
16
|
+
reader = CSV::Reader.create data
|
|
17
|
+
|
|
18
|
+
columns = reader.shift.map { |column_name| cnx.quote_column_name(column_name) }
|
|
19
|
+
column_clause = columns.join(', ')
|
|
20
|
+
|
|
21
|
+
reader.each do |row|
|
|
22
|
+
next if row.first.nil? # skip blank lines
|
|
23
|
+
raise "No table name defined" unless table_name
|
|
24
|
+
raise "No header defined" unless column_clause
|
|
25
|
+
values_clause = row.map { |v| cnx.quote(v).gsub('\\n', "\n").gsub('\\r', "\r") }.join(', ')
|
|
26
|
+
sql = "INSERT INTO #{table_name} (#{column_clause}) VALUES (#{values_clause})"
|
|
27
|
+
cnx.insert sql
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
namespace :globalize do
|
|
33
|
+
desc 'Reset the Globalize data'
|
|
34
|
+
task :reset => [ :teardown, :setup ]
|
|
35
|
+
|
|
36
|
+
desc 'Create Globalize database tables and load locale data'
|
|
37
|
+
task :setup => [ :create_tables, :load_locale_data ]
|
|
38
|
+
|
|
39
|
+
desc 'Remove all globalize data'
|
|
40
|
+
task :teardown => :drop_tables
|
|
41
|
+
|
|
42
|
+
desc 'Create Globalize database tables'
|
|
43
|
+
task :create_tables => :environment do
|
|
44
|
+
raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
|
|
45
|
+
|
|
46
|
+
ActiveRecord::Base.connection.create_table :globalize_countries, :force => true do |t|
|
|
47
|
+
t.column :code, :string, :limit => 2
|
|
48
|
+
t.column :english_name, :string
|
|
49
|
+
t.column :date_format, :string
|
|
50
|
+
t.column :currency_format, :string
|
|
51
|
+
t.column :currency_code, :string, :limit => 3
|
|
52
|
+
t.column :thousands_sep, :string, :limit => 2
|
|
53
|
+
t.column :decimal_sep, :string, :limit => 2
|
|
54
|
+
t.column :currency_decimal_sep, :string, :limit => 2
|
|
55
|
+
t.column :number_grouping_scheme, :string
|
|
56
|
+
end
|
|
57
|
+
ActiveRecord::Base.connection.add_index :globalize_countries, :code
|
|
58
|
+
|
|
59
|
+
ActiveRecord::Base.connection.create_table :globalize_translations, :force => true do |t|
|
|
60
|
+
t.column :type, :string
|
|
61
|
+
t.column :tr_key, :string
|
|
62
|
+
t.column :table_name, :string
|
|
63
|
+
t.column :item_id, :integer
|
|
64
|
+
t.column :facet, :string
|
|
65
|
+
t.column :built_in, :boolean, :default => true
|
|
66
|
+
t.column :language_id, :integer
|
|
67
|
+
t.column :pluralization_index, :integer
|
|
68
|
+
t.column :text, :text
|
|
69
|
+
end
|
|
70
|
+
ActiveRecord::Base.connection.add_index :globalize_translations, [ :tr_key, :language_id ]
|
|
71
|
+
ActiveRecord::Base.connection.add_index :globalize_translations, [ :table_name, :item_id, :language_id ]
|
|
72
|
+
|
|
73
|
+
ActiveRecord::Base.connection.create_table :globalize_languages, :force => true do |t|
|
|
74
|
+
t.column :iso_639_1, :string, :limit => 2
|
|
75
|
+
t.column :iso_639_2, :string, :limit => 3
|
|
76
|
+
t.column :iso_639_3, :string, :limit => 3
|
|
77
|
+
t.column :rfc_3066, :string
|
|
78
|
+
t.column :english_name, :string
|
|
79
|
+
t.column :english_name_locale, :string
|
|
80
|
+
t.column :english_name_modifier, :string
|
|
81
|
+
t.column :native_name, :string
|
|
82
|
+
t.column :native_name_locale, :string
|
|
83
|
+
t.column :native_name_modifier, :string
|
|
84
|
+
t.column :macro_language, :boolean
|
|
85
|
+
t.column :direction, :string
|
|
86
|
+
t.column :pluralization, :string
|
|
87
|
+
t.column :scope, :string, :limit => 1
|
|
88
|
+
end
|
|
89
|
+
ActiveRecord::Base.connection.add_index :globalize_languages, :iso_639_1
|
|
90
|
+
ActiveRecord::Base.connection.add_index :globalize_languages, :iso_639_2
|
|
91
|
+
ActiveRecord::Base.connection.add_index :globalize_languages, :iso_639_3
|
|
92
|
+
ActiveRecord::Base.connection.add_index :globalize_languages, :rfc_3066
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
desc 'Drops Globalize database tables'
|
|
96
|
+
task :drop_tables => :environment do
|
|
97
|
+
raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
|
|
98
|
+
|
|
99
|
+
ActiveRecord::Base.connection.drop_table :globalize_countries
|
|
100
|
+
ActiveRecord::Base.connection.drop_table :globalize_translations
|
|
101
|
+
ActiveRecord::Base.connection.drop_table :globalize_languages
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
desc 'Load locale data'
|
|
105
|
+
task :load_locale_data => :environment do
|
|
106
|
+
# This needs to be called here, so that we can load the structure without
|
|
107
|
+
# the data. It's needed for using currval() as used in loading
|
|
108
|
+
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
|
|
109
|
+
ActiveRecord::Base.connection.execute "SELECT nextval('globalize_countries_id_seq')"
|
|
110
|
+
ActiveRecord::Base.connection.execute "SELECT nextval('globalize_translations_id_seq')"
|
|
111
|
+
ActiveRecord::Base.connection.execute "SELECT nextval('globalize_languages_id_seq')"
|
|
112
|
+
end
|
|
113
|
+
load_from_csv 'globalize_countries', csv_file( :country_data )
|
|
114
|
+
load_from_csv 'globalize_languages', csv_file( :language_data )
|
|
115
|
+
load_from_csv 'globalize_translations', csv_file( :translation_data )
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
desc 'Purge locale data'
|
|
119
|
+
task :purge_locale_data => :environment do
|
|
120
|
+
Globalize::Country.destroy_all
|
|
121
|
+
Globalize::Language.destroy_all
|
|
122
|
+
Globalize::Translation.destroy_all
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
desc 'Run Globalize tests'
|
|
126
|
+
Rake::TestTask.new do |t|
|
|
127
|
+
t.test_files = FileList["#{File.dirname( __FILE__ )}/../test/*_test.rb"]
|
|
128
|
+
t.verbose = true
|
|
129
|
+
end
|
|
130
|
+
end
|
data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en-US.plain.text.rhtml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is the english [en-US] mail.
|
data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en.plain.text.rhtml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is the english [en] mail.
|
data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.he.plain.text.rhtml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is the hebrew [he] mail.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is the default mail.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
|
|
3
|
+
class ActionMailerTest < Test::Unit::TestCase
|
|
4
|
+
include Globalize
|
|
5
|
+
fixtures :globalize_languages, :globalize_countries
|
|
6
|
+
|
|
7
|
+
class GlobalizeMailer < ActionMailer::Base
|
|
8
|
+
@@subject = "Test"
|
|
9
|
+
@@from = "test@test.com"
|
|
10
|
+
|
|
11
|
+
def test
|
|
12
|
+
@charset = 'utf-8'
|
|
13
|
+
recipients 'recipient@test.com'
|
|
14
|
+
subject @@subject
|
|
15
|
+
from @@from
|
|
16
|
+
body(:recipient => "recipient")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def setup
|
|
21
|
+
GlobalizeMailer.template_root = File.dirname(__FILE__)
|
|
22
|
+
Locale.set("en-US")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_en_us
|
|
26
|
+
mail = GlobalizeMailer.create_test
|
|
27
|
+
assert_match "This is the english [en-US] mail.", mail.to_s
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_en
|
|
31
|
+
Locale.set('en')
|
|
32
|
+
mail = GlobalizeMailer.create_test
|
|
33
|
+
assert_match "This is the english [en] mail.", mail.to_s
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_he_il
|
|
37
|
+
Locale.set('he-IL')
|
|
38
|
+
mail = GlobalizeMailer.create_test
|
|
39
|
+
assert_match "This is the hebrew [he] mail.", mail.to_s
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_he
|
|
43
|
+
Locale.set('he')
|
|
44
|
+
mail = GlobalizeMailer.create_test
|
|
45
|
+
assert_match "This is the hebrew [he] mail.", mail.to_s
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_nil
|
|
49
|
+
Locale.set(nil)
|
|
50
|
+
mail = GlobalizeMailer.create_test
|
|
51
|
+
assert_match "This is the default mail.", mail.to_s
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
mysql:
|
|
2
|
+
adapter: mysql
|
|
3
|
+
database: globalize_test
|
|
4
|
+
username: root
|
|
5
|
+
password: root
|
|
6
|
+
|
|
7
|
+
sqlite:
|
|
8
|
+
adapter: sqlite
|
|
9
|
+
dbfile: vendor/plugins/globalize/test/db/test.sqlite.db
|
|
10
|
+
|
|
11
|
+
test:
|
|
12
|
+
adapter: mysql
|
|
13
|
+
database: globalize_test
|
|
14
|
+
username: root
|
|
15
|
+
password: root
|
|
16
|
+
encoding: utf8
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
mysql: &mysql
|
|
2
|
+
adapter: mysql
|
|
3
|
+
database: globalize_test
|
|
4
|
+
username: change-me
|
|
5
|
+
password: change-me
|
|
6
|
+
encoding: utf8
|
|
7
|
+
|
|
8
|
+
postgresql: &postgresql
|
|
9
|
+
adapter: postgresql
|
|
10
|
+
database: globalize_test
|
|
11
|
+
host: localhost
|
|
12
|
+
username: change-me
|
|
13
|
+
password: change-me
|
|
14
|
+
|
|
15
|
+
sqlite: &sqlite
|
|
16
|
+
adapter: sqlite
|
|
17
|
+
dbfile: vendor/plugins/globalize/test/db/test.sqlite.db
|
|
18
|
+
|
|
19
|
+
# Replace "postgresql" with the settings of the database you wish to test Globalize with.
|
|
20
|
+
test:
|
|
21
|
+
<<: *postgresql
|
|
22
|
+
|