app/autotranslate/server/msTranslate.js
/**
	 * Returns translated message for each target language.
	 * @private
	 * @param {object} message
	 * @param {object} targetLanguages
	 * @returns {object} translations: Translated messages for each language
	 */
Returns translated message for each target language.
@private
@param {object} message
@param {object} targetLanguages
@returns {object} translations: Translated messages for each language
Returns translated message for each target language . @private @param { object } message @param { object } targetLanguages @returns { object } translations : Translated messages for each language
_translateMessage(message, targetLanguages) {
		const msgs = message.msg.split('\n').map((msg) => ({ Text: msg }));
		try {
			return this._translate(msgs, targetLanguages);
		} catch (e) {
			msLogger.error({ err: e, msg: 'Error translating message' });
		}
		return {};
	}
_translateMessage ( message , targetLanguages ) { const msgs = message . msg . split ( '\n' ) . map ( ( msg ) => ( { Text : msg } ) ) ; try { return this . _translate ( msgs , targetLanguages ) ; } catch ( e ) { msLogger . error ( { err : e , msg : 'Error translating message' } ) ; } return { } ; }
Returns translated message for each target language.
Returns translated message for each target language .
// There are multi-sentence-messages where multiple sentences come from different languages // This is a problem for translation services since the language detection fails. // Thus, we'll split the message in sentences, get them translated, and join them again after translation