Replies: 1 comment 3 replies
-
That is going against of ideology of gettext and PO files and not going to be implemented. But there are solutions for both problems:
You can use an explicit id on the Trans component or
This usecase is quite common and there is are proven solution for this. Say your backend is responding with a bunch of error codes, create a map in your FE code with translations for this error codes const errorMessages = {
'WRONG_CREDENTIALS': msg`Incorrect login or password`,
'ACCOUNT_BLOCKED': msg`Your account is blocked, please contact your manager`,
}
const response = backendRequest()
if (response.error) {
const message = i18n.t(errorMessages[response.error.id] || msg`Unkown Error`);
} Let me know if you have any questions regarding this or you have a use case which is not covered by this two solutions. |
Beta Was this translation helpful? Give feedback.
-
Currently, Lingui automatically generates message IDs based on the message content, but there is no way to customize this behavior or explicitly output the IDs in
.po
files.Use Case
.po
file (which is initially sent to translators and set up in the backend system) does not contain the ID, the backend has no way to match texts to their corresponding IDs. This makes backend-driven translation handling impossible.Proposed Solutions
.po
files explicitly include the generated ID alongside the translation.Beta Was this translation helpful? Give feedback.
All reactions