thompsonsj / payload-crowdin-sync

Upload and sync localized fields from the default locale to Crowdin.
7 stars 6 forks source link

Sync translations seems to affect all locales? #187

Closed thompsonsj closed 3 months ago

thompsonsj commented 3 months ago

The Sync translations checkbox should sync only the current locale. This is as opposed to Sync all translations which syncs all locales. Recent experience suggests it impacts all locales.

Check, test, try to replicate...etc. The usual!

thompsonsj commented 3 months ago

Console logging arguments passed to updatePayloadTranslation, it's clear that this function is being called twice.

What is likely happening is that context is being set by syncTranslations and the syncAllTranslations afterChange hook is interpreting the context values as a 'good-to-go' signal!

{
  articleDirectoryId: '669a7f8047147b4efa3dd270',
  pluginOptions: {
    projectId: 323731,
    directoryId: 1169,
    token: undefined,
    localeMap: {
      da_DK: [Object],
      de_DE: [Object],
      en_GB: [Object],
      en_US: [Object],
      es_ES: [Object],
      fi_FI: [Object],
      fr_FR: [Object],
      it_IT: [Object],
      nl_NL: [Object],
      no_NO: [Object],
      sv_SE: [Object]
    },
    sourceLocale: 'en',
    tabbedUI: true,
    collections: [
      [Object],
      'content-hub-tags',
      [Object],
      'landing-page-tags',
      'policies',
      'software-reviews',
      [Object]
    ],
    slateToHtmlConfig: {
      markMap: [Object],
      elementMap: [Object],
      elementAttributeTransform: [Function: elementAttributeTransform],
      elementTransforms: [Object],
      encodeEntities: false,
      alwaysEncodeBreakingEntities: true,
      alwaysEncodeCodeEntities: false,
      convertLineBreakToBr: false,
      defaultTag: 'p'
    },
    htmlToSlateConfig: {
      elementAttributeTransform: [Function: elementAttributeTransform],
      elementTags: [Object],
      textTags: [Object],
      htmlPreProcessString: [Function: htmlPreProcessString],
      filterWhitespaceNodes: true,
      convertBrToLineBreak: true,
      trimWhiteSpace: true
    },
    pluginCollectionAdmin: {
      enableRichTextLink: false,
      enableRichTextRelationship: false,
      hidden: [Function: hidden]
    },
    lexicalBlockFolderPrefix: 'lex.'
  },
  payload: '<payload object>',
  draft: true,
  dryRun: false,
  excludeLocales: [
    'da_DK', 'en_GB',
    'en_US', 'es_ES',
    'fi_FI', 'fr_FR',
    'it_IT', 'nl_NL',
    'no_NO', 'sv_SE'
  ]
}
{
  articleDirectoryId: '669a7f8047147b4efa3dd270',
  pluginOptions: {
    projectId: 323731,
    directoryId: 1169,
    token: undefined,
    localeMap: {
      da_DK: [Object],
      de_DE: [Object],
      en_GB: [Object],
      en_US: [Object],
      es_ES: [Object],
      fi_FI: [Object],
      fr_FR: [Object],
      it_IT: [Object],
      nl_NL: [Object],
      no_NO: [Object],
      sv_SE: [Object]
    },
    sourceLocale: 'en',
    tabbedUI: true,
    collections: [
      [Object],
      'content-hub-tags',
      [Object],
      'landing-page-tags',
      'policies',
      'software-reviews',
      [Object]
    ],
    slateToHtmlConfig: {
      markMap: [Object],
      elementMap: [Object],
      elementAttributeTransform: [Function: elementAttributeTransform],
      elementTransforms: [Object],
      encodeEntities: false,
      alwaysEncodeBreakingEntities: true,
      alwaysEncodeCodeEntities: false,
      convertLineBreakToBr: false,
      defaultTag: 'p'
    },
    htmlToSlateConfig: {
      elementAttributeTransform: [Function: elementAttributeTransform],
      elementTags: [Object],
      textTags: [Object],
      htmlPreProcessString: [Function: htmlPreProcessString],
      filterWhitespaceNodes: true,
      convertBrToLineBreak: true,
      trimWhiteSpace: true
    },
    pluginCollectionAdmin: {
      enableRichTextLink: false,
      enableRichTextRelationship: false,
      hidden: [Function: hidden]
    },
    lexicalBlockFolderPrefix: 'lex.'
  },
  payload: '<payload object>',
  draft: true,
  dryRun: false,
  excludeLocales: undefined
}
thompsonsj commented 3 months ago

https://github.com/thompsonsj/payload-crowdin-sync/pull/188 fixes this. Tested manually on a production install.