Loading...
Loading...
Provide additional context for messages based on the codebase and the context of the message to improve the quality of the translations.
npx skill4agent add lingui/skills enhanced-message-contextcomment{count}{name}commenttimport { t } from "@lingui/core/macro";
// With comment
const backLabel = t({
comment: "Button in the navigation bar that returns to the previous page",
message: "Back",
});
// With comment and variable
const uploadSuccess = t({
comment: "Success message showing the name of the file that was uploaded",
message: `File ${fileName} uploaded successfully`,
});Transimport { Trans } from "@lingui/react/macro";
// With comment
<Trans comment="Button that deletes the selected email message">Delete</Trans>
// With comment in a component
<button>
<Trans comment="Label for button that saves changes to user profile">
Save
</Trans>
</button>defineMessagemsgimport { defineMessage } from "@lingui/core/macro";
const messages = {
deleteButton: defineMessage({
comment: "Button that permanently removes the item from the database",
message: "Delete",
}),
statusLabel: defineMessage({
comment: "Shows whether the service is currently operational. Values: 'Active', 'Inactive', 'Pending'",
message: "Status: {status}",
}),
};<button onClick={goBack}>
<Trans>Back</Trans>
</button><button onClick={goBack}>
<Trans comment="Button in the toolbar that navigates to the previous page">
Back
</Trans>
</button>const columns = [
{ key: "name", label: t`Name` },
{ key: "status", label: t`Status` },
];const columns = [
{
key: "name",
label: t({
comment: "Column header in the projects table showing project name",
message: "Name"
})
},
{
key: "status",
label: t({
comment: "Column header showing project status: Active, Inactive, or Archived",
message: "Status"
})
},
{
key: "created",
label: t({
comment: "Column header showing the date when the project was created",
message: "Created"
})
},
];<button onClick={handlePost}>
<Trans>Post</Trans>
</button><button onClick={handlePost}>
<Trans comment="Button that publishes the content. Used as a verb (to post), not a noun (a post)">
Post
</Trans>
</button>const message = t`${count} items selected`;const message = t({
comment: "Shows the number of email messages currently selected in the inbox",
message: `${count} items selected`,
});// Good - no comment needed, message is clear
<Trans>
Your password must contain at least 8 characters, including one uppercase letter and one number.
</Trans>comment