I'm looking for a way to display some text in a view—information about who posted an article, and a link to read more—in a specific language based on which language for the site the user has selected.

I thought I'd do this with a "Customfield: PHP Code" to make an if statement echoing a string depending on the language.

How do I access this variable, or how do I solve the problem in another way?

1 Answer 1


The standard way to display text strings in Drupal is using the t() function. You should enter your text in English and it will be translated to the corresponding string in the current user's language.

If you still want to know the current user's language, you can load the user like this:

$user = user_load(uid);

and the language will be available on


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.