Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

About PluralTranslate()

OniaOnia New
edited February 2013 in Localization

Could someone tell me how to localize the following strings?

\applications\vanilla\views\discussions\helper_functions.php

 printf(PluralTranslate($Discussion->CountComments, 
               '%s comment html', '%s comments html', '%s comment', '%s comments'),
               BigPlural($Discussion->CountComments, '%s comment'));

my language pack:

$Definition['%s comment'] = '%s XXXX';
$Definition['%s comments'] = '%s XXXX';

It didn't work.

Comments

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    Here's the function:

    function PluralTranslate($Number, $Singular, $Plural, $SingularDefault = FALSE, $PluralDefault = FALSE) {
        if ($Number == 1)
            return T($Singular, $SingularDefault);
        else
            return T($Plural, $PluralDefault);
    }
    

    Meaning that your locale definitions should look like this:

    $Definition['%s comment html'] = '%s XXXX';
    $Definition['%s comments html'] = '%s XXXX';
    

    Why is that? Because the $Singular and $Plural variables are the ones being used as identifiers in the PluralTranslate function (e.g. T($Singular, $SingularDefault).

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

    Onia
  • @kasperisager Solved! Thanks for your help.

Sign In or Register to comment.