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.
- data/.gitignore +29 -0
- data/Gemfile +11 -25
- data/History.rdoc +7 -0
- data/README.md +1 -1
- data/Rakefile +4 -46
- data/app/assets/javascripts/lolita/i18n/application.js +1 -1
- data/app/assets/javascripts/lolita/i18n/i18n.js +87 -0
- data/app/assets/stylesheets/lolita/i18n/application.scss +8 -7
- data/app/controllers/lolita/i18n_controller.rb +27 -9
- data/app/helpers/lolita/i18n_helper.rb +40 -7
- data/app/views/lolita/i18n/index.html.haml +23 -14
- data/config/locales/en.yml +7 -2
- data/config/locales/lv.yml +7 -2
- data/config/routes.rb +2 -10
- data/lib/lolita-i18n.rb +11 -77
- data/lib/lolita-i18n/configuration.rb +56 -0
- data/lib/lolita-i18n/exceptions.rb +6 -0
- data/lib/lolita-i18n/rails.rb +0 -1
- data/lib/lolita-i18n/request.rb +219 -0
- data/lib/lolita-i18n/version.rb +11 -0
- data/lolita-i18n.gemspec +18 -96
- data/spec/controllers/lolita/i18n_controller_spec.rb +64 -30
- data/spec/helpers/lolita/i18n_helper_spec.rb +70 -0
- data/spec/lolita-i18n/configuration_spec.rb +63 -0
- data/spec/lolita-i18n/exceptions_spec.rb +15 -0
- data/spec/lolita-i18n/request_spec.rb +238 -0
- data/spec/lolita-i18n/version_spec.rb +8 -0
- data/spec/lolita_i18n_spec.rb +38 -0
- data/spec/rails_spec_helper.rb +11 -0
- data/spec/requests/translating_spec.rb +51 -0
- data/spec/requests/translation_list_spec.rb +36 -0
- data/spec/routing/routes_spec.rb +11 -0
- data/spec/spec_helper.rb +26 -18
- data/spec/{rails_app → test_app}/app/controllers/application_controller.rb +2 -2
- data/spec/test_app/config/application.rb +19 -0
- data/spec/test_app/config/boot.rb +11 -0
- data/spec/{rails_app → test_app}/config/enviroment.rb +4 -4
- data/spec/test_app/config/enviroments/test.rb +44 -0
- data/spec/test_app/config/initializers/lolita_i18n.rb +4 -0
- data/spec/test_app/config/initializers/token.rb +7 -0
- data/spec/test_app/config/locales/en.yml +10 -0
- data/spec/test_app/config/locales/lv.yml +2 -0
- data/spec/test_app/config/locales/ru.yml +2 -0
- data/spec/test_app/config/mongoid.yml +6 -0
- data/spec/{rails_app → test_app}/config/routes.rb +2 -2
- data/spec/test_app/log/.gitkeep +0 -0
- data/spec/test_app/log/development.log +734 -0
- metadata +69 -80
- data/VERSION +0 -1
- data/app/assets/javascripts/lolita/i18n/i18n.js.coffee +0 -135
- data/lib/lolita-i18n/backend.rb +0 -87
- data/spec/lolita-i18n/backend_spec.rb +0 -33
- data/spec/rails_app/config/application.rb +0 -18
- data/spec/rails_app/config/initializers/lolita_i18n.rb +0 -16
- data/spec/rails_app/config/locales/en.yml +0 -10
- 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
|