From 761155628f84f26239d04e4d431af87a95b2c2ee Mon Sep 17 00:00:00 2001 From: dhawes Date: Mon, 4 Oct 2004 16:44:54 +0000 Subject: [PATCH] Additional phpdoc comments for get_string and print_string functions - example usage added and argument types documented --- lib/moodlelib.php | 77 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 3486e46691..65d966fe9d 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2845,18 +2845,37 @@ function current_language() { } /** - * Given a string to translate - prints it out. - * - * @param string $identifier ? - * @param string $module ? - * @param mixed $a ? - */ + * Prints out a translated string. + * + * Prints out a translated string using the return value from the {@link get_string()} function. + * + * Example usage of this function when the string is in the moodle.php file:
+ * + * echo ''; + * print_string('wordforstudent'); + * echo ''; + * + * + * Example usage of this function when the string is not in the moodle.php file:
+ * + * echo '

'; + * print_string('typecourse', 'calendar'); + * echo '

'; + *
+ * + * @param string $identifier The key identifier for the localized string + * @param string $module The module where the key identifier is stored. If none is specified then moodle.php is used. + * @param mixed $a An object, string or number that can be used + * within translation strings + */ function print_string($identifier, $module='', $a=NULL) { echo get_string($identifier, $module, $a); } /** - * Return the translated string specified by $identifier as + * Returns a localized string. + * + * Returns the translated string specified by $identifier as * for $module. Uses the same format files as STphp. * $a is an object, string or number that can be used * within translation strings @@ -2864,12 +2883,46 @@ function print_string($identifier, $module='', $a=NULL) { * eg "hello \$a->firstname \$a->lastname" * or "hello \$a" * + * If you would like to directly echo the localized string use + * the function {@link print_string()} + * + * Example usage of this function involves finding the string you would + * like a local equivalent of and using its identifier and module information + * to retrive it.
+ * If you open moodle/lang/en/moodle.php and look near line 1031 + * you will find a string to prompt a user for their word for student + * + * $string['wordforstudent'] = 'Your word for Student'; + * + * So if you want to display the string 'Your word for student' + * in any language that supports it on your site + * you just need to use the identifier 'wordforstudent' + * + * $mystring = ''. get_string('wordforstudent') .''; +or + * + * If the string you want is in another file you'd take a slightly + * different approach. Looking in moodle/lang/en/calendar.php you find + * around line 75: + * + * $string['typecourse'] = 'Course event'; + * + * If you want to display the string "Course event" in any language + * supported you would use the identifier 'typecourse' and the module 'calendar' + * (because it is in the file calendar.php): + * + * $mystring = '

'. get_string('typecourse', 'calendar') .'

'; + *
+ * + * As a last resort, should the identifier fail to map to a string + * the returned string will be [[ $identifier ]] + * * @uses $CFG - * @param string $identifier ? - * @param string $module ? - * @param mixed $a ? - * @return string - * @todo Finish documenting this function + * @param string $identifier The key identifier for the localized string + * @param string $module The module where the key identifier is stored. If none is specified then moodle.php is used. + * @param mixed $a An object, string or number that can be used + * within translation strings + * @return string The localized string. */ function get_string($identifier, $module='', $a=NULL) { -- 2.39.5