chore: adjusts translation generation
This commit is contained in:
@@ -9,7 +9,13 @@
|
||||
"allowImportingTsExtensions": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": ["src/**/*.spec.js", "src/**/*.spec.jsx", "src/**/*.spec.ts", "src/**/*.spec.tsx"],
|
||||
"exclude": [
|
||||
"src/**/*.spec.js",
|
||||
"src/**/*.spec.jsx",
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.spec.tsx",
|
||||
"src/**/*.json"
|
||||
],
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
||||
"references": [
|
||||
{ "path": "../payload" },
|
||||
|
||||
@@ -508,7 +508,7 @@ export type RichTextField<
|
||||
ExtraProperties = {},
|
||||
> = FieldBase & {
|
||||
admin?: Admin
|
||||
editor?: RichTextAdapter<Value, AdapterProps, AdapterProps>
|
||||
editor: RichTextAdapter<Value, AdapterProps, AdapterProps>
|
||||
type: 'richText'
|
||||
} & ExtraProperties
|
||||
|
||||
|
||||
2
packages/translations/.gitignore
vendored
2
packages/translations/.gitignore
vendored
@@ -1 +1 @@
|
||||
!dist
|
||||
./dist
|
||||
|
||||
63
packages/translations/dist/api/index.d.ts
vendored
63
packages/translations/dist/api/index.d.ts
vendored
@@ -1,63 +0,0 @@
|
||||
export namespace translations {
|
||||
export { ar };
|
||||
export { az };
|
||||
export { bg };
|
||||
export { cs };
|
||||
export { de };
|
||||
export { en };
|
||||
export { es };
|
||||
export { fa };
|
||||
export { fr };
|
||||
export { hr };
|
||||
export { hu };
|
||||
export { it };
|
||||
export { ja };
|
||||
export { ko };
|
||||
export { my };
|
||||
export { nb };
|
||||
export { nl };
|
||||
export { pl };
|
||||
export { pt };
|
||||
export { ro };
|
||||
export { rs };
|
||||
export { rsLatin };
|
||||
export { ru };
|
||||
export { sv };
|
||||
export { th };
|
||||
export { tr };
|
||||
export { ua };
|
||||
export { vi };
|
||||
export { zh };
|
||||
export { zhTw };
|
||||
}
|
||||
import ar from "./ar.json";
|
||||
import az from "./az.json";
|
||||
import bg from "./bg.json";
|
||||
import cs from "./cs.json";
|
||||
import de from "./de.json";
|
||||
import en from "./en.json";
|
||||
import es from "./es.json";
|
||||
import fa from "./fa.json";
|
||||
import fr from "./fr.json";
|
||||
import hr from "./hr.json";
|
||||
import hu from "./hu.json";
|
||||
import it from "./it.json";
|
||||
import ja from "./ja.json";
|
||||
import ko from "./ko.json";
|
||||
import my from "./my.json";
|
||||
import nb from "./nb.json";
|
||||
import nl from "./nl.json";
|
||||
import pl from "./pl.json";
|
||||
import pt from "./pt.json";
|
||||
import ro from "./ro.json";
|
||||
import rs from "./rs.json";
|
||||
import rsLatin from "./rs-latin.json";
|
||||
import ru from "./ru.json";
|
||||
import sv from "./sv.json";
|
||||
import th from "./th.json";
|
||||
import tr from "./tr.json";
|
||||
import ua from "./ua.json";
|
||||
import vi from "./vi.json";
|
||||
import zh from "./zh.json";
|
||||
import zhTw from "./zh-tw.json";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAAe,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;oBACN,iBAAiB;eACtB,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;iBACT,cAAc"}
|
||||
62
packages/translations/dist/api/index.js
vendored
62
packages/translations/dist/api/index.js
vendored
@@ -1,62 +0,0 @@
|
||||
import ar from "./ar.json";
|
||||
import az from "./az.json";
|
||||
import bg from "./bg.json";
|
||||
import cs from "./cs.json";
|
||||
import de from "./de.json";
|
||||
import en from "./en.json";
|
||||
import es from "./es.json";
|
||||
import fa from "./fa.json";
|
||||
import fr from "./fr.json";
|
||||
import hr from "./hr.json";
|
||||
import hu from "./hu.json";
|
||||
import it from "./it.json";
|
||||
import ja from "./ja.json";
|
||||
import ko from "./ko.json";
|
||||
import my from "./my.json";
|
||||
import nb from "./nb.json";
|
||||
import nl from "./nl.json";
|
||||
import pl from "./pl.json";
|
||||
import pt from "./pt.json";
|
||||
import ro from "./ro.json";
|
||||
import rs from "./rs.json";
|
||||
import rsLatin from "./rs-latin.json";
|
||||
import ru from "./ru.json";
|
||||
import sv from "./sv.json";
|
||||
import th from "./th.json";
|
||||
import tr from "./tr.json";
|
||||
import ua from "./ua.json";
|
||||
import vi from "./vi.json";
|
||||
import zh from "./zh.json";
|
||||
import zhTw from "./zh-tw.json";
|
||||
export var translations = {
|
||||
ar: ar,
|
||||
az: az,
|
||||
bg: bg,
|
||||
cs: cs,
|
||||
de: de,
|
||||
en: en,
|
||||
es: es,
|
||||
fa: fa,
|
||||
fr: fr,
|
||||
hr: hr,
|
||||
hu: hu,
|
||||
it: it,
|
||||
ja: ja,
|
||||
ko: ko,
|
||||
my: my,
|
||||
nb: nb,
|
||||
nl: nl,
|
||||
pl: pl,
|
||||
pt: pt,
|
||||
ro: ro,
|
||||
rs: rs,
|
||||
rsLatin: rsLatin,
|
||||
ru: ru,
|
||||
sv: sv,
|
||||
th: th,
|
||||
tr: tr,
|
||||
ua: ua,
|
||||
vi: vi,
|
||||
zh: zh,
|
||||
zhTw: zhTw
|
||||
};
|
||||
1
packages/translations/dist/build.d.ts
vendored
1
packages/translations/dist/build.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export {};
|
||||
476
packages/translations/dist/build.js
vendored
476
packages/translations/dist/build.js
vendored
@@ -1,476 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const transpileAndCopy_1 = require("./utilities/transpileAndCopy");
|
||||
const ensureDirExists_1 = require("./utilities/ensureDirExists");
|
||||
const serverTranslationKeys = [
|
||||
'authentication:account',
|
||||
'authentication:api',
|
||||
'authentication:apiKey',
|
||||
'authentication:enableAPIKey',
|
||||
'authentication:newAccountCreated',
|
||||
'authentication:resetYourPassword',
|
||||
'authentication:verifyYourEmail',
|
||||
'authentication:youAreReceivingResetPassword',
|
||||
'authentication:youDidNotRequestPassword',
|
||||
'authentication:verified',
|
||||
'fields:textToDisplay',
|
||||
'fields:linkType',
|
||||
'fields:chooseBetweenCustomTextOrDocument',
|
||||
'fields:customURL',
|
||||
'fields:internalLink',
|
||||
'fields:enterURL',
|
||||
'fields:chooseDocumentToLink',
|
||||
'fields:openInNewTab',
|
||||
'general:createdAt',
|
||||
'general:deletedCountSuccessfully',
|
||||
'general:deletedSuccessfully',
|
||||
'general:email',
|
||||
'general:notFound',
|
||||
'general:successfullyCreated',
|
||||
'general:thisLanguage',
|
||||
'general:user',
|
||||
'general:users',
|
||||
'general:updatedAt',
|
||||
'general:updatedSuccessfully',
|
||||
'general:updatedCountSuccessfully',
|
||||
'general:value',
|
||||
'error:deletingFile',
|
||||
'error:emailOrPasswordIncorrect',
|
||||
'error:followingFieldsInvalid',
|
||||
'error:noFilesUploaded',
|
||||
'error:notAllowedToPerformAction',
|
||||
'error:problemUploadingFile',
|
||||
'error:unableToDeleteCount',
|
||||
'error:unableToUpdateCount',
|
||||
'error:unauthorized',
|
||||
'error:userLocked',
|
||||
'error:valueMustBeUnique',
|
||||
'upload:width',
|
||||
'upload:height',
|
||||
'upload:fileSize',
|
||||
'upload:fileName',
|
||||
'upload:sizes',
|
||||
'validation:emailAddress',
|
||||
'validation:enterNumber',
|
||||
'validation:greaterThanMax',
|
||||
'validation:invalidInput',
|
||||
'validation:invalidSelection',
|
||||
'validation:invalidSelections',
|
||||
'validation:lessThanMin',
|
||||
'validation:longerThanMin',
|
||||
'validation:notValidDate',
|
||||
'validation:required',
|
||||
'validation:requiresNoMoreThan',
|
||||
'validation:requiresTwoNumbers',
|
||||
'validation:shorterThanMax',
|
||||
'validation:trueOrFalse',
|
||||
'validation:validUploadID',
|
||||
'version:autosavedSuccessfully',
|
||||
'version:draftSavedSuccessfully',
|
||||
'version:restoredSuccessfully',
|
||||
'version:draft',
|
||||
'version:published',
|
||||
'version:status',
|
||||
];
|
||||
const clientTranslationKeys = [
|
||||
'authentication:account',
|
||||
'authentication:accountOfCurrentUser',
|
||||
'authentication:alreadyActivated',
|
||||
'authentication:alreadyLoggedIn',
|
||||
'authentication:backToLogin',
|
||||
'authentication:beginCreateFirstUser',
|
||||
'authentication:changePassword',
|
||||
'authentication:confirmGeneration',
|
||||
'authentication:confirmPassword',
|
||||
'authentication:emailNotValid',
|
||||
'authentication:emailSent',
|
||||
'authentication:enableAPIKey',
|
||||
'authentication:failedToUnlock',
|
||||
'authentication:forceUnlock',
|
||||
'authentication:forgotPassword',
|
||||
'authentication:forgotPasswordEmailInstructions',
|
||||
'authentication:forgotPasswordQuestion',
|
||||
'authentication:generate',
|
||||
'authentication:generateNewAPIKey',
|
||||
'authentication:logBackIn',
|
||||
'authentication:loggedOutInactivity',
|
||||
'authentication:loggedOutSuccessfully',
|
||||
'authentication:login',
|
||||
'authentication:logOut',
|
||||
'authentication:logout',
|
||||
'authentication:logoutUser',
|
||||
'authentication:newAPIKeyGenerated',
|
||||
'authentication:newPassword',
|
||||
'authentication:resetPassword',
|
||||
'authentication:stayLoggedIn',
|
||||
'authentication:successfullyUnlocked',
|
||||
'authentication:unableToVerify',
|
||||
'authentication:verified',
|
||||
'authentication:verifiedSuccessfully',
|
||||
'authentication:verify',
|
||||
'authentication:verifyUser',
|
||||
'authentication:youAreInactive',
|
||||
'error:autosaving',
|
||||
'error:correctInvalidFields',
|
||||
'error:deletingTitle',
|
||||
'error:loadingDocument',
|
||||
'error:localesNotSaved',
|
||||
'error:noMatchedField',
|
||||
'error:notAllowedToAccessPage',
|
||||
'error:previewing',
|
||||
'error:unableToDeleteCount',
|
||||
'error:unableToUpdateCount',
|
||||
'error:unknown',
|
||||
'error:unspecific',
|
||||
'fields:addLabel',
|
||||
'fields:addNew',
|
||||
'fields:addNewLabel',
|
||||
'fields:block',
|
||||
'fields:blocks',
|
||||
'fields:blockType',
|
||||
'fields:chooseFromExisting',
|
||||
'fields:collapseAll',
|
||||
'fields:editLink',
|
||||
'fields:addLink',
|
||||
'fields:itemsAndMore',
|
||||
'fields:latitude',
|
||||
'fields:longitude',
|
||||
'fields:passwordsDoNotMatch',
|
||||
'fields:searchForBlock',
|
||||
'fields:selectFieldsToEdit',
|
||||
'fields:showAll',
|
||||
'fields:swapRelationship',
|
||||
'fields:uploadNewLabel',
|
||||
'fields:swapUpload',
|
||||
'fields:addUpload',
|
||||
'fields:editRelationship',
|
||||
'fields:removeUpload',
|
||||
'fields:saveChanges',
|
||||
'fields:addRelationship',
|
||||
'fields:removeRelationship',
|
||||
'fields:labelRelationship',
|
||||
'general:aboutToDeleteCount',
|
||||
'general:aboutToDelete',
|
||||
'general:addBelow',
|
||||
'general:addFilter',
|
||||
'general:adminTheme',
|
||||
'general:and',
|
||||
'general:applyChanges',
|
||||
'general:ascending',
|
||||
'general:automatic',
|
||||
'general:backToDashboard',
|
||||
'general:cancel',
|
||||
'general:changesNotSaved',
|
||||
'general:close',
|
||||
'general:collapse',
|
||||
'general:collections',
|
||||
'general:columns',
|
||||
'general:columnToSort',
|
||||
'general:confirm',
|
||||
'general:confirmDeletion',
|
||||
'general:confirmDuplication',
|
||||
'general:copied',
|
||||
'general:copy',
|
||||
'general:create',
|
||||
'general:created',
|
||||
'general:createNew',
|
||||
'general:createNewLabel',
|
||||
'general:creating',
|
||||
'general:creatingNewLabel',
|
||||
'general:dark',
|
||||
'general:dashboard',
|
||||
'general:delete',
|
||||
'general:deletedCountSuccessfully',
|
||||
'general:deleting',
|
||||
'general:descending',
|
||||
'general:deselectAllRows',
|
||||
'general:duplicate',
|
||||
'general:duplicateWithoutSaving',
|
||||
'general:edit',
|
||||
'general:editing',
|
||||
'general:editingLabel',
|
||||
'general:editLabel',
|
||||
'general:email',
|
||||
'general:emailAddress',
|
||||
'general:enterAValue',
|
||||
'general:error',
|
||||
'general:errors',
|
||||
'general:fallbackToDefaultLocale',
|
||||
'general:filters',
|
||||
'general:filterWhere',
|
||||
'general:globals',
|
||||
'general:language',
|
||||
'general:lastModified',
|
||||
'general:lastSavedAgo',
|
||||
'general:leaveAnyway',
|
||||
'general:leaveWithoutSaving',
|
||||
'general:light',
|
||||
'general:livePreview',
|
||||
'general:loading',
|
||||
'general:locale',
|
||||
'general:menu',
|
||||
'general:moveDown',
|
||||
'general:moveUp',
|
||||
'general:noFiltersSet',
|
||||
'general:noLabel',
|
||||
'general:none',
|
||||
'general:noOptions',
|
||||
'general:noResults',
|
||||
'general:notFound',
|
||||
'general:nothingFound',
|
||||
'general:noValue',
|
||||
'general:of',
|
||||
'general:open',
|
||||
'general:or',
|
||||
'general:order',
|
||||
'general:pageNotFound',
|
||||
'general:password',
|
||||
'general:payloadSettings',
|
||||
'general:perPage',
|
||||
'general:remove',
|
||||
'general:reset',
|
||||
'general:row',
|
||||
'general:rows',
|
||||
'general:save',
|
||||
'general:saving',
|
||||
'general:searchBy',
|
||||
'general:selectAll',
|
||||
'general:selectAllRows',
|
||||
'general:selectedCount',
|
||||
'general:selectValue',
|
||||
'general:showAllLabel',
|
||||
'general:sorryNotFound',
|
||||
'general:sort',
|
||||
'general:sortByLabelDirection',
|
||||
'general:stayOnThisPage',
|
||||
'general:submissionSuccessful',
|
||||
'general:submit',
|
||||
'general:successfullyCreated',
|
||||
'general:successfullyDeleted',
|
||||
'general:successfullyDuplicated',
|
||||
'general:thisLanguage',
|
||||
'general:titleDeleted',
|
||||
'general:toggleBlock',
|
||||
'general:unauthorized',
|
||||
'general:unsavedChangesDuplicate',
|
||||
'general:untitled',
|
||||
'general:updatedAt',
|
||||
'general:updatedCountSuccessfully',
|
||||
'general:updatedSuccessfully',
|
||||
'general:updating',
|
||||
'general:welcome',
|
||||
'operators:equals',
|
||||
'operators:exists',
|
||||
'operators:isNotIn',
|
||||
'operators:isIn',
|
||||
'operators:contains',
|
||||
'operators:isLike',
|
||||
'operators:isNotEqualTo',
|
||||
'operators:near',
|
||||
'operators:isGreaterThan',
|
||||
'operators:isLessThan',
|
||||
'operators:isGreaterThanOrEqualTo',
|
||||
'operators:isLessThanOrEqualTo',
|
||||
'upload:crop',
|
||||
'upload:cropToolDescription',
|
||||
'upload:dragAndDrop',
|
||||
'upload:editImage',
|
||||
'upload:focalPoint',
|
||||
'upload:focalPointDescription',
|
||||
'upload:height',
|
||||
'upload:previewSizes',
|
||||
'upload:selectCollectionToBrowse',
|
||||
'upload:selectFile',
|
||||
'upload:setCropArea',
|
||||
'upload:setFocalPoint',
|
||||
'upload:sizesFor',
|
||||
'upload:width',
|
||||
'validation:fieldHasNo',
|
||||
'validation:limitReached',
|
||||
'validation:required',
|
||||
'validation:requiresAtLeast',
|
||||
'version:aboutToPublishSelection',
|
||||
'version:aboutToRestore',
|
||||
'version:aboutToRestoreGlobal',
|
||||
'version:aboutToUnpublishSelection',
|
||||
'version:autosave',
|
||||
'version:autosavedSuccessfully',
|
||||
'version:compareVersion',
|
||||
'version:confirmPublish',
|
||||
'version:confirmUnpublish',
|
||||
'version:confirmVersionRestoration',
|
||||
'version:draft',
|
||||
'version:draftSavedSuccessfully',
|
||||
'version:noFurtherVersionsFound',
|
||||
'version:noRowsFound',
|
||||
'version:preview',
|
||||
'version:problemRestoringVersion',
|
||||
'version:publish',
|
||||
'version:publishChanges',
|
||||
'version:published',
|
||||
'version:publishing',
|
||||
'version:restoredSuccessfully',
|
||||
'version:restoreThisVersion',
|
||||
'version:restoring',
|
||||
'version:saveDraft',
|
||||
'version:selectLocales',
|
||||
'version:selectVersionToCompare',
|
||||
'version:showLocales',
|
||||
'version:type',
|
||||
'version:unpublish',
|
||||
'version:unpublishing',
|
||||
'version:versionCreatedOn',
|
||||
'version:versionID',
|
||||
'version:versions',
|
||||
'version:viewingVersion',
|
||||
'version:viewingVersionGlobal',
|
||||
'version:viewingVersions',
|
||||
'version:viewingVersionsGlobal',
|
||||
];
|
||||
const DESTINATION_ROOT = '../dist';
|
||||
const SOURCE_DIR = './all';
|
||||
function filterKeys(obj, parentGroupKey = '', keys) {
|
||||
const result = {};
|
||||
for (const [namespaceKey, value] of Object.entries(obj)) {
|
||||
// Skip $schema key
|
||||
if (namespaceKey === '$schema') {
|
||||
result[namespaceKey] = value;
|
||||
continue;
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
const filteredObject = filterKeys(value, namespaceKey, keys);
|
||||
if (Object.keys(filteredObject).length > 0) {
|
||||
result[namespaceKey] = filteredObject;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const key of keys) {
|
||||
const [groupKey, selector] = key.split(':');
|
||||
if (parentGroupKey === groupKey) {
|
||||
if (namespaceKey === selector) {
|
||||
result[selector] = value;
|
||||
}
|
||||
else {
|
||||
const pluralKeys = ['zero', 'one', 'two', 'few', 'many', 'other'];
|
||||
pluralKeys.forEach((pluralKey) => {
|
||||
if (namespaceKey === `${selector}_${pluralKey}`) {
|
||||
result[`${selector}_${pluralKey}`] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function sortObject(obj) {
|
||||
const sortedObject = {};
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.forEach((key) => {
|
||||
if (typeof obj[key] === 'object') {
|
||||
sortedObject[key] = sortObject(obj[key]);
|
||||
}
|
||||
else {
|
||||
sortedObject[key] = obj[key];
|
||||
}
|
||||
});
|
||||
return sortedObject;
|
||||
}
|
||||
function buildSchemaFile(type) {
|
||||
const groupedProperties = new Map();
|
||||
const keys = type === 'client' ? clientTranslationKeys : serverTranslationKeys;
|
||||
const DESTINATION_DIR = `${DESTINATION_ROOT}/${type === 'client' ? 'client' : 'api'}`;
|
||||
for (const translationKey of keys) {
|
||||
const [group, selector] = translationKey.split(':');
|
||||
groupedProperties.set(group, groupedProperties.get(group) || new Set());
|
||||
groupedProperties.get(group).add(selector);
|
||||
const pluralKeys = ['zero', 'one', 'two', 'few', 'many', 'other'];
|
||||
pluralKeys.forEach((pluralKey) => {
|
||||
groupedProperties.get(group).add(`${selector}_${pluralKey}`);
|
||||
});
|
||||
}
|
||||
const schemaFileContents = JSON.parse(fs.readFileSync(path.resolve(__dirname, SOURCE_DIR, 'translation-schema.json'), 'utf8'));
|
||||
for (const [group, selectors] of groupedProperties.entries()) {
|
||||
const groupProperties = schemaFileContents.properties[group];
|
||||
const remainingProperties = {};
|
||||
const remainingRequired = [];
|
||||
for (const selector of selectors) {
|
||||
if (groupProperties.properties?.[selector]) {
|
||||
remainingProperties[selector] = groupProperties.properties[selector];
|
||||
if (groupProperties.required && groupProperties.required.includes(selector)) {
|
||||
remainingRequired.push(selector);
|
||||
}
|
||||
}
|
||||
}
|
||||
groupProperties.properties = remainingProperties;
|
||||
if (remainingRequired.length) {
|
||||
groupProperties.required = remainingRequired;
|
||||
}
|
||||
else {
|
||||
delete groupProperties.required;
|
||||
}
|
||||
}
|
||||
schemaFileContents.required = Array.from(groupedProperties.keys());
|
||||
fs.writeFileSync(path.resolve(__dirname, DESTINATION_DIR, 'translation-schema.json'), JSON.stringify(schemaFileContents, null, 2), { flag: 'w+' });
|
||||
}
|
||||
async function build() {
|
||||
(0, ensureDirExists_1.ensureDirectoryExists)(path.resolve(__dirname, `${DESTINATION_ROOT}/client`));
|
||||
(0, ensureDirExists_1.ensureDirectoryExists)(path.resolve(__dirname, `${DESTINATION_ROOT}/api`));
|
||||
const filenames = fs.readdirSync(path.resolve(__dirname, SOURCE_DIR));
|
||||
// build up the client and server translation files
|
||||
for (const filename of filenames) {
|
||||
if (!filename.endsWith('.json') || filename === 'translation-schema.json') {
|
||||
continue;
|
||||
}
|
||||
const source = JSON.parse(fs.readFileSync(path.resolve(__dirname, SOURCE_DIR, filename), 'utf8'));
|
||||
const clientTranslations = sortObject(filterKeys(source, '', clientTranslationKeys));
|
||||
fs.writeFileSync(path.resolve(__dirname, `${DESTINATION_ROOT}/client`, filename), JSON.stringify(clientTranslations, null, 2), {
|
||||
flag: 'w+',
|
||||
});
|
||||
const serverTranslations = sortObject(filterKeys(source, '', serverTranslationKeys));
|
||||
fs.writeFileSync(path.resolve(__dirname, `${DESTINATION_ROOT}/api`, filename), JSON.stringify(serverTranslations, null, 2), {
|
||||
flag: 'w+',
|
||||
});
|
||||
console.info(filename, ': sync complete');
|
||||
}
|
||||
// build up the client and server schema files after the translation files have been built
|
||||
buildSchemaFile('client');
|
||||
buildSchemaFile('server');
|
||||
// copy barrel files
|
||||
await (0, transpileAndCopy_1.transpileAndCopy)(path.resolve(__dirname, SOURCE_DIR, 'index.ts'), path.resolve(__dirname, `${DESTINATION_ROOT}/api`, 'index.ts'));
|
||||
await (0, transpileAndCopy_1.transpileAndCopy)(path.resolve(__dirname, SOURCE_DIR, 'index.ts'), path.resolve(__dirname, `${DESTINATION_ROOT}/client`, 'index.ts'));
|
||||
}
|
||||
build()
|
||||
.then(() => {
|
||||
console.log('Built client and api translation files.');
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error occurred:', error);
|
||||
});
|
||||
63
packages/translations/dist/client/index.d.ts
vendored
63
packages/translations/dist/client/index.d.ts
vendored
@@ -1,63 +0,0 @@
|
||||
export namespace translations {
|
||||
export { ar };
|
||||
export { az };
|
||||
export { bg };
|
||||
export { cs };
|
||||
export { de };
|
||||
export { en };
|
||||
export { es };
|
||||
export { fa };
|
||||
export { fr };
|
||||
export { hr };
|
||||
export { hu };
|
||||
export { it };
|
||||
export { ja };
|
||||
export { ko };
|
||||
export { my };
|
||||
export { nb };
|
||||
export { nl };
|
||||
export { pl };
|
||||
export { pt };
|
||||
export { ro };
|
||||
export { rs };
|
||||
export { rsLatin };
|
||||
export { ru };
|
||||
export { sv };
|
||||
export { th };
|
||||
export { tr };
|
||||
export { ua };
|
||||
export { vi };
|
||||
export { zh };
|
||||
export { zhTw };
|
||||
}
|
||||
import ar from "./ar.json";
|
||||
import az from "./az.json";
|
||||
import bg from "./bg.json";
|
||||
import cs from "./cs.json";
|
||||
import de from "./de.json";
|
||||
import en from "./en.json";
|
||||
import es from "./es.json";
|
||||
import fa from "./fa.json";
|
||||
import fr from "./fr.json";
|
||||
import hr from "./hr.json";
|
||||
import hu from "./hu.json";
|
||||
import it from "./it.json";
|
||||
import ja from "./ja.json";
|
||||
import ko from "./ko.json";
|
||||
import my from "./my.json";
|
||||
import nb from "./nb.json";
|
||||
import nl from "./nl.json";
|
||||
import pl from "./pl.json";
|
||||
import pt from "./pt.json";
|
||||
import ro from "./ro.json";
|
||||
import rs from "./rs.json";
|
||||
import rsLatin from "./rs-latin.json";
|
||||
import ru from "./ru.json";
|
||||
import sv from "./sv.json";
|
||||
import th from "./th.json";
|
||||
import tr from "./tr.json";
|
||||
import ua from "./ua.json";
|
||||
import vi from "./vi.json";
|
||||
import zh from "./zh.json";
|
||||
import zhTw from "./zh-tw.json";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAAe,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;oBACN,iBAAiB;eACtB,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;eACX,WAAW;iBACT,cAAc"}
|
||||
62
packages/translations/dist/client/index.js
vendored
62
packages/translations/dist/client/index.js
vendored
@@ -1,62 +0,0 @@
|
||||
import ar from "./ar.json";
|
||||
import az from "./az.json";
|
||||
import bg from "./bg.json";
|
||||
import cs from "./cs.json";
|
||||
import de from "./de.json";
|
||||
import en from "./en.json";
|
||||
import es from "./es.json";
|
||||
import fa from "./fa.json";
|
||||
import fr from "./fr.json";
|
||||
import hr from "./hr.json";
|
||||
import hu from "./hu.json";
|
||||
import it from "./it.json";
|
||||
import ja from "./ja.json";
|
||||
import ko from "./ko.json";
|
||||
import my from "./my.json";
|
||||
import nb from "./nb.json";
|
||||
import nl from "./nl.json";
|
||||
import pl from "./pl.json";
|
||||
import pt from "./pt.json";
|
||||
import ro from "./ro.json";
|
||||
import rs from "./rs.json";
|
||||
import rsLatin from "./rs-latin.json";
|
||||
import ru from "./ru.json";
|
||||
import sv from "./sv.json";
|
||||
import th from "./th.json";
|
||||
import tr from "./tr.json";
|
||||
import ua from "./ua.json";
|
||||
import vi from "./vi.json";
|
||||
import zh from "./zh.json";
|
||||
import zhTw from "./zh-tw.json";
|
||||
export var translations = {
|
||||
ar: ar,
|
||||
az: az,
|
||||
bg: bg,
|
||||
cs: cs,
|
||||
de: de,
|
||||
en: en,
|
||||
es: es,
|
||||
fa: fa,
|
||||
fr: fr,
|
||||
hr: hr,
|
||||
hu: hu,
|
||||
it: it,
|
||||
ja: ja,
|
||||
ko: ko,
|
||||
my: my,
|
||||
nb: nb,
|
||||
nl: nl,
|
||||
pl: pl,
|
||||
pt: pt,
|
||||
ro: ro,
|
||||
rs: rs,
|
||||
rsLatin: rsLatin,
|
||||
ru: ru,
|
||||
sv: sv,
|
||||
th: th,
|
||||
tr: tr,
|
||||
ua: ua,
|
||||
vi: vi,
|
||||
zh: zh,
|
||||
zhTw: zhTw
|
||||
};
|
||||
@@ -5,22 +5,26 @@
|
||||
"main": "./dist/exports/index.ts",
|
||||
"types": "./dist/types.d.ts",
|
||||
"scripts": {
|
||||
"build": "npx ts-node ./src/build.ts && tsc",
|
||||
"writeFiles": "npx ts-node ./writeTranslationFiles.ts",
|
||||
"build": "pnpm writeFiles && tsc",
|
||||
"clean": "rimraf {dist,*.tsbuildinfo}",
|
||||
"prepublishOnly": "pnpm clean && pnpm build"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/exports/index.js",
|
||||
"require": "./dist/exports/index.js"
|
||||
},
|
||||
"./api": {
|
||||
"import": "./dist/api/index.js",
|
||||
"require": "./dist/api/index.js"
|
||||
"import": "./dist/_generatedFiles_/api/index.js",
|
||||
"require": "./dist/_generatedFiles_/api/index.js"
|
||||
},
|
||||
"./client": {
|
||||
"import": "./dist/client/index.js",
|
||||
"require": "./dist/client/index.js"
|
||||
"import": "./dist/_generatedFiles_/client/index.js",
|
||||
"require": "./dist/_generatedFiles_/client/index.js"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
63
packages/translations/src/_generatedFiles_/api/index.ts
Normal file
63
packages/translations/src/_generatedFiles_/api/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import ar from './ar.json'
|
||||
import az from './az.json'
|
||||
import bg from './bg.json'
|
||||
import cs from './cs.json'
|
||||
import de from './de.json'
|
||||
import en from './en.json'
|
||||
import es from './es.json'
|
||||
import fa from './fa.json'
|
||||
import fr from './fr.json'
|
||||
import hr from './hr.json'
|
||||
import hu from './hu.json'
|
||||
import it from './it.json'
|
||||
import ja from './ja.json'
|
||||
import ko from './ko.json'
|
||||
import my from './my.json'
|
||||
import nb from './nb.json'
|
||||
import nl from './nl.json'
|
||||
import pl from './pl.json'
|
||||
import pt from './pt.json'
|
||||
import ro from './ro.json'
|
||||
import rs from './rs.json'
|
||||
import rsLatin from './rs-latin.json'
|
||||
import ru from './ru.json'
|
||||
import sv from './sv.json'
|
||||
import th from './th.json'
|
||||
import tr from './tr.json'
|
||||
import ua from './ua.json'
|
||||
import vi from './vi.json'
|
||||
import zh from './zh.json'
|
||||
import zhTw from './zh-tw.json'
|
||||
|
||||
export const translations = {
|
||||
ar,
|
||||
az,
|
||||
bg,
|
||||
cs,
|
||||
de,
|
||||
en,
|
||||
es,
|
||||
fa,
|
||||
fr,
|
||||
hr,
|
||||
hu,
|
||||
it,
|
||||
ja,
|
||||
ko,
|
||||
my,
|
||||
nb,
|
||||
nl,
|
||||
pl,
|
||||
pt,
|
||||
ro,
|
||||
rs,
|
||||
rsLatin,
|
||||
ru,
|
||||
sv,
|
||||
th,
|
||||
tr,
|
||||
ua,
|
||||
vi,
|
||||
zh,
|
||||
zhTw,
|
||||
}
|
||||
63
packages/translations/src/_generatedFiles_/client/index.ts
Normal file
63
packages/translations/src/_generatedFiles_/client/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import ar from './ar.json'
|
||||
import az from './az.json'
|
||||
import bg from './bg.json'
|
||||
import cs from './cs.json'
|
||||
import de from './de.json'
|
||||
import en from './en.json'
|
||||
import es from './es.json'
|
||||
import fa from './fa.json'
|
||||
import fr from './fr.json'
|
||||
import hr from './hr.json'
|
||||
import hu from './hu.json'
|
||||
import it from './it.json'
|
||||
import ja from './ja.json'
|
||||
import ko from './ko.json'
|
||||
import my from './my.json'
|
||||
import nb from './nb.json'
|
||||
import nl from './nl.json'
|
||||
import pl from './pl.json'
|
||||
import pt from './pt.json'
|
||||
import ro from './ro.json'
|
||||
import rs from './rs.json'
|
||||
import rsLatin from './rs-latin.json'
|
||||
import ru from './ru.json'
|
||||
import sv from './sv.json'
|
||||
import th from './th.json'
|
||||
import tr from './tr.json'
|
||||
import ua from './ua.json'
|
||||
import vi from './vi.json'
|
||||
import zh from './zh.json'
|
||||
import zhTw from './zh-tw.json'
|
||||
|
||||
export const translations = {
|
||||
ar,
|
||||
az,
|
||||
bg,
|
||||
cs,
|
||||
de,
|
||||
en,
|
||||
es,
|
||||
fa,
|
||||
fr,
|
||||
hr,
|
||||
hu,
|
||||
it,
|
||||
ja,
|
||||
ko,
|
||||
my,
|
||||
nb,
|
||||
nl,
|
||||
pl,
|
||||
pt,
|
||||
ro,
|
||||
rs,
|
||||
rsLatin,
|
||||
ru,
|
||||
sv,
|
||||
th,
|
||||
tr,
|
||||
ua,
|
||||
vi,
|
||||
zh,
|
||||
zhTw,
|
||||
}
|
||||
12
packages/translations/src/utilities/copyFile.ts
Normal file
12
packages/translations/src/utilities/copyFile.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
const fs = require('fs')
|
||||
|
||||
export function copyFile(source, destination) {
|
||||
fs.copyFile(source, destination, (err) => {
|
||||
if (err) {
|
||||
// Handle error
|
||||
console.error(`Error copying file from ${source} to ${destination}:`, err)
|
||||
return
|
||||
}
|
||||
console.log(`File copied successfully from ${source} to ${destination}.`)
|
||||
})
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import fs from 'fs'
|
||||
const swc = require('@swc/core')
|
||||
export async function transpileAndCopy(sourcePath, targetPath) {
|
||||
try {
|
||||
const inputCode = fs.readFileSync(sourcePath, 'utf-8')
|
||||
|
||||
const { code } = await swc.transform(inputCode, {
|
||||
filename: sourcePath,
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: 'typescript',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
fs.writeFileSync(targetPath.replace(/\.tsx?$/, '.js'), code, 'utf-8')
|
||||
console.log(`Transpiled and copied ${sourcePath} to ${targetPath.replace(/\.tsx?$/, '.js')}`)
|
||||
} catch (error) {
|
||||
console.error(`Error transpiling ${sourcePath}: ${error.message}`)
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,9 @@
|
||||
"moduleResolution": "Node16",
|
||||
"resolveJsonModule": true,
|
||||
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
||||
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
||||
"rootDir": "./src",
|
||||
"lib": ["dom", "dom.iterable", "esnext"]
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.json"],
|
||||
"exclude": ["src/all"],
|
||||
"references": [{ "path": "../payload" }]
|
||||
"exclude": ["src/all"]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { transpileAndCopy } from './utilities/transpileAndCopy'
|
||||
import { ensureDirectoryExists } from './utilities/ensureDirExists'
|
||||
import { ensureDirectoryExists } from './src/utilities/ensureDirExists'
|
||||
import { copyFile } from './src/utilities/copyFile'
|
||||
|
||||
const serverTranslationKeys = [
|
||||
'authentication:account',
|
||||
@@ -343,8 +343,8 @@ const clientTranslationKeys = [
|
||||
'version:viewingVersionsGlobal',
|
||||
]
|
||||
|
||||
const DESTINATION_ROOT = '../dist'
|
||||
const SOURCE_DIR = './all'
|
||||
const DESTINATION_ROOT = './src/_generatedFiles_'
|
||||
const SOURCE_DIR = './src/all'
|
||||
|
||||
function filterKeys(obj, parentGroupKey = '', keys) {
|
||||
const result = {}
|
||||
@@ -484,21 +484,21 @@ async function build() {
|
||||
},
|
||||
)
|
||||
|
||||
console.info(filename, ': sync complete')
|
||||
console.info('Rebuilt:', filename)
|
||||
}
|
||||
|
||||
// build up the client and server schema files after the translation files have been built
|
||||
buildSchemaFile('client')
|
||||
buildSchemaFile('server')
|
||||
|
||||
// copy barrel files
|
||||
await transpileAndCopy(
|
||||
path.resolve(__dirname, SOURCE_DIR, 'index.ts'),
|
||||
path.resolve(__dirname, `${DESTINATION_ROOT}/api`, 'index.ts'),
|
||||
// copy barrel file to both client and api folders
|
||||
copyFile(
|
||||
path.resolve(__dirname, `${SOURCE_DIR}/index.ts`),
|
||||
path.resolve(__dirname, `${DESTINATION_ROOT}/api/index.ts`),
|
||||
)
|
||||
await transpileAndCopy(
|
||||
path.resolve(__dirname, SOURCE_DIR, 'index.ts'),
|
||||
path.resolve(__dirname, `${DESTINATION_ROOT}/client`, 'index.ts'),
|
||||
copyFile(
|
||||
path.resolve(__dirname, `${SOURCE_DIR}/index.ts`),
|
||||
path.resolve(__dirname, `${DESTINATION_ROOT}/client/index.ts`),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { RichTextField, RichTextAdapter, CellComponentProps } from 'payload
|
||||
|
||||
export const RichTextCell: React.FC<CellComponentProps<RichTextField>> = (props) => {
|
||||
// eslint-disable-next-line react/destructuring-assignment
|
||||
const editor: RichTextAdapter = props.field.editor
|
||||
const editor: RichTextAdapter = props.cellData.editor
|
||||
|
||||
const isLazy = 'LazyCellComponent' in editor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user