2013-02-06 03:16:51 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "i18n integrity checks" do
|
|
|
|
|
|
|
|
it 'should have an i18n key for all trust levels' do
|
|
|
|
TrustLevel.all.each do |ts|
|
|
|
|
ts.name.should_not =~ /translation missing/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "needs an i18n key (description) for each Site Setting" do
|
|
|
|
SiteSetting.all_settings.each do |s|
|
|
|
|
next if s[:setting] =~ /^test/
|
|
|
|
s[:description].should_not =~ /translation missing/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "needs an i18n key (notification_types) for each Notification type" do
|
2013-03-01 20:07:44 +08:00
|
|
|
Notification.types.keys.each do |type|
|
2013-02-26 00:42:20 +08:00
|
|
|
I18n.t("notification_types.#{type}").should_not =~ /translation missing/
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-23 22:49:31 +08:00
|
|
|
it "has valid YAML for client" do
|
|
|
|
Dir["#{Rails.root}/config/locales/client.*.yml"].each do |f|
|
2013-03-23 15:57:31 +08:00
|
|
|
locale = /.*\.([^.]{2,})\.yml$/.match(f)[1]
|
|
|
|
client = YAML.load_file("#{Rails.root}/config/locales/client.#{locale}.yml")
|
|
|
|
client.count.should == 1
|
|
|
|
client[locale].should_not == nil
|
|
|
|
client[locale].count.should == 2
|
|
|
|
client[locale]["js"].should_not == nil
|
|
|
|
client[locale]["admin_js"].should_not == nil
|
2013-03-23 22:49:31 +08:00
|
|
|
end
|
|
|
|
end
|
2013-03-23 15:57:31 +08:00
|
|
|
|
2013-03-23 22:49:31 +08:00
|
|
|
it "has valid YAML for server" do
|
|
|
|
Dir["#{Rails.root}/config/locales/server.*.yml"].each do |f|
|
|
|
|
locale = /.*\.([^.]{2,})\.yml$/.match(f)[1]
|
2013-03-23 15:57:31 +08:00
|
|
|
server = YAML.load_file("#{Rails.root}/config/locales/server.#{locale}.yml")
|
|
|
|
server.count.should == 1
|
|
|
|
server[locale].should_not == nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-23 00:49:46 +08:00
|
|
|
it "does not overwrite another language" do
|
2013-03-20 17:51:28 +08:00
|
|
|
Dir["#{Rails.root}/config/locales/*.yml"].each do |f|
|
|
|
|
locale = /.*\.([^.]{2,})\.yml$/.match(f)[1] + ':'
|
|
|
|
IO.foreach(f) do |line|
|
2014-02-15 03:47:52 +08:00
|
|
|
line.strip!
|
2013-03-20 17:51:28 +08:00
|
|
|
next if line.start_with? "#"
|
|
|
|
next if line.start_with? "---"
|
2014-02-15 06:57:38 +08:00
|
|
|
next if line.blank?
|
2013-03-20 17:51:28 +08:00
|
|
|
line.should eq locale
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
end
|