I22r::Translate::Filter::Literal - protect text in input to I22r::Translate
I22r::Translate->config( ..., 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.
I22r::Translate::Filter::Literal
The I22r::Translate::Filter::Literal filter recognizes any of the following ways to protect parts of the input from being seen by the translators:
Parts of the input enclosed in a set of double braces will be protected from the translator.
The French word for cat is {{"chat"}}.
Text enclosed in [lit]...[/lit] or [literal]...[/literal] tokens will be protected from the translator.
[lit]...[/lit]
[literal]...[/literal]
My friend Mr. [lit]Wong[/lit] lives in [literal]Los Angeles[/literal].
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.
<span>
lang
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
<span>...</span>
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 cpan.org) if you have an opinion one way or the other about what is a good way to specify protected text.
mob at cpan.org
I22r::Translate::Filter, I22r::Translate::Filter::HTML, I22r::Translate.
To install I22r::Translate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm I22r::Translate
CPAN shell
perl -MCPAN -e shell install I22r::Translate
For more information on module installation, please visit the detailed CPAN module installation guide.