System Information
- Strapi Version: 5.12.3
- Operating System: Libux Debian
- Database: sqlite
- Node Version: 18.17.1
- PNPM Version: 5.12.3
Good afternoon everyone! I’ve encountered the following problem when using localization in Strapi: I get the error message: ‘Missing message: “content-manager.content-types.undefined.slug” for locale “uk”, using default message (slug) as fallback.’ As far as I understand, my key should be ‘content-manager.content-types.api::post.post.title’. However, it seems that the localizer doesn’t understand or doesn’t recognize the created ‘Post’ collection model. It only has two fields: ‘title’ and ‘slug’. The error occurs for both keys. I’ve added these supposed keys to app.ts
, but there’s no result. Could you please help me figure out what I’m doing wrong or what I’m missing?
Му app.ts
import type { StrapiApp } from '@strapi/strapi/admin';
import {registerTranslations} from "./helpers/registerTranslations";
const locales = ['uk'];
const translations = await registerTranslations({ locales });
export default {
config: {
locales,
translations
},
bootstrap(app: StrapiApp) {
console.log(app);
},
};
registerTranslations.ts
type TranslationData = Record<string, Object>;
export const registerTranslations = async ({
locales,
}: {
locales: Array<string>;
}) => {
const results = await Promise.all(
locales.map(async (locale) => {
try {
const response = await import(`../transtations/${locale}.json`);
console.log(response);
const { default: data } = response
return {
locale,
data,
};
} catch {
return {
locale,
data: {},
};
}
})
);
let importedTranslations: TranslationData = {};
results.forEach(({ locale, data }) => {
importedTranslations[locale] = data;
});
return importedTranslations;
};
createt shema admin/src/api/post/content-types/post/schema.json
{
"kind": "collectionType",
"collectionName": "posts",
"info": {
"singularName": "post",
"pluralName": "posts",
"displayName": "Post"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {
"i18n": {
"localized": true
}
},
"attributes": {
"title": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
}
}
},
"slug": {
"type": "uid",
"targetField": "title"
}
}
}
This is what the admin panel looks like.