Multi-language version

The multi-language version of the default site profile is in fact identical to the intermediate default site profile except for a few minor things:

In any given site, there is going to be some static text for things like buttons, auto-generated headlines and such. We can make these translatable by surrounding that text in a __('your text here') function. Once you've done that, you can translate that text per-language in ProcessWire's admin (Setup > Languages), and output values will be automatically changed depending on the language. There are also a couple of other variations on this function, used for certain situations. Here's an example of them all:

// This makes 'text' translatable  
__('text');

// Same as above, but with a specific context
// useful if the same term appears in multiple places
_x('text', 'context');

// For when we need singular and plural translation
_n('singular', 'plural', $count);

For more about making your static text translatable see our documentation on code internationalization.

The only other thing different about the multi-language default site profile is that it contains some additional code in the _main.php file for navigation that lets you view the page in each language. You'll see this near the top of the _main.php file.

Next: More template file resources »


  1. Introduction to template files
  2. Beginner version
  3. Intermediate version
  4. Multi-language version
  5. More template file resources

Comments

  • Andy

    Andy 1 year ago 21

    Hi Ryan

    Many languages have more plural forms than two. You can find it here
    http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms

    But in russian languige we have 3 - one (1), two (2,3,4), many (5,6,7,8,9,0)

    For example php code for russian count

    class datext{
    public static function proceedTextual( $numeric, $one, $two, $many )
    {
    $numeric = (int) abs($numeric);
    if ( (numeric % 100 == 1 || ($numeric % 100 > 20) && ( $numeric % 10 == 1 ) ) return $one;
    if ( $numeric % 100 == 2 || ($numeric % 100 > 20) && ( $numeric % 10 == 2 ) ) return $two;
    if ( $numeric % 100 == 3 || ($numeric % 100 > 20) && ( $numeric % 10 == 3 ) ) return $two;
    if ( $numeric % 100 == 4 || ($numeric % 100 > 20) && ( $numeric % 10 == 4 ) ) return $two;

    return $many;
    }
    }

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.