gt-sanity 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +9 -3
- package/src/utils/__tests__/locales.test.ts +48 -0
- package/src/utils/locales.ts +20 -0
package/dist/index.cjs
CHANGED
|
@@ -3611,7 +3611,13 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3611
3611
|
}
|
|
3612
3612
|
)
|
|
3613
3613
|
] });
|
|
3614
|
-
}, TranslationsTool = () => /* @__PURE__ */ jsxRuntime.jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsToolContent, {}) }) })
|
|
3614
|
+
}, TranslationsTool = () => /* @__PURE__ */ jsxRuntime.jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsToolContent, {}) }) });
|
|
3615
|
+
function resolveTargetLocales(sourceLocale, locales) {
|
|
3616
|
+
return Array.from(new Set(locales)).filter(
|
|
3617
|
+
(locale) => locale !== sourceLocale
|
|
3618
|
+
);
|
|
3619
|
+
}
|
|
3620
|
+
const TranslationTab = (props) => {
|
|
3615
3621
|
const { displayed } = props.document;
|
|
3616
3622
|
return /* @__PURE__ */ jsxRuntime.jsx(BaseTranslationWrapper, { showContainer: !1, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationsProvider, { singleDocument: displayed, children: /* @__PURE__ */ jsxRuntime.jsx(TranslationView, {}) }) });
|
|
3617
3623
|
}, gtPlugin = sanity.definePlugin(
|
|
@@ -3641,14 +3647,14 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3641
3647
|
fieldLevelDocuments,
|
|
3642
3648
|
preserveExistingTranslations = !1
|
|
3643
3649
|
}) => {
|
|
3644
|
-
const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? internal.libraryDefaultLocale, normalizeFilters = (entries) => entries?.map((entry) => typeof entry == "string" ? { type: entry } : entry).filter((filter) => filter.documentId || filter.type), normalizedTranslateDocuments = normalizeFilters(translateDocuments), normalizedFieldLevelDocuments = normalizeFilters(fieldLevelDocuments) ?? [], rawFieldLevelConfig = internationalizedArray2 ?? fieldLevelLocalization;
|
|
3650
|
+
const resolvedSourceLocale = sourceLocale ?? defaultLocale ?? internal.libraryDefaultLocale, targetLocales = resolveTargetLocales(resolvedSourceLocale, locales), normalizeFilters = (entries) => entries?.map((entry) => typeof entry == "string" ? { type: entry } : entry).filter((filter) => filter.documentId || filter.type), normalizedTranslateDocuments = normalizeFilters(translateDocuments), normalizedFieldLevelDocuments = normalizeFilters(fieldLevelDocuments) ?? [], rawFieldLevelConfig = internationalizedArray2 ?? fieldLevelLocalization;
|
|
3645
3651
|
warnOnRemovedFieldLevelOptions(rawFieldLevelConfig);
|
|
3646
3652
|
const fieldLevelConfig = resolveFieldLevelConfig(rawFieldLevelConfig);
|
|
3647
3653
|
pluginConfig.init(
|
|
3648
3654
|
secretsNamespace,
|
|
3649
3655
|
languageField,
|
|
3650
3656
|
resolvedSourceLocale,
|
|
3651
|
-
|
|
3657
|
+
targetLocales,
|
|
3652
3658
|
singletons || [],
|
|
3653
3659
|
// singletons is a string array of singleton document ids
|
|
3654
3660
|
singletonMapping || ((sourceDocumentId, locale) => `${sourceDocumentId}-${locale}`),
|
|
@@ -3675,7 +3681,7 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3675
3681
|
if (showDocumentInternationalization) {
|
|
3676
3682
|
const schemaTypes = normalizedTranslateDocuments?.map((filter) => filter.type).filter((type) => !!type).filter((type) => !arrayLocalizedTypes.has(type)) ?? [];
|
|
3677
3683
|
if (schemaTypes.length > 0) {
|
|
3678
|
-
const supportedLanguages = [resolvedSourceLocale, ...
|
|
3684
|
+
const supportedLanguages = [resolvedSourceLocale, ...targetLocales].map((locale) => {
|
|
3679
3685
|
const props = generaltranslation.getLocaleProperties(
|
|
3680
3686
|
locale,
|
|
3681
3687
|
resolvedSourceLocale,
|
|
@@ -3703,7 +3709,7 @@ const DocumentRow = ({ document: document2 }) => {
|
|
|
3703
3709
|
buildInternationalizedArrayPlugin(
|
|
3704
3710
|
fieldLevelConfig,
|
|
3705
3711
|
resolvedSourceLocale,
|
|
3706
|
-
|
|
3712
|
+
targetLocales,
|
|
3707
3713
|
customMapping
|
|
3708
3714
|
)
|
|
3709
3715
|
), {
|