The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Normalization

The checks in here are for various best practices to consider while crafting phrases.

Rationale

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.

possible violations

None

possible warnings

Entire phrase is bracket notation, is there a better way in this case?

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:

method
    $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)
overly complex
    $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);
Hard coded URLs can be a maintenance nightmare, why not pass the URL in so the phrase does not change if the URL does
     $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.

Bare variable can lead to ambiguous output
    $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:

Using “ and ” disambiguates the entire string’s intent. No accidental or malicious meaning changes.
They also provide substance to a variable that may very well be null.

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.

Having this dis-ambiguation also assists the translator:
They can use whatever their locale uses without needing bracket notation (e.g. « and »).

This allows for flexibility since brakcet notation is not nestable (and should not be since it isn’t a templating engine).

When the translators see <strong> or any other wrapping element in the phrase, they will not immediately know what’s going on.
It helps programmers make better choices.

Perhaps quotes are the wrong thing in a given instance: Depending on what you’re doing other things might work too:

Trailing introductory “:”:
   An error has occured: [_2]
Alternate text:
   Sorry, [is_defined,_2,“_2” is an invalid,you must specify a valid] value for “[_1]”.
Parentheses:
   The domain ([_1]) could not be found.

   The clown (AKA [_1]) is down.

   The network ([_1] in IPv6) is up.
Comma reference:
   The user, [_1], already exists.
Etc etc

Checks only run under extra filter mode:

None.