Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as babelTtagPlugin from "babel-plugin-ttag";
import * as babelPluginDecorators from "@babel/plugin-proposal-decorators";

export const defaultPlugins: ConfigItem[] = [
[babelPluginDecorators, { legacy: true }],
[babelPluginDecorators, { version: "2023-11" }],
exportDefaultFromPlugin,
];

Expand Down
12 changes: 12 additions & 0 deletions tests/commands/__snapshots__/test_extract.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ msgstr \\"\\"
"
`;

exports[`extract with decorator 1`] = `
"msgid \\"\\"
msgstr \\"\\"
\\"Content-Type: text/plain; charset=utf-8\\\\n\\"
\\"Plural-Forms: nplurals=2; plural=(n!=1);\\\\n\\"

#: tests/fixtures/testDecoratorParse.js:3
msgid \\"hi from a module with decorators\\"
msgstr \\"\\"
"
`;

exports[`should extract in the alphabetical order (sortByMsgid) 1`] = `
"msgid \\"\\"
msgstr \\"\\"
Expand Down
10 changes: 10 additions & 0 deletions tests/commands/test_extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const baseTestPath = path.resolve(__dirname, "../fixtures/baseTest");
const sortByMsgidPath = path.resolve(__dirname, "../fixtures/sortByMsgidTest");
const ukTestPath = path.resolve(__dirname, "../fixtures/ukLocaleTest");
const jsxPath = path.resolve(__dirname, "../fixtures/testJSXParse.jsx");
const decoratorPath = path.resolve(
__dirname,
"../fixtures/testDecoratorParse.js"
);
const vuePath = path.resolve(__dirname, "../fixtures/vueTest/testVueParse.vue");
const vuePath2 = path.resolve(
__dirname,
Expand Down Expand Up @@ -48,6 +52,12 @@ test("extract from jsx", () => {
expect(result).toMatchSnapshot();
});

test("extract with decorator", () => {
execSync(`ts-node src/index.ts extract -o ${potPath} ${decoratorPath}`);
const result = fs.readFileSync(potPath).toString();
expect(result).toMatchSnapshot();
});

test("extract from vue", () => {
execSync(`ts-node src/index.ts extract -o ${potPath} ${vuePath}`);
const result = fs.readFileSync(potPath).toString();
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/testDecoratorParse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { t } from 'ttag';

const x = t`hi from a module with decorators`

@myClassDecorator
class MyClass {
@myFieldDecorator myField;
@myAccessorDecortor accessor myAccessor;
@myGetterDecorator get myGetter() { }
@mySetterDecorator set mySetter(x) { }
@methodDecorator hi() { }
}