var result = {success: false};
source = crowdin.source.replace(/(?:\r\n|\r)/g, '\n');
translation = crowdin.translation.replace(/(?:\r\n|\r)/g, '\n');
sourceMatch = source.match(/^[ ]+/g);
translationMatch = translation.match(/^[ ]+/g);
if (null != sourceMatch) {
sourceMatch = sourceMatch[0];
if (null != translationMatch) {
translationMatch = translationMatch[0];
sourceLeadingSpaces = null !== sourceMatch ? sourceMatch.length : 0;
translationLeadingSpaces = null !== translationMatch ? translationMatch.length : 0;
if (sourceLeadingSpaces != translationLeadingSpaces) {
if (sourceLeadingSpaces == 0) {
result.message = 'The source text does not begin with a space, please remove ' + translationLeadingSpaces + ' space(s) at the beginning of your translation.';
} else if (translationLeadingSpaces == 0) {
result.message = 'The source text begins with ' + sourceLeadingSpaces + ' space(s), please add ' + sourceLeadingSpaces + ' space(s) at the beginning of your translation.';
result.message = 'The source text begins with ' + sourceLeadingSpaces + ' space(s), please use the same amount of spaces at the beginning of your translation.';
if (sourceLeadingSpaces > translationLeadingSpaces) {
replacement: sourceMatch.slice(0, sourceLeadingSpaces - translationLeadingSpaces)
result.fixes = [{from_pos: 0, to_pos: translationLeadingSpaces - sourceLeadingSpaces, replacement: ''}];