Pelzini

This is the code documentation for the Pelzini project

file /viewer/i18n.php

Namespace: viewer

View source


This is a set of functions for internationalisation.

The main functions are:
  loadLanguage for loading a language file
  str for returning a language string
  setParam for manually setting a replacement parameter
  clearParams for clearing all replacement parameters

Authors

Functions

clearParams

Clears all named parameters that are used by the str function

getOriginalString

Returns the original string from the string table, without any parameter replacement

loadLanguage

Loads a language file

If you are using a language which may not be complete, it is advisable
to load another language which you know is complete first (e.g. English)
This will prevent empty strings being returned.

param_replace

Replaces params in strings

Replacements can be in the following forms:
  {PARAM}
  Does a replacement with a named parameter, PARAM, specified in any case

  {#PLURAL|PARAM|SINGLE|MULTIPLE}
  Does a replacement with SINGLE if PARAM (any case) is 1, and with MULTIPLE if PARAM is anything else

  {#NL}
  Adds a new line to the output

  {#URLENC|PARAM}
  Returns the specified parameter, urlencode()ed.

  {#HTMLENC|PARAM}
  Returns the specified parameter, htmlspecialchars()ed.

param_replace_inner

Does the actual legwork for param_replace

setParam

Sets a named param for use by the str function

str

Outputs a string, and sets arguments

This function also allows additional functions after the string constant, printf style.
Because the language system uses named arguments, arguments should be specified in pairs
The first argument should be the param name, the second argument should be the param