Streamlining language calls

Not sure if this is common knowledge, so I thought I would throw it out there.

When asking the system for a language string we use the elgg_echo(''); function. This works nicely as expected.

However if you want to make your code a little cleaner (and less of it) it's possible to stick variables into your language calls.

Here's the catch:

If you're going to use a variable in your language call you need to use the double quotes "", not single quotes inside your elgg_echo("");

See below examples:

elgg_echo('course:{$obj}:status:user');

elgg_echo("course:{$obj}:status:user");

The first one will read the string directly and output what it sees course:{$obj}:status:user. The second one will deal with the variable and go and find the relevant language string.

Saves me a bit of time and space when coding versatile functions.

Navigation