Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip translations for RichText #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

asieraduriz
Copy link

@asieraduriz asieraduriz commented Jan 9, 2025

Situation

Currently, there is no way to stop receiving the texts from the richText field. This PR checks for translatorSkip property for the richText fields.

Collection config

...
{
    name: 'content',
    type: 'richText',
    required: true,
    localized: true,
    custom: {
      translatorSkip: true,
    },
    editor: lexicalEditor(),
},
...

Translator resolver

const myResolver: TranslateResolver = {
  key: 'translator-key',
  resolve: async ({localeTo, texts}) => {
    console.log("Args.texts", texts);
    const transformed = texts.map((each) => `${each} - ${localeTo}`);
    return {
      success: true,
      translatedTexts: transformed,
    };
  },
};

How it looks in CMS UI

For english locale
image

What the logs show

Args.texts [
  'RichText translatorSkip',
  'Summary',
  'Any content not to be translated'
]

With this PR rich texts will also be skipped

@asieraduriz asieraduriz changed the title RichText Skip translations for RichText Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant