@sanity/document-internationalization 0.3.5 → 0.3.7
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/CHANGELOG.md +10 -0
- package/lib/actions/index.js +18 -16
- package/lib/actions/index.js.map +1 -1
- package/lib/badges/LanguageBadge.d.ts +1 -1
- package/lib/badges/index.js +6 -18
- package/lib/badges/index.js.map +1 -1
- package/lib/constants/UiMessages.d.ts +6 -0
- package/lib/constants/index.js +7 -1
- package/lib/constants/index.js.map +1 -1
- package/lib/language-select/index.js +13 -14
- package/lib/language-select/index.js.map +1 -1
- package/lib/structure/hooks/useDocumentsInformation.d.ts +12 -12
- package/lib/structure/index.js +315 -498
- package/lib/structure/index.js.map +1 -1
- package/lib/structure/utils/fixBaseDocumentRefs.d.ts +2 -2
- package/lib/structure/utils/fixBaseLanguageMismatch.d.ts +2 -2
- package/lib/structure/utils/fixIdStructureMismatchDocuments.d.ts +2 -2
- package/lib/structure/utils/fixLanguageFields.d.ts +2 -2
- package/lib/structure/utils/fixOrphanedDocuments.d.ts +2 -2
- package/lib/structure/utils/fixTranslationRefs.d.ts +2 -2
- package/lib/types/Ti18nConfig.d.ts +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/utils/getLanguageFromDocument.d.ts +3 -0
- package/lib/utils/getTranslationsForId.d.ts +2 -2
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +7 -42
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/lib/types/Ti18nDocument.d.ts +0 -10
- package/lib/utils/batch.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v0.3.7
|
|
4
|
+
* Fixed issues with translation maintenance
|
|
5
|
+
* Added transaction overview confirmation dialog for better transparency
|
|
6
|
+
|
|
7
|
+
## v0.3.6
|
|
8
|
+
* Updates the internal logic to derive the language from the given field name as opposed to the ID.
|
|
9
|
+
|
|
10
|
+
## v0.3.5
|
|
11
|
+
* Fix how translation draft references are created so that they can be deleted
|
|
12
|
+
|
|
3
13
|
## v0.3.4
|
|
4
14
|
* Updated docs regarding V3 studio
|
|
5
15
|
|
package/lib/actions/index.js
CHANGED
|
@@ -1551,7 +1551,13 @@ var UiMessages = {
|
|
|
1551
1551
|
orphanDocuments: 'orphaned translation document(s)',
|
|
1552
1552
|
referenceBehaviorMismatch: 'document(s) with mismatched reference behaviors',
|
|
1553
1553
|
baseLanguageMismatch: 'base document(s) with mismatched language field',
|
|
1554
|
-
fix: 'Fix'
|
|
1554
|
+
fix: 'Fix',
|
|
1555
|
+
pendingTransactionDialog: {
|
|
1556
|
+
header: 'Confirm pending transaction',
|
|
1557
|
+
caution: 'Before continuing please review the transactions. Keep in mind, the translation maintenance functionality may remove or update many documents at once. It is recommended to back-up your dataset before performing data maintenance',
|
|
1558
|
+
cancel: 'Cancel',
|
|
1559
|
+
confirm: 'Confirm operation'
|
|
1560
|
+
}
|
|
1555
1561
|
},
|
|
1556
1562
|
errors: {
|
|
1557
1563
|
baseDocumentNotPublished: 'It looks like you have not published your base translation yet. When using strong references it is required to publish the base document before publishing any translated entries'
|
|
@@ -1811,17 +1817,6 @@ var getLanguagesFromOption = /*#__PURE__*/function () {
|
|
|
1811
1817
|
};
|
|
1812
1818
|
}();
|
|
1813
1819
|
|
|
1814
|
-
var getLanguageFromId = function getLanguageFromId(id) {
|
|
1815
|
-
// subpath
|
|
1816
|
-
var rx = new RegExp("".concat(I18nPrefix, "\\.[^.]+\\.([^.]+)"));
|
|
1817
|
-
var match = id.match(rx);
|
|
1818
|
-
if (match && match.length === 2) return match[1]; // delimiter
|
|
1819
|
-
|
|
1820
|
-
var split = id.split(I18nDelimiter);
|
|
1821
|
-
if (split.length > 1) return split[1];
|
|
1822
|
-
return null;
|
|
1823
|
-
};
|
|
1824
|
-
|
|
1825
1820
|
var getBaseIdFromId = function getBaseIdFromId(id) {
|
|
1826
1821
|
var nonDraftId = id.replace(/^drafts\./, ''); // subpath
|
|
1827
1822
|
|
|
@@ -1908,6 +1903,10 @@ function createSanityReference(id) {
|
|
|
1908
1903
|
} : {});
|
|
1909
1904
|
}
|
|
1910
1905
|
|
|
1906
|
+
function getLanguageFromDocument(doc, config) {
|
|
1907
|
+
return (doc === null || doc === void 0 ? void 0 : doc[config.fieldNames.lang]) || config.base || null;
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1911
1910
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1912
1911
|
|
|
1913
1912
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -1940,7 +1939,7 @@ function _updateIntlFieldsForDocument() {
|
|
|
1940
1939
|
|
|
1941
1940
|
case 11:
|
|
1942
1941
|
langs = _context.sent;
|
|
1943
|
-
languageId =
|
|
1942
|
+
languageId = getLanguageFromDocument(document, config) || ((_getBaseLanguage = getBaseLanguage(langs, config.base)) === null || _getBaseLanguage === void 0 ? void 0 : _getBaseLanguage.id); // Update I18n field for current document
|
|
1944
1943
|
|
|
1945
1944
|
currentDocumentTransaction = client.transaction();
|
|
1946
1945
|
currentDocumentTransaction.createIfNotExists({
|
|
@@ -1975,7 +1974,7 @@ function _updateIntlFieldsForDocument() {
|
|
|
1975
1974
|
|
|
1976
1975
|
if (config.referenceBehavior !== ReferenceBehavior.DISABLED) {
|
|
1977
1976
|
translatedRefs = ___default["default"].compact(translatedDocuments.map(function (doc) {
|
|
1978
|
-
var lang =
|
|
1977
|
+
var lang = getLanguageFromDocument(doc, config);
|
|
1979
1978
|
if (!lang) return null;
|
|
1980
1979
|
return _objectSpread$1({
|
|
1981
1980
|
_key: lang
|
|
@@ -2334,6 +2333,9 @@ var DuplicateWithi18nAction = function DuplicateWithi18nAction(_ref) {
|
|
|
2334
2333
|
draft = _ref.draft,
|
|
2335
2334
|
published = _ref.published;
|
|
2336
2335
|
var toast = ui.useToast();
|
|
2336
|
+
var config = React__default["default"].useMemo(function () {
|
|
2337
|
+
return getConfig(type);
|
|
2338
|
+
}, [type]);
|
|
2337
2339
|
var client = getSanityClient();
|
|
2338
2340
|
var baseDocumentId = getBaseIdFromId(id);
|
|
2339
2341
|
|
|
@@ -2367,7 +2369,7 @@ var DuplicateWithi18nAction = function DuplicateWithi18nAction(_ref) {
|
|
|
2367
2369
|
translations.forEach(function (t) {
|
|
2368
2370
|
var isDraft = t._id.startsWith('drafts.');
|
|
2369
2371
|
|
|
2370
|
-
var newId = buildDocId(dupeId,
|
|
2372
|
+
var newId = buildDocId(dupeId, getLanguageFromDocument(t, config));
|
|
2371
2373
|
transaction.create(_objectSpread(_objectSpread({}, t), {}, {
|
|
2372
2374
|
_id: isDraft ? "drafts.".concat(newId) : newId
|
|
2373
2375
|
}));
|
|
@@ -2394,7 +2396,7 @@ var DuplicateWithi18nAction = function DuplicateWithi18nAction(_ref) {
|
|
|
2394
2396
|
}
|
|
2395
2397
|
}
|
|
2396
2398
|
}, _callee, null, [[1, 13]]);
|
|
2397
|
-
})), [client, toast, baseDocumentId, type, draft, published]);
|
|
2399
|
+
})), [client, toast, config, baseDocumentId, type, draft, published]);
|
|
2398
2400
|
return {
|
|
2399
2401
|
icon: ContentCopyIcon__default["default"],
|
|
2400
2402
|
disabled: Boolean(duplicateOp.disabled) || isDuplicating,
|