mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] compiler: translatableAttributes can be added/removed
This commit is contained in:
committed by
Aaron Bohy
parent
140818b5f9
commit
2c1226d737
@@ -214,14 +214,24 @@ export class CodeGenerator {
|
||||
templateName?: string;
|
||||
dev: boolean;
|
||||
translateFn: (s: string) => string;
|
||||
translatableAttributes: string[];
|
||||
translatableAttributes: string[] = TRANSLATABLE_ATTRS;
|
||||
ast: AST;
|
||||
staticCalls: { id: string; template: string }[] = [];
|
||||
helpers: Set<string> = new Set();
|
||||
|
||||
constructor(ast: AST, options: CodeGenOptions) {
|
||||
this.translateFn = options.translateFn || ((s: string) => s);
|
||||
this.translatableAttributes = options.translatableAttributes || TRANSLATABLE_ATTRS;
|
||||
if (options.translatableAttributes) {
|
||||
const attrs = new Set(TRANSLATABLE_ATTRS);
|
||||
for (let attr of options.translatableAttributes) {
|
||||
if (attr.startsWith("-")) {
|
||||
attrs.delete(attr.slice(1));
|
||||
} else {
|
||||
attrs.add(attr);
|
||||
}
|
||||
}
|
||||
this.translatableAttributes = [...attrs];
|
||||
}
|
||||
this.hasSafeContext = options.hasSafeContext || false;
|
||||
this.dev = options.dev || false;
|
||||
this.ast = ast;
|
||||
|
||||
Reference in New Issue
Block a user