The checks in here are for various best practices to consider while crafting phrases.
These are warnings only and are meant to help point out things that typically are best done differently but could possibly be legit and thus a human needs to consider and sort it out.
None
This will append '[comment,does this phrase really need to be entirely bracket notation?]' to the phrase.
The idea behind it is that a phrase that is entirely bracket notation is a sure sign that it needs done differently.
For example:
$lh->maketext('[numf,_1]',$n);
There is no need to translate that, it’d be the same in every locale!
You would simply do this:
$lh->numf($n)
$lh->maketext('[boolean,_1,Your foo has been installed.,Your foo has been uninstalled.]',$is_install);
Unnecessarily difficult to read/work with and without benefit. You can't use any other bracket notation. You can probably spot other issues too.
Depending on the situation you might do either of these:
if ($is_install) { $lh->maketext('Your foo has been installed.'); } else { $lh->maketext('Your foo has been uninstalled.'); }
or if you prefer to keep the variant–pair as one unit:
$lh->maketext('Your foo has been [boolean,_1,installed,uninstalled].',$is_install);
$lh->maketext('You can [output,url,http://support.example.com,visit our support page] for further assistance.');
What happens when support.example.com changes to custcare.example.com? You have to change, not only the caller but the lexicons and translations, ick!
Then after you do that your boss says, oh wait actually it needs to be customer.example.com …
But if you had passed it in as an argument:
$lh->maketext('You can [output,url,_1,visit our support page] for further assistance.', $url_db{'support_url'});
Now when support.example.com changes to custcare.example.com you update 'support_url' in %url_db–done.
He wants it to be customer.example.com, no problem update 'support_url' in %url_db–done.
$lh->maketext('The checksum was [_1].', $sum);
If $sum is empty or undef you get odd spacing (e.g. “was .” instead of “was.”), could lose info, (e.g. “wait, the checksum is what now?”), or change meaning completely (e.g. what if the checksum was the string “BAD”).
'The checksum was .' 'The checksum was BAD.' # what! my data is corrupt ⁈
That applies even if it is decorated some way:
'The checksum was <code></code>.' 'The checksum was <code>BAD</code>.' # what my data is corrupt ⁈
It promotes evil partial phrases (i.e. that are untranslatable which is sort of the opposite of localizing things no?)
$lh->maketext('The checksum was [_1].', $lh->maketext('inserted into the database)); # !!!! DON’T DO THIS !!!!
One way to visually distinguish what you intend regardless of the value given is simply to quote it:
The checksum was “[_1]”.
becomes:
The checksum was “”. # It is obvious that the sum is empty The checksum was “ ”. # It is obvious that the sum is all whitespace The checksum was “BAD”. # It is obvious that it is a string made up of B, A, and D and not a statement that the sum has a problem The checksum was “perfectly awesome”. # It looks weird so someone probably will notice and ask you to fix your code
In other words:
For browsers, any span-level tag which is empty is not expressed in the rendering of the page. Therefore if we wrap variable expressions in span-level DOM, the user stands a very real chance of seeing incompleteness or potentially not noticing errors at all.
This allows for flexibility since brakcet notation is not nestable (and should not be since it isn’t a templating engine).
Perhaps quotes are the wrong thing in a given instance: Depending on what you’re doing other things might work too:
An error has occured: [_2]
Sorry, [is_defined,_2,“_2” is an invalid,you must specify a valid] value for “[_1]”.
The domain ([_1]) could not be found. The clown (AKA [_1]) is down. The network ([_1] in IPv6) is up.
The user, [_1], already exists.
None.
To install Locale::Maketext::Utils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::Maketext::Utils
CPAN shell
perl -MCPAN -e shell install Locale::Maketext::Utils
For more information on module installation, please visit the detailed CPAN module installation guide.