fix a few translate.js bugs.

This commit is contained in:
Rex YE 2016-11-24 14:16:23 +00:00
parent 63f1414c7d
commit cf32bc26c8
2 changed files with 110 additions and 104 deletions

View File

@ -1,4 +1,4 @@
.docs-content { .docs-content, .l-content, .main-footer {
display: none; display: none;
.original-english { .original-english {
border-top: 1px dashed $regal; border-top: 1px dashed $regal;

View File

@ -1,10 +1,10 @@
// TODO: refactor me! // TODO: refactor me!
var sourceVisible = localStorage.getItem('source-visible') === 'true'; var sourceVisible = localStorage.getItem('source-visible') === 'true';
(function ($) { (function ($) {
var content = document.querySelector('article.docs-content'); var content = document.querySelector('article');
var footer = document.querySelector('.main-footer'); var footer = document.querySelector('.main-footer');
processContainer(content); processContainer(content);
processContainer(footer);
if (!sourceVisible) { if (!sourceVisible) {
var nodes = document.querySelectorAll('.original-english'); var nodes = document.querySelectorAll('.original-english');
@ -40,6 +40,7 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
case 'H5': case 'H5':
case 'H6': case 'H6':
case 'HEADER': case 'HEADER':
case 'LI':
if (processBlock(node)) { if (processBlock(node)) {
i++; i++;
} }
@ -47,7 +48,8 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
case 'TD': case 'TD':
case 'TH': case 'TH':
processContainer(node); processContainer(node);
return; // stop // return; // stop
break;
default: default:
if (node.children.length > 0) { if (node.children.length > 0) {
processContainer(node); processContainer(node);
@ -95,8 +97,12 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
} }
function isPureEnglish(text) { function isPureEnglish(text) {
if(text){
return !/\p{Han}/.test(text); return !/\p{Han}/.test(text);
} }
return false;
}
function attributesToString(node) { function attributesToString(node) {
return _.chain(node.attributes) return _.chain(node.attributes)