lolita-i18n 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.gitignore +29 -0
  2. data/Gemfile +11 -25
  3. data/History.rdoc +7 -0
  4. data/README.md +1 -1
  5. data/Rakefile +4 -46
  6. data/app/assets/javascripts/lolita/i18n/application.js +1 -1
  7. data/app/assets/javascripts/lolita/i18n/i18n.js +87 -0
  8. data/app/assets/stylesheets/lolita/i18n/application.scss +8 -7
  9. data/app/controllers/lolita/i18n_controller.rb +27 -9
  10. data/app/helpers/lolita/i18n_helper.rb +40 -7
  11. data/app/views/lolita/i18n/index.html.haml +23 -14
  12. data/config/locales/en.yml +7 -2
  13. data/config/locales/lv.yml +7 -2
  14. data/config/routes.rb +2 -10
  15. data/lib/lolita-i18n.rb +11 -77
  16. data/lib/lolita-i18n/configuration.rb +56 -0
  17. data/lib/lolita-i18n/exceptions.rb +6 -0
  18. data/lib/lolita-i18n/rails.rb +0 -1
  19. data/lib/lolita-i18n/request.rb +219 -0
  20. data/lib/lolita-i18n/version.rb +11 -0
  21. data/lolita-i18n.gemspec +18 -96
  22. data/spec/controllers/lolita/i18n_controller_spec.rb +64 -30
  23. data/spec/helpers/lolita/i18n_helper_spec.rb +70 -0
  24. data/spec/lolita-i18n/configuration_spec.rb +63 -0
  25. data/spec/lolita-i18n/exceptions_spec.rb +15 -0
  26. data/spec/lolita-i18n/request_spec.rb +238 -0
  27. data/spec/lolita-i18n/version_spec.rb +8 -0
  28. data/spec/lolita_i18n_spec.rb +38 -0
  29. data/spec/rails_spec_helper.rb +11 -0
  30. data/spec/requests/translating_spec.rb +51 -0
  31. data/spec/requests/translation_list_spec.rb +36 -0
  32. data/spec/routing/routes_spec.rb +11 -0
  33. data/spec/spec_helper.rb +26 -18
  34. data/spec/{rails_app → test_app}/app/controllers/application_controller.rb +2 -2
  35. data/spec/test_app/config/application.rb +19 -0
  36. data/spec/test_app/config/boot.rb +11 -0
  37. data/spec/{rails_app → test_app}/config/enviroment.rb +4 -4
  38. data/spec/test_app/config/enviroments/test.rb +44 -0
  39. data/spec/test_app/config/initializers/lolita_i18n.rb +4 -0
  40. data/spec/test_app/config/initializers/token.rb +7 -0
  41. data/spec/test_app/config/locales/en.yml +10 -0
  42. data/spec/test_app/config/locales/lv.yml +2 -0
  43. data/spec/test_app/config/locales/ru.yml +2 -0
  44. data/spec/test_app/config/mongoid.yml +6 -0
  45. data/spec/{rails_app → test_app}/config/routes.rb +2 -2
  46. data/spec/test_app/log/.gitkeep +0 -0
  47. data/spec/test_app/log/development.log +734 -0
  48. metadata +69 -80
  49. data/VERSION +0 -1
  50. data/app/assets/javascripts/lolita/i18n/i18n.js.coffee +0 -135
  51. data/lib/lolita-i18n/backend.rb +0 -87
  52. data/spec/lolita-i18n/backend_spec.rb +0 -33
  53. data/spec/rails_app/config/application.rb +0 -18
  54. data/spec/rails_app/config/initializers/lolita_i18n.rb +0 -16
  55. data/spec/rails_app/config/locales/en.yml +0 -10
  56. data/spec/rails_app/config/locales/lv.yml +0 -2
@@ -1,33 +0,0 @@
1
- USE_RAILS=true unless defined?(USE_RAILS)
2
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
-
4
- describe Lolita::I18n::Backend do
5
-
6
- it "should have fallback to default I18n store" do
7
- I18n.t("Page title").should == "Page title"
8
- end
9
-
10
- it "should set translation into DB" do
11
- ::I18n.t("test-key", :locale => :en, :default => '').should == ''
12
- Lolita::I18n::Backend.set("en.test-key","Hello")
13
- ::I18n.t("test-key", :locale => :en, :default => '').should == 'Hello'
14
- end
15
-
16
- it "should delete key from DB if empty value given" do
17
- Lolita::I18n::Backend.set("en.test-key","Hello")
18
- Lolita::I18n::Backend.get("en.test-key")[:value].should == "Hello"
19
- Lolita::I18n::Backend.set("en.test-key","")
20
- Lolita.i18n.store.get("en.test-key").should be_nil
21
- end
22
-
23
- it "should get translation into DB" do
24
- Lolita::I18n::Backend.get("en.test-key")[:value].should == ''
25
- Lolita::I18n::Backend.set("en.test-key","Hello")
26
- Lolita::I18n::Backend.get("en.test-key")[:value].should == "Hello"
27
- end
28
-
29
- it "should raise Lolita::I18n::Exceptions::MissingInterpolationArgument" do
30
- lambda {Lolita::I18n::Backend.set("lv.copyright","Autortiesibas 2010-2012")}.should raise_error(Lolita::I18n::Exceptions::MissingInterpolationArgument)
31
- lambda {Lolita::I18n::Backend.set("lv.copyright","Autortiesibas %{year_from}-%{year_till}")}.should_not raise_error(Lolita::I18n::Exceptions::MissingInterpolationArgument)
32
- end
33
- end
@@ -1,18 +0,0 @@
1
- require "action_controller/railtie"
2
- require "action_mailer/railtie"
3
- require "active_resource/railtie"
4
- require "rails/test_unit/railtie"
5
-
6
- #require File.expand_path("../../../../lib/lolita-i18n",__FILE__)
7
- #require 'i18n'
8
-
9
- module Test
10
- class Application < Rails::Application
11
- config.root=File.expand_path("#{File.dirname(__FILE__)}/..")
12
- config.logger=Logger.new(File.join(config.root,"log","development.log"))
13
- config.active_support.deprecation=:log
14
- config.i18n.default_locale = :en
15
-
16
- #config.autoload_paths=File.expand_path("../#{File.dirname(__FILE__)}")
17
- end
18
- end
@@ -1,16 +0,0 @@
1
-
2
- Lolita.setup do |config|
3
- # ==> User and authentication configuration
4
- # Add one or more of your user classes to Lolita
5
- # config.user_classes << MyUser
6
- # config.authentication = :authenticate_user!
7
-
8
- # Define authentication for Lolita controllers.
9
- # Call some of your own methods
10
- # config.authentication=:is_admin?
11
- # Or use some customized logic
12
- # config.authentication={
13
- # current_user.is_a?(Admin) || current_user.has_role?(:admin)
14
- # }
15
- config.i18n.store = {:db => 11}
16
- end
@@ -1,10 +0,0 @@
1
- en:
2
- "Page title": "Page title"
3
- posts:
4
- "Title": Posts
5
- "Description": "Posts description"
6
- comments:
7
- "Title": Comments
8
- "Description": "Comment description"
9
- Footer: "Footer text"
10
- copyright: "Copyright %{year_from}-%{year_till}"
@@ -1,2 +0,0 @@
1
- lv:
2
- "Page title": "Lapas virsraksts"