diff --git a/src/www/translator/translator.js b/src/www/translator/translator.js index c7b6cea04..0dfd5126e 100644 --- a/src/www/translator/translator.js +++ b/src/www/translator/translator.js @@ -483,7 +483,7 @@ Translator.prototype.import=function(el) { } function done() { function add_segments(text) { - var ls=text.split("\n") + var ls=lines(text) var segs= punct.firstChild.checked ? split_punct(text,punctchars.value) : paras.firstChild.checked @@ -571,7 +571,7 @@ Translator.prototype.import_globalsight=function(el) { } function done() { function import_text(name,text) { - var ls=text.split("\n") + var ls=lines(text) if(ls.length>0 && ls[0]=="# GlobalSight Download File") { t.current=null; t.local.put("current",null) @@ -973,6 +973,13 @@ function split_punct(text,punct) { return segs } +// Break a string into lines +function lines(text) { + var ls=text.split("\r\n") // DOS + if(ls.length<=1) ls=text.split(/\n|\r/) // Unix | Mac + return ls +} + function supports_local_files() { // See http://www.html5rocks.com/en/tutorials/file/dndfiles/ return window.File && window.FileList && window.FileReader