...->loc_('This is a text.');
...->loc_npx(
'appointment', # context
'This is {dates :num} date.', # singular
'This are {dates :num} dates.', # plural
1, # plural selection
dates => 1, # placeholder replacement
);
...->loc_m(
'Send email to <strong>[_1]</strong>.',
# ^^^^
'Max Mustermann <mustermann@example.com>',
);
With Maketext, you can not give the placeholder attribute ":html".
...->loc_mp(
'appointment', # context
'This are [*,_1,date,dates].',
# ^^^
1, # plural selection and placeholder replacement
);
At Maketext plural is limited.
HTML is also translatable. But it's 2nd choice to plain text.
JavaScript is also translated.
...->loc_('... <a href="foo.de" on...="...">...</a> ...');
There is a risk to destroy HTML and JavaScript during translation.
HTML is unlikely broken, because primitive. JavaScript does not break.
The solution here is HTML::Zoom and an empty a tag, because it is configured only during rendering. (Patrick Grämer)
<span class="...">... <a>...</a> ...</span>
->replace_content( \$ctx->loc_('<a>...</a>') )
->then
->collect({
filter => sub {
$_
->select('a')
->set_attribute('href' => 'foo.de');
},
passthrough => 1,
})
<script type="text/javascript">
var language_locales = {
"LC_NUMERIC":{
"decimal_point":".", "thousands_sep":",", "grouping":["3","3"]
},
"LC_MONETARY":{
"n_sep_by_space":"0", "currency_symbol":"£", "p_sign_posn":"1", "negative_sign":"-", "int_curr_symbol":"GBP ", "frac_digits":"2", "p_sep_by_space":"0", "positive_sign":"", "n_cs_precedes":"1", "p_cs_precedes":"1", "int_frac_digits":"2", "mon_grouping":["3","3"], "n_sign_posn":"1", "mon_thousands_sep":",", "mon_decimal_point":"."}
};
var language_tag = "i-default";
$(function() {
$.datepicker.setDefaults($.datepicker.regional['en-GB']);
Locale::TextDomain::OO::Extract
Locale::TextDomain::OO::Process
https://metacpan.org/.../example/21_process_utf-8.pl
The example says all about the process. When working with MO files, you must still run at the end:
$process->spew(mo => "../2nd_${language}_${domain}_clean.mo");
Locale::Utils::Autotranslator
Locale::Utils::Autotranslator
https://metacpan.org/.../example/01_my_translator_utf-8.pl
The example also shows how the placeholders pass the translation tool.