Sha256: 1160da3eb5845b68a190ae456f49013c6b0dfcf8df1e40bd0aea7fd550ab1140

Contents?: true

Size: 1.51 KB

Versions: 14

Compression:

Stored size: 1.51 KB

Contents

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

require 'test/unit'
require 'ostruct'

require 'glue/localization'

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

  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

14 entries across 14 versions & 1 rubygems

Version Path
glue-0.41.0 test/glue/tc_localization.rb
glue-0.21.0 test/glue/tc_localization.rb
glue-0.21.2 test/glue/tc_localization.rb
glue-0.22.0 test/glue/tc_localization.rb
glue-0.23.0 test/glue/tc_localization.rb
glue-0.24.0 test/glue/tc_localization.rb
glue-0.25.0 test/glue/tc_localization.rb
glue-0.31.0 test/glue/tc_localization.rb
glue-0.27.0 test/glue/tc_localization.rb
glue-0.28.0 test/glue/tc_localization.rb
glue-0.29.0 test/glue/tc_localization.rb
glue-0.30.0 test/glue/tc_localization.rb
glue-0.40.0 test/glue/tc_localization.rb
glue-0.26.0 test/glue/tc_localization.rb