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
m (moodle 2.0 syntax change)
(Shifted to dev docs)
 
(One intermediate revision by one other user not shown)
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>
<span class="small-info-right"><span class="text-small">Moodle </span><span class="text-big new">2.0</span></span>
<includeonly>[[Category:Moodle 2.0]]</includeonly>
Note the use of { } in Moodle 2.0 language files.
<pre>$string['stringname'] = 'This is a string with a variable called {$a}';</pre>
<noinclude>[[fr:Modèle:Moodle 2.0]]</noinclude>
 
 
 
[[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.