Sha256: 5e9d411a15106df6b99a571269ca4ec837444d5360408ddad8f3c509ffe3da17

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 KB

Contents

# -*- coding: utf-8 -*-
require 'test_helper'
require 'review/i18n'

require 'review/compiler'
require 'review/book'
require 'review/htmlbuilder'

class I18nTest < Test::Unit::TestCase
  include ReVIEW

  def test_ja
    I18n.i18n "ja"
    assert_equal I18n.t("image"), "図"
    assert_equal I18n.t("table"), "表"
    assert_equal I18n.t("chapter", 1), "第1章"
    assert_equal I18n.t("etc"), "etc"
  end

  def test_ja_with_user_i18n
    I18n.i18n "ja", {"image" => "ず"}
    assert_equal I18n.t("image"), "ず"
    assert_equal I18n.t("table"), "表"
    assert_equal I18n.t("chapter", 1), "第1章"
    assert_equal I18n.t("etc"), "etc"
  end

  def test_en
    I18n.i18n "en"
    assert_equal I18n.t("image"), "Figure "
    assert_equal I18n.t("table"), "Table "
    assert_equal I18n.t("chapter", 1), "Chapter 1"
    assert_equal I18n.t("etc"), "etc"
  end

  def test_nil
    I18n.i18n "nil"
    assert_equal I18n.t("image"), "image"
    assert_equal I18n.t("table"), "table"
    assert_equal I18n.t("etc"), "etc"
  end

  def test_htmlbuilder
    _setup_htmlbuilder
    @builder.headline(1,"test","this is test.")
    assert_equal %Q|<h1 id="test"><a id="h1"></a>Chapter 1. this is test.</h1>\n|, @builder.raw_result
  end

  def _setup_htmlbuilder
    I18n.i18n "en"
    @builder = HTMLBuilder.new()
    @param = {
      "secnolevel" => 2,    # for IDGXMLBuilder, HTMLBuilder
      "inencoding" => "UTF-8",
      "outencoding" => "UTF-8",
      "stylesheet" => nil,  # for HTMLBuilder
    }
    ReVIEW.book.param = @param
    @compiler = ReVIEW::Compiler.new(@builder)
    @chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
    location = Location.new(nil, nil)
    @builder.bind(@compiler, @chapter, location)
  end

  def teardown
    I18n.i18n "ja"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
review-1.2.0 test/test_i18n.rb
review-1.1.0 test/test_i18n.rb