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::conlang::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::conlang::TranslationResult::unknownWords

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

Functions

TranslationResult ew::app::conlang::translateFromConlang(const ew::core::conlang::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::conlang::translateToConlang(const ew::core::conlang::Language &language, const QString &glossText)

Translates glossText – a passage in the writer's own language – into language by replacing what it recognizes with the lexicon entry that carries that meaning. A run of words matches an entry when it equals the entry's whole gloss, and a single word matches when it equals the head (last) word of one, so an entry glossed "to run" answers to "to run" and to "run" alone. The longest run that matches at a point wins, and punctuation between two words ends a 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.