mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
simple translator: accept DOS, Mac and Unix line breaks when importing text
This commit is contained in:
@@ -483,7 +483,7 @@ Translator.prototype.import=function(el) {
|
|||||||
}
|
}
|
||||||
function done() {
|
function done() {
|
||||||
function add_segments(text) {
|
function add_segments(text) {
|
||||||
var ls=text.split("\n")
|
var ls=lines(text)
|
||||||
var segs= punct.firstChild.checked
|
var segs= punct.firstChild.checked
|
||||||
? split_punct(text,punctchars.value)
|
? split_punct(text,punctchars.value)
|
||||||
: paras.firstChild.checked
|
: paras.firstChild.checked
|
||||||
@@ -571,7 +571,7 @@ Translator.prototype.import_globalsight=function(el) {
|
|||||||
}
|
}
|
||||||
function done() {
|
function done() {
|
||||||
function import_text(name,text) {
|
function import_text(name,text) {
|
||||||
var ls=text.split("\n")
|
var ls=lines(text)
|
||||||
if(ls.length>0 && ls[0]=="# GlobalSight Download File") {
|
if(ls.length>0 && ls[0]=="# GlobalSight Download File") {
|
||||||
t.current=null;
|
t.current=null;
|
||||||
t.local.put("current",null)
|
t.local.put("current",null)
|
||||||
@@ -973,6 +973,13 @@ function split_punct(text,punct) {
|
|||||||
return segs
|
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() {
|
function supports_local_files() {
|
||||||
// See http://www.html5rocks.com/en/tutorials/file/dndfiles/
|
// See http://www.html5rocks.com/en/tutorials/file/dndfiles/
|
||||||
return window.File && window.FileList && window.FileReader
|
return window.File && window.FileList && window.FileReader
|
||||||
|
|||||||
Reference in New Issue
Block a user