Sha256: 30c30d31778cf2882d223a86411698a24a4031a4c4fbbd37e49f675ef7e3f8dc

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')

require 'test/unit'
require 'ostruct'

require 'nitro/localization'

class TestCaseLocalization < Test::Unit::TestCase # :nodoc: all
	include Nitro

	def setup
		locale_en = {
			'See you' => 'See you',
			:long_paragraph => 'The best new books, up to 30% reduced price',
			:price => 'Price: %d %s',
			:proc_price => proc { |value, cur| "Price: #{value} #{cur}" }
		}

		locale_de = {
			'See you' => 'Auf wieder sehen',
			:long_paragraph => 'Die besten neuer buecher, bis zu 30% reduziert',
			:price => 'Preis: %d %s',
			:proc_price => proc { |value, cur| "Preis: #{value} #{cur}" }
		}

		Localization.add(
			:en => locale_en,
			:de => locale_de
		)
	end

	def test_all
		lc = Localization.get
		assert_equal 'See you', lc['See you']
		assert_equal 'The best new books, up to 30% reduced price', lc[:long_paragraph]
		
		lc = Localization.get(:en)
		assert_equal 'See you', lc['See you']
		assert_equal 'The best new books, up to 30% reduced price', lc[:long_paragraph]
		assert_equal 'Price: 100 euro', lc[:price, 100, 'euro']
		assert_equal 'Price: 100 euro', lc[:proc_price, 100, 'euro']

		lc = Localization.get(:de)
		assert_equal 'Auf wieder sehen', lc['See you']
		assert_equal 'Die besten neuer buecher, bis zu 30% reduziert', lc[:long_paragraph]
		assert_equal 'Preis: 100 euro', lc.translate(:price, 100, 'euro')
		assert_equal 'Preis: 100 euro', lc[:proc_price, 100, 'euro']
	end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nitro-0.16.0 test/nitro/tc_localization.rb
nitro-0.17.0 test/nitro/tc_localization.rb
nitro-0.18.0 test/nitro/tc_localization.rb
nitro-0.18.1 test/nitro/tc_localization.rb
nitro-0.19.0 test/nitro/tc_localization.rb
nitro-0.20.0 test/nitro/tc_localization.rb