How do I get the $language object inside a form builder? I have this necesity to use $language inside MY_MODULE_form($form, &amp;$form_state) function and it seems is not available. I tried to define it as global, but it displays blank.

global $language_content;
dpm($language_content-&gt;language);


My simplified structure of MY_MODULE_form() looks like this:

function MYMODULE_form($form, &amp;$form_state) {
global $language_content;
$form['name'] = array(
      '#type' =&gt; 'fieldset',
      '#title' =&gt; t('Name'),
  );
  $form['back'] = array(
      '#markup' =&gt; '&lt;div class="link" &gt;&lt;a href="/project/$LANG-HERE/my/home"&gt;'.t('Back').'&lt;/a&gt;&lt;/div&gt;',
  );
  return $form;
}


I found a hardcoded PHP solution:

if(strpos($haystack, 'en')) {
    $back_path = "/project/en/my/home";
    }
  if(strpos($haystack, 'fi')) {
    $back_path = "/project/fi/my/home";
  }
  $form['continue-shopping'] = array(
      '#markup' =&gt; '&lt;div class="link" &gt;&lt;a href="'.$back_path.'"&gt;'.t('Back').'&lt;/a&gt;&lt;/div&gt;',
  );


I am looking however to something more elegant.
Always use l() (or url(), which justs generates the URL) for generating links; then you, don't have to worry about the current language, base path, whatever clean URLs are enabled or not.

l(t('Back'), 'my/home');


That said, global $language should always work.