Single entry based translations.
{
"my_api_result": {
"en": "This is easy.",
"de": "Alles im selben Eintrag.",
"fr": "Je ne parle pas francais."
}
}This plugin is currently in alpha. Contributions are welcome!
Beside Strapi beeing one of the best CMS out there, it gets challenging when it comes to internationalization. As every translation is stored as seperate entry in the database, working with relations in many languages gets a real pain.
This plugin introduces custom fields for text and rich text that store all translations within a single entry. This reduces the need for enabling Strapi's i18n and therefore makes working with translateable relations reasonable.
Install the plugin:
# with npm
npm i @klammerzu/strapi-internationalized-fields
# with yarn
yarn add @klammerzu/strapi-internationalized-fieldsAdd this to your config/plugins.[js|ts] file:
export default ({ env }) => ({
// ...
'internationalized-fields': {
enabled: true,
},
});Then build the app:
npm run buildYou now can find the Internationalized Text field unter Custom when adding new fields.
Behind the scenes the plugin uses Strapi's json field type. The locales will be delivered automatically, without further configuration or population. The resulting response will look like this:
{
"field_name": {
"en": "My field value.",
"de": "Irgendwas auf Deutsch.",
"fr": "Je ne parle pas francais."
}
}Rich text object must be back-converted using JSON.parse().
Look that you have the i18n plugin enabled. There is no futher configuration needed. The plugin automatically detects the configured languages.
Don't use internationalized-fields on models with enabled Internationalization as they conflict each other.
You can get the basic concepts in the CONTRIBUTE.md file. Feel free to fork and make pull requests to this plugin. All input is welcome - thanks for all contributions so far!
I you like this project, please give it a star.