Skip to content

Commit 3c5ca70

Browse files
committed
@ signs in translations
1 parent 03abd21 commit 3c5ca70

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Multilingual.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ public function getTranslations($data, $projectSettings){
159159

160160
$response['all'][$row['field_name']] = $misc;
161161
foreach($misc AS $key => $value){
162+
//replace ___ with @
163+
$value = str_replace('___', '@', $value);
164+
162165
//questions
163166
if(strpos($value, 'p1000lang') !== false){
164167
$value = trim(str_replace('p1000lang', '', $value));
@@ -407,8 +410,11 @@ public function exportData($pid, $lang){
407410

408411
while($row = mysqli_fetch_array($result)){
409412
$misc = explode('@', $row['misc']);
410-
413+
411414
foreach($misc AS $key => $value){
415+
//replace ___ with @
416+
$value = str_replace('___', '@', $value);
417+
412418
//questions
413419
if(strpos($value, 'p1000lang') !== false){
414420
$value = trim(str_replace('p1000lang', '', $value));

js/multilingual_setup.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
function getTranslations(r){
160160
//parse existing data
161161
$('#div_parent_field_annotation textarea').val($('#div_parent_field_annotation textarea').val().replace(/\n([^@])/g, "<br>$1"));
162-
var data = $('#div_parent_field_annotation textarea').val();
162+
var data = $('#div_parent_field_annotation textarea').val().replace(/___/g, '@');
163163
var tags = data.split('\n');
164164
var id;
165165
var questions = {};
@@ -272,7 +272,7 @@
272272
if(counter > 0){
273273
var questions = {};
274274
$(this).children().val($(this).children().val().replace(/\n([^@])/g, "<br>$1"));
275-
var data = $(this).children().val();
275+
var data = $(this).children().val().replace(/___/g, '@');
276276
var tags = data.split('\n');
277277

278278
for(id in tags){
@@ -380,11 +380,11 @@
380380
others = $('.p1000_otherActionTags').val();
381381

382382
// inject p1000 action tags only if any translation exists
383-
var ques = ($.isEmptyObject(q))?'':('@p1000lang' + JSON.stringify(q) + '\n');
384-
var answ = ($.isEmptyObject(a))?'':('@p1000answers' + JSON.stringify(a) + '\n');
385-
var err = ($.isEmptyObject(e))?'':('@p1000errors' + JSON.stringify(e) + '\n');
386-
var note = ($.isEmptyObject(n))?'':('@p1000notes' + JSON.stringify(n) + '\n');
387-
var stext = ($.isEmptyObject(st))?'':('@p1000surveytext' + JSON.stringify(st) + '\n');
383+
var ques = ($.isEmptyObject(q))?'':('@p1000lang' + JSON.stringify(q).replace(/@/g, '___') + '\n');
384+
var answ = ($.isEmptyObject(a))?'':('@p1000answers' + JSON.stringify(a).replace(/@/g, '___') + '\n');
385+
var err = ($.isEmptyObject(e))?'':('@p1000errors' + JSON.stringify(e).replace(/@/g, '___') + '\n');
386+
var note = ($.isEmptyObject(n))?'':('@p1000notes' + JSON.stringify(n).replace(/@/g, '___') + '\n');
387+
var stext = ($.isEmptyObject(st))?'':('@p1000surveytext' + JSON.stringify(st).replace(/@/g, '___') + '\n');
388388

389389
$('#div_parent_field_annotation').children(0).val((ques + answ + err + note + stext + others).trim());
390390

@@ -404,7 +404,7 @@
404404
}
405405
});
406406

407-
var ques = ($.isEmptyObject(q))?'':('@p1000lang' + JSON.stringify(q) + '\n');
407+
var ques = ($.isEmptyObject(q))?'':('@p1000lang' + JSON.stringify(q).replace(/@/g, '___') + '\n');
408408

409409
$('.p1000_answers').each(function(){
410410
tmp = $(this).attr('id').replace('a','');
@@ -419,7 +419,7 @@
419419
}
420420
});
421421

422-
var answ = ($.isEmptyObject(a))?'':('@p1000answers' + JSON.stringify(a));
422+
var answ = ($.isEmptyObject(a))?'':('@p1000answers' + JSON.stringify(a).replace(/@/g, '___'));
423423

424424
//update
425425
count = 0;

0 commit comments

Comments
 (0)