Using variables in localization strings: Difference between revisions
From MoodleDocs
No edit summary |
m (moodle 2.0 syntax change) |
||
Line 14: | Line 14: | ||
<pre>$string['stringname'] = 'This is a string with a variable called $a';</pre> | <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:Developer|Localization strings and variables]] | ||
[[Category:Language]] | [[Category:Language]] |
Revision as of 07:57, 2 February 2011
Language strings are defined as follows:
$string['stringname'] = 'This is a string';
and are called via:
get_string("stringname","wherefrom")
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:
get_string("stringname","wherefrom","passedvariable")
The variable can then be used in your string as follows:
$string['stringname'] = 'This is a string with a variable called $a';
Moodle 2.0
Note the use of { } in Moodle 2.0 language files.
$string['stringname'] = 'This is a string with a variable called {$a}';