Skip to content

Commit 25e2af4

Browse files
committed
update
1 parent caab56e commit 25e2af4

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

Multilingual.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,24 @@ public function getRecordVar($data){
370370
return $row['field_name'];
371371
}
372372

373+
public function getSavedLang($data){
374+
if($data['record_id'] != ''){
375+
$langVar = $this->getProjectSetting('languages_variable', $data['project_id']);
376+
$tmp = json_decode(REDCap::getData($data['project_id'], 'json', array($data['record_id']), array($langVar)),true);
377+
if(!empty($tmp)){
378+
header('Content-Type: application/json');
379+
echo json_encode($tmp[0][$langVar]);
380+
}
381+
else{
382+
return null;
383+
}
384+
}
385+
else{
386+
return null;
387+
}
388+
389+
}
390+
373391
public function updateLangVar($data){
374392
if($data['record_id'] != ''){
375393
$exist = json_decode(\REDCap::getData($data['project_id'], 'json', $data['record_id']), true);

index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
case 3:
2020
$module->getSettings($data);
2121
break;
22+
case 4:
23+
$module->getSavedLang($data);
24+
break;
2225
default:
2326
exit;
2427
}

js/multilingual_survey.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
(function(){
1+
var Multilingual = (function(){
22
//load languages
33
var pdf_url = 'REDCAP_PDF_URL';
44
var ajax_url = 'REDCAP_AJAX_URL';
55
var langVar = 'REDCAP_LANGUAGE_VARIABLE';
66

7+
//get language choice from url
8+
getURLLanguage();
9+
710
var project_id = getVariable('pid');
811
//var languages = {1: 'en', 2: 'es', 3: 'fr'};
912
var languages = {1: 'en', 2: 'es'};
@@ -194,6 +197,14 @@
194197
}
195198
}
196199
}
200+
201+
function getURLLanguage(){
202+
//use url
203+
if(getVariable(langVar)){
204+
setNormalCookie('p1000Lang', getVariable(langVar), .04);
205+
return;
206+
}
207+
}
197208

198209
function loadSettings(){
199210
// Get Settings JSON
@@ -579,10 +590,10 @@
579590
$('#' + id + '-tr').find('button').html(translations['answers'][id]['text'][0]);
580591
}
581592
else if(translations['answers'][id]['type'] == 'signature'){
582-
$('#' + id + '-tr').children().last().children().eq(3).children().eq(1).html(translations['answers'][id]['text'][0]);
593+
$('#' + id + '-tr').find('.fileuploadlink').html(translations['answers'][id]['text'][0]);
583594
}
584595
else if(translations['answers'][id]['type'] == 'file'){
585-
$('#' + id + '-tr').children().last().children().eq(2).children().eq(1).html(translations['answers'][id]['text'][0]);
596+
$('#' + id + '-tr').find('.fileuploadlink').html(translations['answers'][id]['text'][0]);
586597
}
587598
else if(translations['answers'][id]['type'] == 'slider'){
588599
if (translations['answers'][id]['text'][0] != null) $('#sldrlaba-' + id).html(translations['answers'][id]['text'][0]);
@@ -633,7 +644,7 @@
633644
var id2;
634645
for(id2 in translations['answers'][id]['text']){
635646
$('#'+id+'-tr .choicevert').each(function(){
636-
$(this).show();
647+
//$(this).show();
637648
if($(this).find('[name="__chk__' + id + '_RC_' + id2 + '"]').length) {
638649
$(this).contents().last().html(' ' + translations['answers'][id]['text'][id2]);
639650
$(this).data('lang', lang);
@@ -646,7 +657,7 @@
646657
for(id2 in translations['answers'][id]['text']){
647658
$('.ec').each(function(){
648659
var tmp = $(this).parent().attr('comps').split(',');
649-
$(this).show();
660+
//$(this).show();
650661
if(tmp[0] == id && tmp[2] == id2) {
651662
$(this).html(translations['answers'][id]['text'][id2]);
652663
$(this).data('lang', lang);

0 commit comments

Comments
 (0)