Change “en-US” to “en”

If you want to get the language of the browser do so:

$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);

If you want to redirect to ?lang=en:

header("location: {$_SERVER['REQUEST_URI']}?lang={$lang}");

You should read about HTTP_ACCEPT_LANGAUGE.

There are many ways you can dance with languages but you should understand some key points.

  1. Chose the default language of your website (French in your case)
  2. The user may be French but his OS & Browser can be in English because he wants to learn the language of trade.
  3. Create a cookie that stores the selected (or default) language so that you know what content to display. $_COOKIE["wpse_166976_lang"] = "fr" or $_COOKIE["wpse_166976_lang"] = $land where $lang = get_query_var("lang")

To get the language with WPML plugin, you could use ICL_LANGUAGE_CODE to get the language of the page

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)