The correct way to change the name of the language in the language switch
Check, if the variable is set, to avoid the error:

function theme_preprocess_block(&amp;$variables) {
  if (isset($variables['content']['#links']['zh-hans']['title'])) {
    $variables['content']['#links']['zh-hans']['title'] = '中文';
  }
}