Skip to content

Conversation

@jeremydw
Copy link
Member

This PR adds two major features:

  1. Metadata on translatable fields
  2. Quick AI translations

The current metadata options are:

  1. Description - Included in translation requests (in ARB files and AI translations)
  2. "Do Not Translate" checkbox. If this is checked, the string isn't extracted or sent for translation.

The metadata is stored as:

{
  fieldName: 'Value',
  @fieldName: {
    translations: {
      doNotTranslate: true,
      description: 'Foo bar'
    }
  }
}

When "do not translate" is checked the icon in the doc editor switches to red with a strike through it.

image image image image

@jeremydw jeremydw requested a review from stevenle January 30, 2026 04:37
@stevenle
Copy link
Member

I think I would prefer a flatter structure for metadata, and the enableFoo/disableFoo nomenclature. E.g.:

{
  fieldName: 'Value',
  @fieldName: {
    disableTranslations: true,
    description: 'Lorem ipsum'
  }
}

@stevenle
Copy link
Member

Couple of other notes:

  • the purple ai icon would be a new color for the cms, i don't think purple is used anywhere else. i think i'd prefer our action icons to be consistent, although this is a useful feature i don't think it needs the prominence of a strong color here
  • the red strikeout in the icon also feels a little too prominent for me, i think having it strikedout with the normal black color is good enough (with a tooltip that says "translations are disabled").

@stevenle
Copy link
Member

(also noting that one of the unit tests are failing)

@jeremydw
Copy link
Member Author

Done - all should be updated now


const responseText = res.text || '{}';

// Try to extract JSON from the response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: comments should end in punctuation.

// Try to extract JSON from the response
let jsonText = responseText.trim();

// Remove markdown code blocks if present
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be worth extracting to its own function and adding unit tests for it.

'Do not include any markdown formatting, code blocks, or explanatory text.',
].join('\n');

let userPrompt = `Source text: "${options.sourceText}"\n\n`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loop-based string concatentation is expensive, use arrays for building strings

options.existingTranslations &&
Object.keys(options.existingTranslations).length > 0
) {
userPrompt += 'Existing translations for reference:\n';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of providing it with existing translations? Can we ignore locales we already have translations for in this request, to avoid overwriting existing translations?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing it with the existing translations was my idea to help it establish more context; e.g. if you have 10 locales translated and one missing; the tone can be inferred from the existing translations to make the missing one more accurate.

It won't overwrite any existing translations (it just uses them to improve the style of the translations it's getting). I've added a comment that clarifies that to EditTranslationsModal.

@jeremydw
Copy link
Member Author

Done - updated

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.

3 participants