diff --git a/Client/client.js b/Client/client.js index ad8bd380c..71964d0d8 100644 --- a/Client/client.js +++ b/Client/client.js @@ -5,12 +5,13 @@ let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment() global.env = ENVIRONMENT_MODULE process.on('uncaughtException', function (err) { - if (err.message.indexOf("EADDRINUSE") > 0) { + if (err.message && err.message.indexOf("EADDRINUSE") > 0) { console.log("A Superalgos Client cannot be started. Reason: the port " + port + " is already in use by another application.") return } console.log('[ERROR] Client -> client-> uncaughtException -> err.message = ' + err.message) console.log('[ERROR] Client -> client-> uncaughtException -> err.stack = ' + err.stack) + console.log('[ERROR] Client -> client-> uncaughtException -> err = ' + err) process.exit(1) }) diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/vaina.json b/Projects/Superalgos/Schemas/Docs-Concepts/vaina.json index 5f1f2de8c..ec299d611 100644 --- a/Projects/Superalgos/Schemas/Docs-Concepts/vaina.json +++ b/Projects/Superalgos/Schemas/Docs-Concepts/vaina.json @@ -4,7 +4,17 @@ "paragraphs": [ { "style": "Text", - "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." + "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode.", + "translations": [ + { + "language": "RU", + "text": "Esto esta escrito en ruso." + }, + { + "language": "ES", + "text": "Esto esta en espaniol." + } + ] }, { "style": "Text", diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 40b7cffbc..adcb6aebe 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -502,29 +502,39 @@ function newSuperalgosDocSpace() { if (paragraphs.length === 1) { /* There is no need to add new paragraphs, we just update the one we have. */ if (paragraphs[0] !== '') { - docSchemaParagraph.text = paragraphs[0] + setTextBasedOnLanguage(docSchemaParagraph, paragraphs[0]) } else { - docsSchemaDocument.paragraphs.splice(selectededitableParagraphIndex, 1) - if (docsSchemaDocument.paragraphs.length === 0) { - let newParagraph = { - style: 'Text', - text: 'Please contribute to the docs by editing this content.' + /* + Deleting paragarphs is only possible in the default language. + */ + if (language === DEFAULT_LANGUAGE) { + docsSchemaDocument.paragraphs.splice(selectededitableParagraphIndex, 1) + if (docsSchemaDocument.paragraphs.length === 0) { + let newParagraph = { + style: 'Text', + text: 'Please contribute to the docs by editing this content.' + } + docsSchemaDocument.paragraphs.push(newParagraph) } - docsSchemaDocument.paragraphs.push(newParagraph) } } } else { /* - We will update the one paragraph we have and we will add the rest. + Adding paragarphs is only possible in the default language. */ - docSchemaParagraph.text = paragraphs[0] + if (language === DEFAULT_LANGUAGE) { + /* + We will update the one paragraph we have and we will add the rest. + */ + setTextBasedOnLanguage(docSchemaParagraph, paragraphs[0]) - for (let i = 1; i < paragraphs.length; i++) { - let newParagraph = { - style: style, - text: paragraphs[i] + for (let i = 1; i < paragraphs.length; i++) { + let newParagraph = { + style: style, + text: paragraphs[i] + } + docsSchemaDocument.paragraphs.splice(selectededitableParagraphIndex + i, 0, newParagraph) } - docsSchemaDocument.paragraphs.splice(selectededitableParagraphIndex + i, 0, newParagraph) } } @@ -542,6 +552,29 @@ function newSuperalgosDocSpace() { } EDITOR_ON_FOCUS = false renderDocumentPage() + + function setTextBasedOnLanguage(paragraph, text) { + if (language === DEFAULT_LANGUAGE) { + paragraph.text = text + return + } + if (paragraph.translations === undefined) { + paragraph.translations = [] + } + for (let i = 0; i < paragraph.translations.length; i++) { + let translation = paragraph.translations[i] + if (translation.language === language) { + translation.text = text + return + } + } + let translation = { + language: language, + text: text + } + paragraph.translations.push(translation) + return + } } }