View on
Marty O'Brien > I22r-Translate-0.95 > I22r::Translate::Filter::Literal



Annotate this POD


Open  1
View/Report Bugs
Module Version: 0.95   Source   Latest Release: I22r-Translate-0.96


I22r::Translate::Filter::Literal - protect text in input to I22r::Translate


       filter => [ 'Literal' ]

    $t = I22r::Translate->translate_string(
       src => ..., dest => ..., text => 'string with Proper Nouns',
       filter => [ 'Literal' ] )


A preprocessing and postprocessing filter that recognizes words or phrases with particular markup, and prevents that text from being altered in a translation engine.

Sometimes, content that you wish to translate may contain words or phrases that you don't want to translate.

    My friend Paul Fisher lives in Key West.

    The French word for cat is "chat".

If you wished to translate these sentences into, say, Spanish, you would probably not want some of those words to be translated, including all the proper nouns and the "foreign" word which also happens to have the same spelling as an English word. That is, you would much prefer a translation output like

    Mi amigo Paul Fisher vive en Key West.

    La palabra francesca para gato es "chat".

rathen than

    Mi amigo Pablo Pescador vive en Clave Oeste.

    La palabra francesca para gato es "charlar".

The I22r::Translate::Filter::Literal filter will recognize certain markup in translation input and interpret it as an instruction to hide certain words from the translation engine. The untranslated words will then be (hopefully) restored to the correct place in the translated output.


The I22r::Translate::Filter::Literal filter recognizes any of the following ways to protect parts of the input from being seen by the translators:

double braces

Parts of the input enclosed in a set of double braces will be protected from the translator.

    The French word for cat is {{"chat"}}.

lit and literal pseudo tags

Text enclosed in [lit]...[/lit] or [literal]...[/literal] tokens will be protected from the translator.

    My friend Mr. [lit]Wong[/lit] lives in [literal]Los Angeles[/literal].

span tag with lang attribute

Text inside a <span> tag with an attribute called lang will be protected from the translator. This is somewhat of a convention for identifying the source language of some text in an HTML document, and it wouldn't be sensible for a translator to render text inside those tags in another language.

    The French word for "hat" is <span lang="fr">"chapeau"</span>.

Note that if your input uses this construction and you also intend to pass translation input through the I22r::Translate::Filter::HTML filter, you should include this filter first, or the <span>...</span> tags will not be visible to this filter. That is, you should specify

    filter => [ 'Literal', 'HTML' ]

rather than

    filter => [ 'HTML', 'Literal' ]

These markup specifications are kind of arbitrary. More may be added and some may be removed in future releases of this module. Send me a note (mob at if you have an opinion one way or the other about what is a good way to specify protected text.


I22r::Translate::Filter, I22r::Translate::Filter::HTML, I22r::Translate.

syntax highlighting: