MyBB Community Forums

Full Version: How {#}'s work in Language Files?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can someone explain how those work to me,

How they are defined? Is it just the order of the variable definitions in the corresponding .php file

Just for example I'm looking at the language file: message.lang.php


I see the line:

{3}/member.php?action=resetpassword&uid={4}&code={5}

how are {3}{4}&{5} defined?
They're replaced in the code with our "sprintf" method. Look at the following example:
Language file:
Hello {1}!

Replacement:
echo $lang->sprintf($lang->message, $mybb->user['username']);

Output (when I'm the user):
Hello King Louis!

So it depends on the code which value is used - in the example above {3} would be the board url, {4} the user's id and {5} the generated reset code.
Thanks, I believe I understand now

If I need 4 variables it would be:

$lang->sprintf($lang->message, 1,2,3,4);
Yes, then {4} will be replaced by the fifth value passed to the method (since the first value is the string).
(2014-05-29, 03:33 AM)Omar G. Wrote: [ -> ]Yes, then {4} will be replaced by the fifth value passed to the method (since the first value is the string).

Thanks for the follow up, I believe I got it now