Open SalahAdDin opened 4 months ago
For the List View Page title, we have that the title is not translatable, while in Strapi 4, it is translatable.
Yeah, while in the Strapi 4 the labels are translatable, in Strapi 5 they are not: Strapi 4:
const tableHeaders: TableHeader[] = React.useMemo(() => {
const headers = runHookWaterfall(INJECT_COLUMN_IN_TABLE, {
displayedHeaders,
layout,
});
const formattedHeaders = headers.displayedHeaders.map((header) => {
if (header.fieldSchema.type === 'relation') {
return {
...header,
metadatas: {
...header.metadatas,
label: formatMessage({
id: getTranslation(`containers.ListPage.table-headers.${header.name}`),
defaultMessage: header.metadatas.label,
}),
},
name: `${header.name}.${header.metadatas.mainField?.name ?? ''}`,
} satisfies TableHeader;
}
return {
...header,
metadatas: {
...header.metadatas,
label: formatMessage({
id: getTranslation(`containers.ListPage.table-headers.${header.name}`),
defaultMessage: header.metadatas.label,
}),
},
} satisfies TableHeader;
});
if (hasDraftAndPublish) {
formattedHeaders.push({
key: '__published_at_temp_key__',
name: 'publishedAt',
fieldSchema: {
type: 'custom',
},
metadatas: {
label: formatMessage({
id: getTranslation(`containers.ListPage.table-headers.publishedAt`),
defaultMessage: 'publishedAt',
}),
searchable: false,
sortable: true,
},
} satisfies TableHeader);
}
if (reviewWorkflowColumns) {
formattedHeaders.push(
...reviewWorkflowColumns.map((column) => {
return {
...column,
metadatas: {
...column.metadatas,
label: formatMessage(column.metadatas.label),
},
} satisfies TableHeader;
})
);
}
return formattedHeaders;
}, [
runHookWaterfall,
displayedHeaders,
layout,
reviewWorkflowColumns,
hasDraftAndPublish,
formatMessage,
]);
Strapi 5:
/**
* Run the waterfall and then inject our additional table headers.
*/
const tableHeaders = React.useMemo(() => {
const headers = runHookWaterfall(INJECT_COLUMN_IN_TABLE, {
displayedHeaders,
layout: list,
});
const formattedHeaders = headers.displayedHeaders.map<ListFieldLayout>((header) => {
return {
...header,
label: typeof header.label === 'string' ? header.label : formatMessage(header.label),
name: `${header.name}${header.mainField?.name ? `.${header.mainField.name}` : ''}`,
};
});
if (schema?.options?.draftAndPublish) {
formattedHeaders.push({
attribute: {
type: 'custom',
},
name: 'status',
label: formatMessage({
id: getTranslation(`containers.list.table-headers.status`),
defaultMessage: 'status',
}),
searchable: false,
sortable: false,
} satisfies ListFieldLayout);
}
return formattedHeaders;
}, [displayedHeaders, formatMessage, list, runHookWaterfall, schema?.options?.draftAndPublish]);
Why did you guys forget it?
A solution could be:
const formattedHeaders = headers.displayedHeaders.map<ListFieldLayout>((header) => {
return {
...header,
label: formatMessage({
id: getTranslation(`containers.list.table-headers.${header.name}`),
defaultMessage: header.label,
}),,
name: `${header.name}${header.mainField?.name ? `.${header.mainField.name}` : ''}`,
};
});
Following the format defined by containers.list.table-headers.status
.
What do you think?
Bug report
Required System information
Describe the bug
We are working on localizing all the content types we create for our project, we followed the existing documentation, but it seems to be deprecated.
When checking the literals on the admin panel, only the content type names are translated, but the rest of the literals are in English yet.
This does not happen in Strapi 4.
Steps to reproduce the behavior
Expected behavior
All the translation literals should be shown properly as it happens in Strapi 4.
Screenshots
Strapi 5:
Strapi 4:
Code snippets
You can check the files in this commit.
Additional context
It also has a lot of reports of missing translation literals: