ConlangTranslate.h header

#include <ew/app/ConlangTranslate.h>

Namespace ew::app

TranslationResult struct

struct ew::app::TranslationResult

The outcome of translating a passage through a constructed language's lexicon: the rendered text with every recognized word swapped for its counterpart, plus the list of source words that had no dictionary entry (so the UI can report coverage and prompt the writer to coin the missing words).

Members

QString ew::app::TranslationResult::text

The translated passage. Words found in the lexicon are replaced; unknown words are passed through verbatim, and punctuation and spacing between words are preserved.

std::vector<QString> ew::app::TranslationResult::unknownWords

The distinct source words (lowercased) that had no lexicon match, in first-seen order.

Functions

TranslationResult ew::app::translateFromConlang(const ew::core::Language &language, const QString &conlangText)

Translates conlangText – a passage written in language – back into the writer's language by replacing each word with its lexicon gloss. Matching is by exact word (ignoring case and surrounding punctuation); a capitalized source word yields a capitalized gloss. Words absent from the lexicon are passed through verbatim and reported in TranslationResult::unknownWords.

TranslationResult ew::app::translateToConlang(const ew::core::Language &language, const QString &glossText)

Translates glossText – a passage in the writer's own language – into language by replacing each word with a lexicon entry whose gloss matches it. Since translation is word-by-word, a word matches an entry when it equals the entry's whole gloss (for a single-word gloss) or the head (last) word of a multi-word gloss (so an entry glossed "to run" answers to "run"); when several entries match, the first in lexicon order wins. Matching ignores case, and a capitalized source word yields a capitalized translation. Punctuation attached to a word (e.g. a trailing comma) is preserved around the replacement.