Skip to content
This repository has been archived by the owner on Jul 5, 2019. It is now read-only.

Commit

Permalink
#225 & #203: translation suggestion v1
Browse files Browse the repository at this point in the history
  • Loading branch information
jbs1 committed Jun 11, 2016
1 parent b750283 commit 1741713
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion sites/all/modules/mathhub_user/mathhub_user.module
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,62 @@ function mathhub_user_gitlab_api_call_repos($access_token){
}
}

function mathhub_user_node_view($node, $view_mode, $langcode){
global $user;
if($node->type=='oaff_doc'){//check if node is mathhub doc
$t=explode(".", $node->title)[0];
$weight=1000;
// watchdog('node',print_r($node->content,1),array(), WATCHDOG_NOTICE);

foreach ($user->data['languages'] as $l) {//go through each language the user has set

// special case chinese
if($l=="zh-hant"){
$result=db_query("SELECT * FROM {node} WHERE title='".$t.".zht"."'");
if ($result->rowCount()<=0) {
// watchdog('node_missing',$t.".zht",array(), WATCHDOG_NOTICE);
// $frm=oaff_features_add_doc();
// $frm['#weight']=$weight;
// $weight+=10;
// $node->content['translate_zht']=$frm;
$node->content['translate_zht']=array(
'#title' => "Translate ".$l,
'#markup' => "Please translate the node for ".$t." ".l("here","mh/add-document")." to the language ["."zht"."].",
'#weight' => $weight,
);
$weight+=10;
}
}
elseif($l=="zh-hans"){
$result=db_query("SELECT * FROM {node} WHERE title='".$t.".zhs"."'");
if ($result->rowCount()<=0) {
// watchdog('node_missing',$t.".zh",array(), WATCHDOG_NOTICE);
$node->content['translate_zhs']=array(
'#title' => "Translate ".$l,
'#markup' => "Please translate the node for ".$t." ".l("here","mh/add-document")." to the language ["."zhs"."].",
'#weight' => $weight,
);
$weight+=10;
}
}else{//rest of the languages
$result=db_query("SELECT * FROM {node} WHERE title='".$t.".".$l."'");
if ($result->rowCount()<=0) {
// watchdog('node_missing',$t.".".$l,array(), WATCHDOG_NOTICE);
$node->content['translate_'.$l]=array(
'#title' => "Translate ".$l,
'#markup' => "Please translate the node for ".$t." ".l("here","mh/add-document")." to the language [".$l."].",
'#weight' => $weight,
);
$weight+=10;
}
}

// watchdog('node',print_r($node->content,1),array(), WATCHDOG_NOTICE);

}
}
}

function mathhub_user_gitlab_api_call_user($access_token){
global $user;

Expand Down Expand Up @@ -384,7 +440,7 @@ function mathhub_user_gitlab($verbose=true)
}

} else {
if($verbose){print("Couldn't finish REPO API call!");}
if($verbose){print("Couldn't finish USER API call!");}
}
}

Expand Down

0 comments on commit 1741713

Please sign in to comment.