Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Using variables in localization strings.

Using variables in localization strings: Difference between revisions

From MoodleDocs
No edit summary
(Shifted to dev docs)
 
Line 1: Line 1:
Language strings are defined as follows:
{{Moved_to_dev_docs}}
 
<pre>$string['stringname'] = 'This is a string';</pre>
 
and are called via:
 
<pre>get_string("stringname","wherefrom")</pre>
 
If you wish to use a variable from the calling page in the string then you will need to use the following variation to call it:
 
<pre>get_string("stringname","wherefrom","passedvariable")</pre>
 
The variable can then be used in your string as follows:
 
<pre>$string['stringname'] = 'This is a string with a variable called {$a}';</pre>
 
Note that in Moodle 1.9, the { } are optional. From Moodle 2.0 onwards, they are required, so you should get into the habit of using them now.
 
 
[[Category:Developer|Localization strings and variables]]
[[Category:Language]]

Latest revision as of 08:46, 22 June 2011

This development related page is now located in the Dev docs.

See the Using variables in localization strings page in the Dev docs.