Textpattern PHP Cross Reference Content Management Systems

Summary: /textpattern/vendors/Textpattern/L10n/Lang.php - 823 lines - 25920 bytes - Source - Print

Description: Language manipulation.

Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Lang:: (21 methods):
__construct()
installed()
files()
findFilename()
fetchMeta()
available()
setPack()
getPack()
swapStrings()
installFile()
loadTextpack()
installTextpack()
upsertPack()
extract()
load()
getStrings()
hasString()
txt()
languageList()
languageSelect()
hasOwnerSupport()

Class: Lang


__construct($langDirectory = null)  line: 107
Constructor.

param: string $langDirectory Language directory to use
installed()  line: 126
Return all installed languages in the database.

return: array Available language codes
files($extensions = array('ini', 'textpack', 'txt')  line: 147
Return all language files in the lang directory.

return: array Available language filenames
param: array $extensions Language files extensions
findFilename($lang_code line: 175
Locate a file in the lang directory based on a language code.

return: string|null       The matching filename
param: string $lang_code The language code to look up
fetchMeta($file line: 200
Read the meta info from the top of the given language file.

return: array        Meta info such as language name, language code, language direction and last modified time
param: string $file The filename to read
available($flags = TEXTPATTERN_LANG_AVAILABLE, $force = 0)  line: 248
Fetch available languages.

Depending on the flags, the returned array can contain active,
installed or available language metadata.

return: array
param: int $flags Determine which type of information to return
param: int $force Force update the given information, even if it's already populated
setPack(array $strings, $merge = false)  line: 351
Set/overwrite the language strings. Chainable.

param: array $strings Set of strings to use
param: bool  $merge   Whether to merge the strings (true) or replace them entirely (false)
getPack($lang_code, $group = null, $filter = null)  line: 371
Fetch Textpack strings from the file matching the given $lang_code.

A subset of the strings may be fetched by supplying a list of
$group names to grab.

return: array
param: string|array $lang_code The language code to fetch, or array(lang_code, override_lang_code)
param: string|array $group     Comma-separated list or array of headings from which to extract strings
param: string|array $filter    Comma-separated list or array of strings that should be returned
swapStrings($lang, $group = 'admin')  line: 417
Temporarily override a bunch of strings with a set from a different language.

return: null|true           Returns true if language swap took place, null otherwise.
param: string|null $lang   The language from which to extract strings.
param: string|array $group List of groups (comma-separated or an array) to fetch in the new language.
installFile($lang_code, $owner = '')  line: 452
Install a language pack from a file.

param: string $lang_code The lang identifier to load
loadTextpack($textpack, $useLang = null)  line: 477
Load localisation strings from a Textpack using the given language.

param: array  $textpack    The Textpack to install
param: string $useLang     Import strings for this language
installTextpack($textpack, $addNewLangs = false)  line: 513
Install localisation strings from a Textpack.

return: int                 Number of installed strings
param: string $textpack    The Textpack to install
param: bool   $addNewLangs If TRUE, installs strings for any included language
upsertPack($langpack, $owner_ref = '')  line: 563
Insert or update a language pack.

return: result set
param: array  $langpack The language pack to store
param: string $langpack The owner to use if not in the pack
extract($lang_code, $events = null, $filter = null)  line: 599
Fetch the given language's strings from the database as an array.

If no $events are specified, only appropriate strings for the current context
are returned. If the 'txpinterface' constant is 'public' only strings from
events 'common' and 'public' are returned.

Note the returned array includes the language if the fallback has been used.
This ensures (as far as possible) a full complement of strings, regardless of
the degree of translation that's taken place in the desired $lang code.
Any holes can be mopped up by the default language.

return: array
param: string       $lang_code The language code
param: array|string $events    A list of loaded events to extract
param: string|array $filter    Comma-separated list or array of strings that should be returned
load($lang_code, $events = null)  line: 665
Load the given language's strings from the database into the class.

Note the returned array includes the language if the fallback has been used.
This ensures (as far as possible) a full complement of strings, regardless of
the degree of translation that's taken place in the desired $lang code.
Any holes can be mopped up by the default language.

return: array
param: string       $lang_code The language code
param: array|string $events    A list of loaded events to load
getStrings()  line: 697
Fetch the language strings from the loaded language.

return: array
hasString($var line: 708
Determine if a string key exists in the current pack

return: boolean
param: string  $var The string name to check
txt($var, $atts = array()  line: 722
Return a localisation string.

return: string A localisation string
param: string $var    String name
param: array  $atts   Replacement pairs
param: string $escape Convert special characters to HTML entities. Either "html" or ""
languageList($flags = null)  line: 759
Generate an array of languages and their localised names.

return: array
param: int $flags Logical OR list of flags indiacting the type of list to return:
languageSelect($name, $val, $flags = null)  line: 792
Generate a <select> element of languages.

return: string HTML
param: string $name  The HTML name and ID to assign to the select control
param: string $val   The currently active language identifier (en-gb, fr, de, ...)
param: int    $flags Logical OR list of flags indicating the type of list to return:
hasOwnerSupport()  line: 811
Determine if the class supports the 'owner' column or not.

Only of use during upgrades from older versions to guard against errors.

return: boolean

title

Body