additionals/test/unit/i18n_test.rb

48 lines
1.4 KiB
Ruby
Raw Normal View History

2018-07-15 11:07:31 +03:00
require File.expand_path('../../test_helper', __FILE__)
2016-12-02 14:45:12 +03:00
2018-07-15 13:07:09 +03:00
class I18nTest < ActiveSupport::TestCase
include Redmine::I18n
2016-12-02 14:45:12 +03:00
2018-07-15 13:07:09 +03:00
def setup
User.current = nil
end
2016-12-02 14:45:12 +03:00
2018-07-15 13:07:09 +03:00
def teardown
set_language_if_valid 'en'
end
2016-12-02 14:45:12 +03:00
2018-07-15 13:07:09 +03:00
def test_valid_languages
assert valid_languages.is_a?(Array)
assert valid_languages.first.is_a?(Symbol)
end
2016-12-02 14:45:12 +03:00
2018-07-15 13:07:09 +03:00
def test_locales_validness
lang_files_count = Dir[Rails.root.join('plugins',
'additionals',
'config',
'locales',
'*.yml')].size
assert_equal lang_files_count, 7
valid_languages.each do |lang|
assert set_language_if_valid(lang)
2016-12-02 14:45:12 +03:00
end
2018-07-15 13:07:09 +03:00
# check if parse error exists
::I18n.locale = 'de'
assert_equal 'Externe URLs', l(:label_external_urls)
::I18n.locale = 'en'
assert_equal 'External urls', l(:label_external_urls)
::I18n.locale = 'fr'
assert_equal 'Les urnes externes', l(:label_external_urls)
::I18n.locale = 'it'
assert_equal 'Esterno urls', l(:label_external_urls)
::I18n.locale = 'ja'
assert_equal '外部URL', l(:label_external_urls)
::I18n.locale = 'zh-TW'
assert_equal '外部連結', l(:label_external_urls)
::I18n.locale = 'zh'
assert_equal '外部 URLs', l(:label_external_urls)
set_language_if_valid('en')
2016-12-02 14:45:12 +03:00
end
end