Skip to content

BeechCMS


BeechCMS / @beechcms/core / applyLocalizedPatch

Function: applyLocalizedPatch() ​

applyLocalizedPatch(branch, stored, write, config): LocalizedDictionary | null

Merges a write into the value stored for a localized branch. The write path's only way to persist a localized value, so a translation the write does not mention is never dropped (brief §2):

  • write === null clears the whole field (an explicit null keeps its pre-localization meaning);
  • otherwise the write is normalised with toLocalizedPatch: every registered locale it names overwrites that locale, a null entry clears that locale only, and every other stored locale — including ones no longer registered — is kept as-is;
  • a stored legacy value (written before the branch became localized) is the default-locale value.

Parameters ​

branch ​

Pick<Branch, "type" | "localized">

stored ​

unknown

write ​

unknown

config ​

LocaleConfig

Returns ​

LocalizedDictionary | null

The compacted dictionary, or null when no locale keeps a value.