Commit a08f5d0a authored by Diegodlh's avatar Diegodlh
Browse files

Template configuration translateWith should output translations for non-applicable templates

parent 1edc51f7
......@@ -161,17 +161,21 @@ export class Domain {
baseCitation?: MediaWikiBaseFieldCitation
): Translation {
// create citoid citations from output
const citation = this.makeCitation(
templateOutput.outputs,
// With this we are setting the output citation's URL to that of the
// target Webpage object, which does not follow redirects.
// We may change this to the final response URL, but there may be cases
// where we do not want to do that (see T210871).
// Alternatively, we may let users manually change this using a URL
// template field.
templateOutput.target.url.href,
baseCitation
);
let citation;
if (templateOutput.applicable) {
// only make citations for applicable template outputs
citation = this.makeCitation(
templateOutput.outputs,
// With this we are setting the output citation's URL to that of the
// target Webpage object, which does not follow redirects.
// We may change this to the final response URL, but there may be cases
// where we do not want to do that (see T210871).
// Alternatively, we may let users manually change this using a URL
// template field.
templateOutput.target.url.href,
baseCitation
);
}
let fields: FieldInfo[] | undefined;
if (templateFieldInfo) {
......@@ -306,7 +310,7 @@ type Translation = {
path: string | undefined; // undefined for fallback template
fields?: FieldInfo[];
};
citation: WebToCitCitation;
citation: WebToCitCitation | undefined;
timestamp: string;
};
......
......@@ -211,10 +211,8 @@ export class TemplateConfiguration extends DomainConfiguration<
for (const template of templates) {
// todo: catch errors?
const output = await template.translate(target);
if (output.applicable) {
outputs.push(output);
break;
}
outputs.push(output);
if (output.applicable) break;
}
}
return outputs;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment