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

これは何?

Harusame extracts a version of the HTML document written in the specified natural language, from a source HTML document that contains paragraphs in multiple natural languages.

The document management of a multilingual Web site where there are multiple versions of a (conceptually same) document is somewhat difficult in general. If the author of an HTML document wants to edit a part of the document, then he or she has to ensure not to forget updating translations at the same time, otherwise documents in different language versions also differ in their content versions.

Using harusame, one can generate versions of an HTML document in different language from one source HTML document that contains paragraphs written in all of those languages, such that authors no longer have to manage different content versions and different language versions in separate files.

最新情報

変更履歴差分の 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.pl for each language to generate, as:

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

    For more information on the harusame.pl 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 DOM 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 to insert elements as its content. For example, the content model of the title element does not allow child elements, so that this attribute can be used to provide translations to the title element content like this:

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

<div id="title-content" data-lang-declaration>
<span lang=en>Example</span>
<span lang=ja>例</span>
</div>
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.

利用例

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

Dependency

This software requires Perl 5.8 or later, as well as manakai-core and Whatpm packages.

Download

This software is available from the CVS repository.

The tarball for the latest version is also available.

There is no installer. Just copy the script file to some directory.

著者

.

License

Copyright 2008 Wakaba <>.

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