春雨 — 多言語 Web 頁管理ツール

これは何?

春雨は、複数の自然言語の文章をまとめた元となる HTML 文書から、指定した自然言語の版の HTML 文書を取り出すツールです。

多言語 Web サイトで (実際には同じ内容の) 文書の版を管理するのは大変です。 HTML 文書の著者が一部でも変更しようと思うと、 他の言語の翻訳も同時に更新しておかないと、言語間で文書の版が違ってしまいます。

春雨を使えば複数言語の HTML 文書を1つの元となる HTML 文書から生成できます。 段落毎に各言語の翻訳文を並べた元文書を用意すればよいので、 著者は別々のファイルで別々の言語の別々の版を管理する煩わしさから開放されます。

最新情報

変更履歴差分の Atom フィードはじめました。

使い方

  1. First, prepare a source HTML document html-document.src. The document can be marked up in HTML as usual, except for the special markup for harusame to identify alternative blocks written in various languages.

    An input document might look like:

    <!DOCTYPE HTML>
    <html lang=mul>
    <title>Example Document</title>
    
    <h1 data-lang-container>
    <span lang=en>Example document</span>
    <span lang=ja>文書の例</span>
    </h1>
    
    <p data-lang-container>
    <span lang=en>This is an example of document with multiple languages.</span>
    <span lang=ja>これは複数の言語で記述された文書の例です。</span>
    
  2. Then, invoke the harusame command for each language to generate, as:

    $ harusame --lang en < html-document.src > html-document.en
    $ harusame --lang ja < html-document.src > html-document.ja

    For more information on the harusame's command-line options, see its documentation.

Harusame Markup Reference

Special markup for harusame processing is represented as data-lang-* attributes on HTML elements, as follows:

data-lang-container

If this attribute is specified to an HTML element, then it is treated as a container element that contains versions of the content in various languages.

An element with this attribute must contain one or more HTML elements. One of them, whose language (lang attribute value) matches with the language specified as --lang command-line option, is selected. If there are more than one such elements, then the first one is selected. If there is no element whose language matches to the --lang option, then the first element (of whatever language) is selected.

If the attribute value is replace, then the element itself is replaced by the selected element. Otherwise, the content of the element is replaced by the selected element.

data-lang-content

If this attribute is specified to an HTML element, then its content is replaced by the content of another element.

If this attribute is specified, its value must be an ID of another HTML element in the document.

A child element of the element addressed by the ID is selected in the similar way to the data-lang-container attribute. Then, the content of the element with the data-lang-content attribute is replaced by the text content (the value of the textContent IDL attribute) of the selected element.

If the element addressed by the ID has data-lang-declaration attribute, then the element will be removed from the document at the end of the whole processing.

This attribute is useful when an HTML element does not allow elements to be inserted within it . For example, the content model of the title element does not allow child elements. In such a case, instead of inserting elements with lang attribute, this attribute can be used to point to translations of the title element content, as follows:

<title data-lang-content="title-content">Example</title>

<div id="title-content" data-lang-declaration hidden>
<span lang=en>Example</span>
<span lang=ja>例</span>
</div>

Note that the pointed element, i.e. the div element, has the data-lang-declaration attribute specified. In many (though not all) cases, the pointed translations do not form the actual content of the document and therefore the attribute ask to harusame to get rid of them from the document at the end of the processing.

data-lang-declaration

This attribute indicates that the element declares a set of alternatives in various languages.

This attribute must not be used for an element that is not pointed by a data-lang-content attribute in the same document.

利用例

この文書自体も春雨を使って生成しています。春雨の使い方の例として、 原始文書をご覧ください

依存性

春雨の動作には Perl 5.8 以降が必要です。

春雨はmanakai-coreCharClass も使っています (Git リポジトリーのサブモジュールです)。

Download

春雨は Git を使って開発しています。 Git リポジトリ(GitHub) は次のようにして clone できます。

$ git clone https://github.com/wakaba/harusame.git
$ cd harusame
$ make deps
$ ./harusame

著者

.

ライセンス

Copyright 2008-2015 Wakaba <>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.