[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/admin/ -> lang.php (summary)

Display the admin/language menu and process strings translation.

File Size: 1378 lines (60 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 14 functions

  lang_save_file()
  lang_fix_value_from_file()
  lang_fix_value_before_save()
  lang_make_directory()
  lang_form_string_key()
  lang_file_string_key()
  lang_xhtml_save_substr()
  lang_standard_locations()
  lang_extra_locations()
  lang_get_file_info()
  lang_help_standard_locations()
  lang_help_extra_locations()
  lang_help_preview_url()
  lang_help_save_file()

Functions
Functions that are not part of a class:

lang_save_file($path, $file, $strings, $local, $packstrings)   X-Ref
Save language translation file.

Thanks to Petri Asikainen for the original version of code
used to save language files.

param: string $path Full pathname to the directory to use
param: string $file File to overwrite
param: array $strings Array of strings to write
param: bool $local Should *_local version be saved?
param: array $packstrings Array of default langpack strings (needed if $local)
return: bool Created successfully?

lang_fix_value_from_file($value='')   X-Ref
Fix value of the translated string after it is load from the file.

These modifications are typically necessary to work with the same string coming from two sources.
We need to compare the content of these sources and we want to have e.g. "This string\r\n"
to be the same as " This string\n".

param: string $value Original string from the file
return: string Fixed value

lang_fix_value_before_save($value='')   X-Ref
Fix value of the translated string before it is saved into the file

param: string $value Raw string to be saved into the lang pack
return: string Fixed value

lang_make_directory($dir, $shownotices=true)   X-Ref
Try and create a new language directory.

Uses PHP>=5.0 syntax of mkdir and tries to create directories recursively.

param: string $directory full path to the directory under $langbase
return: string|false Returns full path to directory if successful, false if not

lang_form_string_key($keyfromfile)   X-Ref
Return the string key name for use in HTML form.

Required because '.' in form input names get replaced by '_' by PHP.

param: string $keyfromfile The key name containing '.'
return: string The key name without '.'

lang_file_string_key($keyfromform)   X-Ref
Return the string key name for use in file.

Required because '.' in form input names get replaced by '_' by PHP.

param: string $keyfromfile The key name without '.'
return: string The key name containing '.'

lang_xhtml_save_substr($str, $start, $length = NULL)   X-Ref
Return the substring of the string and take care of XHTML compliance.

There was a problem with pure substr() which could possibly produce XHTML parsing error:
substr('Marks & Spencer', 0, 9) -> 'Marks &am' ... is not XHTML compliance
This function takes care of these cases. Fixes MDL-8852.

Thanks to kovacsendre, the author of the function at http://php.net/substr

param: string $str The original string
param: int $start Start position in the $value string
param: int $length Optional length of the returned substring
return: string The substring as returned by substr() with XHTML compliance

lang_standard_locations()   X-Ref
Finds all English string files in the standard lang/en_utf8 location.

Core lang files should always be stored here and not in the module space (MDL-10920).
The English version of the file may be found in
$CFG->dirroot/lang/en_utf8/filename
The localised version of the found file should be saved into
$CFG->dataroot/lang/currentlang[_local]/filename
where "filename" is returned as a part of the file record.

return: array Array of a file information. Compatible format with {@link lang_extra_locations()}

lang_extra_locations()   X-Ref
Finds all English string files in non-standard location.

Searches for lang/en_utf8/*.php in various types of plugins (blocks, database presets, question types,
3rd party modules etc.) and returns an array of found files details.

The English version of the file may be found in
$CFG->dirroot/location/plugin/lang/en_utf8/filename
The localised version of the found file should be saved into
$CFG->dataroot/lang/currentlang[_local]/prefix_plugin.php
where "location", "plugin", "prefix" and "filename" are returned as a part of the file record.

return: array Array of a file information. Compatible format with {@link lang_standard_locations()}

lang_get_file_info($currentfile, $stringfiles)   X-Ref
Lookup for a stringfile details.

English files can be stored in several places (core space or module/plugin space). Their translations
go into the one directory - the current language pack. Therefore, the name of the stringfile may be
considered as a key of the list of all stringfiles.

param: string $currentfile the filename
param: array $stringfiles the array of file info returned by {@link lang_extra_locations()}
return: array Array of a file information (filename, location, plugin, prefix) or null.

lang_help_standard_locations()   X-Ref
Returns all English help files in the standard lang/en_utf8/help location.

Core help files should always be stored here and not in the module space (MDL-10920).
The English version of the file may be found in
$CFG->dirroot/lang/en_utf8/help/filename
The localised version of the found file should be saved into
$CFG->dataroot/lang/currentlang[_local]/help/filename
where "filename" is returned as a part of the file record.

return: array Array of a file information. Compatible format with {@link lang_extra_locations()}

lang_help_extra_locations()   X-Ref
Returns all English help files in non-standard location.

Searches for lang/en_utf8/help/* files in various types of plugins (blocks, database presets, question types,
3rd party modules etc.) and returns an array of found files details.

The English version of the file may be found in
$CFG->dirroot/location/plugin/lang/en_utf8/help/filename
The localised version of the found file should be saved into
$CFG->dataroot/lang/currentlang[_local]/help/prefix_plugin/filename (XXX is "prefix" here right?)
where "location", "plugin", "prefix" and "filename" are returned as a part of the file record.

return: array Array of a file information. Compatible format with {@link lang_standard_locations()}

lang_help_preview_url($currentfile, $skiplocal=false, $forcelang = '')   X-Ref
Return a preview URL for help file, if available.

param: string $currentfile The relative path to the help file, e.g. "assignment/types.html" - MDL-12291
param: bool $skiplocal Force displaying the helpfile from a master lang pack
param: string $forcelang Force language of the help, e.g. "en_utf8"
return: string $url

lang_help_save_file($helproot, $file, $content)   X-Ref
Saves (overwrites) translated help file.

param: string $helproot The path to the "help" folder
param: string $file The relative path to the html help file
param: string $content HTML data to be saved
return: bool False if save failed, true otherwise



Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7