TranslationImport.h header
#include <ew/app/TranslationImport.h>
Namespace ew::app
TranslationImportSummary struct
struct ew::app::TranslationImportSummary
What an import did, so the writer is told rather than left to guess.
Every row a file contained is accounted for by exactly one of these counts. A number that does not add up is the writer's earliest warning that a file was not what they thought it was.
Members
int ew::app::localization::TranslationImportSummary::applied = 0
Translations stored or updated.
int ew::app::localization::TranslationImportSummary::unchanged = 0
Rows whose translation was already exactly what the catalogue held – re-importing the same file twice is a normal thing to do and must be visibly a no-op.
int ew::app::localization::TranslationImportSummary::untranslated = 0
Rows that came back with no translation. Nothing is stored, and nothing already stored is destroyed: an empty cell means "I did not get to this one", never "delete what you had".
int ew::app::localization::TranslationImportSummary::unknown = 0
Rows naming a string the project no longer has – a chapter deleted while the file was out being translated. Dropped, because there is nowhere to put them.
Functions
TranslationImportSummary ew::app::localization::applyTranslations(const ew::core::project::Project &project, ew::core::localization::TranslationCatalog &catalog, const std::vector< ImportedTranslation > &rows)
Applies rows to catalog, against the strings project currently has.
Each row is digested by its OWN sourceText, not the project's current source. That is the whole reason the readers keep it. If the writer revised a chapter while the file was out, the returned translation is of the old words, and storing it against today's prose would certify a translation the translator was never shown – silently, and exactly where staleness exists to speak up. Digested this way it lands as Stale immediately, which is the truth.
A row is checked against the project before it is stored. A translation whose string has been deleted has nowhere to belong; keeping it would grow the catalogue with entries no export could ever list again.
An empty translation never deletes an existing one. A translator returning a file with blanks has not translated those strings yet; treating a blank as a deletion would destroy earlier work on the strength of somebody skipping a row.
This mutates catalog in place and does not touch the project. The caller wraps the result in one ew::core::localization::SetTranslationsCommand – a returned file is hundreds of strings, and undo has to put all of it back in a single step rather than four hundred.