Drupal 7 default language after translation

When we translate a drupal site from English to any other language, let’s say Arabic, it will be fine if we make English as default language, but if we change the default language to be Arabic then we will face a problem, all translations will disappear, in order to solve that we have to implement our function to do that by implementing hook_language_negotiation_info()

 * Implements hook_language_negotiation_info()
function mymodule_language_negotiation_info() {

  $providers = array();
  $providers['default-arabic'] = array(
    'callbacks' => array('language' => 'mymodule_language_arabic'), 
    'file' => drupal_get_path('module', 'mymodule') .'/mymodule.module',
    'weight' => -4, 
    'name' => t('Arabic'), 
    'description' => t("Use Arabic language by default."),
  return $providers;

function mymodule_language_arabic($languages) {
  global $user;
  if ($user->uid == 1) {
    return FALSE;
  return 'ar';

After that go to Languages-> Detection and Selection and choose “Use Arabic language by default” which we defined above.

Leave a Comment.