Selector

Contact

Markdown Hosing - Register Now!

Home > Authoring > Guide > Selector | Japanese

Selector

The Selector reads souce text mixed with passages for different purposes and writes the output containing only the selected passages.

Source Selector Output Inline SVG not supported by your browser

For example, Selector can select text written in a specified language and for a specific version.

Passage and Selector

A passage is a part of text such as one or more sentences, one or more paragraphs, sections or chapters of a web page or document.

A source text passed to Selector can cocntain passages for differnt purposes. For example, a single source file can contain passages for multiple languages and/or multiple versions. A selector is used to specify which passages should be output for a final output to meet a specific purpose.

Language Selector

A source text intermixed with selectors is called passage-marked text.

Here is a simple source text with selectable passages for two languages: English and Japanese.

 This is a common part for any languages.
 /en/
 This text is included when the request language is English.
 This line too.
 /ja/
 This text is for Japanese only.
 /end/
 This again included for every output.

An ISO-defined language code enclosed in two slashes (/.../) is called a language selector and selects the language. In this case, a passage following /en/ is a passage in English and /ja/ in Japanese. A language-specific passage continues until a new selector appears or /end/ marker appears. The end marker resets passage selection.

Specify the target selector of en if you want to produce a document in English. Then you will get the following:

 This is a common part for any languages.
 This text is included when the request language is English.
 This line too.
 This is a common part for any languages.

Specify ja to get a Japanese version:

 This is a common part for any languages.
 This text is for Japanese only.
 This is a common part for any languages.

You can use /any/ instead of /end/ if you prefer. You can write a language selector at the beginning of a line instead on an independent line. But you can't write a selector at the end of a line.

 This is a common part for any languages.
 /en/ This text is included when the request language is English.
 This line too.
 /ja/This text is for Japanese only.
 /any/ This again included for every output.

In this example, /any/ effect will continue to the next lines.

Version Selector

In addition to language selectors, you can use version selectors to deepen your selection:

 /en/
 Text for all English versions.
 /.v2/
 This is only for version 2 of the document.
 /.v2.r1/
 This is only for revision 1 of version 2 of the document.
 /end/
 This again is for all English versions.
 /end/
 End of English passages.

A version selector is used to select any kind of passages based on non-language criteria. It can be used to specify selection of a product type, target customer, target reader as well as product or document version. It is called version selector assuming it is the most typical case.

A version selector is prefixed by a dot (.) in order to distinguish it from a language selector. It has one or more levels and levels are delimited by a dot.

If you specify the target selector of en you will get:

 Text for all English versions.
 This again is for all English versions.
 End of English passages.

while you get the following if you specify en and .v2:

 Text for all English versions.
 This is only for version 2 of the document.
 This again is for all English versions.
 End of English passages.

Note that the part for .v2 is included while the part for .v2.r1 is not.

If you specify en and .v2.r1 you will get:

 Text for all English versions.
 This is only for version 2 of the document.
 This is only for revision 1 of version 2 of the document.
 This again is for all English versions.
 End of English passages.

Note that the part for .v2 is also included for .v2.r1 selection.

Examples of version selectors:

One note about difference between language and version selectors. Only one target language is selected from a list of candidate languages. More than one version selectors can be effective and all are used to select passages. For example, either 'ja' or 'kr' is effective even if you specify both. You can have '.v2' and '.debian' at the same time.

Presented by Kobu.Com

2020-apr-08 first edition
2020-apr-20 second edition
2020-aug-31 changes in marker placement rules
2020-oct-08 third edition

Contact