Support functions for internationalization.
This file activates support for the GNU gettext extension if it is loaded and falls back to an ad hoc system using native PHP functions otherwise.
function _( |
| ) |
Mimics the behavior of gettext.
str | The string to translate. |
The translated string. If no translated version is found for the current language, then the str parameter is returned.
function lang_js( |
| ) |
Gets a link to the JavaScript translation file for the configured language. This should be linked into any page that generates text from JavaScript. If the correct translation file does not exist, then use the English file.
function fmtdate( |
| ) |
Print a formatted date.
This function exists because strftime prints localized strings using the local character set. So, for example, if you are running on Windows and set the locale to "rus" (Russian"), then you get a the Windows Russian date, which is in whatever 2-byte encoding Windows uses for Russian. Needless to say, this breaks the page.
The ugly, hacky solution is to offer the user the alternative of using strftime, which respects the locale and hence causes problems, or date, which is stupid and ignores the locale.
Note that this function now attempts to auto-convert from strftime() format codes to date() format codes. Since all strftime() codes start with a %, old code that uses date() codes will be unaffacted.
fmt | The format string for the date |
ts | The optional timestamp to use for the date. |
The formatted date string.
function p_( |
| ) |
A convenience funtion to print a translated string.
str | The string to translate. |
A convenience function that mixes translation with printf.
Takes a variable list of parameters, the first of which is a format string for printf, which will be translated. The remainder are the substitution variables for printf.
A convenience function that mixes translation with sprintf.
Takes a variable list of parameters, the first of which is a format string for printf, which will be translated. The remainder are the substitution variables for printf.
The first argument, translated with the the other arguments substituted for the appropriate scancodes.