Loading
시스템 관리자에 대한 피싱 방지 MFA 및 전 직원사용자 MFA 적용 안내 더 많이 읽기
현재 다수의 문의가 발생하여 대응에 지연이 발생하고 있습니다.더 많이 읽기
B2C Commerce 시작하기
Page Designer의 대량 현지화를 위해 현지화 가능한 요소 내보내기

Page Designer의 대량 현지화를 위해 현지화 가능한 요소 내보내기

현지화 프로세스의 빠른 진행을 위해 두 가지 API를 사용하여 현지화 내보내기 및 가져오기를 구성합니다. 이 항목은 B2C Commerce에 적용됩니다.

시작하려면 내보낼 PageID 목록을 제공하는 맞춤형 작업 단계(다음 문서에서 FindPages라고 함)를 생성합니다. 이 프로세스에 대한 자세한 내용은 맞춤형 작업 단계 생성을 참조하십시오.

다음 코드 샘플은 참조용으로 제공됩니다.

FindPages.js

/**
* Sample logic for finding Page Designer pages for bulk translation
*
* @module cartridge/scripts/jobsteps/FindPages
*/

'use strict';

/**
* Find the pages main function
*
* @param {object}  parameters Job step parameters
* 
* @param {boolean} parameters.IsDisabled Mark the step as disabled - skips step execution and returns an OK status
* @param {string}  parameters.TranslationContentFolder The content folder for pages for translation
* @param {string}  parameters.OutputPageIDsFile File with list of IDs of pages found for translation, relative to the 'Impex/src' folder
* @param {boolean} parameters.OutputUnassignmentFile File with unassignments for the Page Designer pages from the translation folder, relative to the 'Impex/src' folder, not created if omitted
* @param {string}  parameters.NoDataFoundStatus No Data for translation found exit code
* 
* @param {dw.job.JobStepExecution} stepExecution Represents an execution of a step that belongs to a job
* 
*/
function DoFindPages(parameters, stepExecution) {
	var 
		Status = require("dw/system/Status"), 
		ContentMgr = require("dw/content/ContentMgr"),
		File = require("dw/io/File"),
		FileWriter = require("dw/io/FileWriter");
	
	var folder, foundContent, content, contentFolder, impexsrc, pageidsFile, pageidsWriter, unassign, unassignFile, unassignWriter;
	
	if (parameters.IsDisabled) {
	    return new Status(Status.OK, "SKIPPED", "The job step " + stepExecution.stepID + " was skipped");
	}
	
	folder = ContentMgr.getFolder(parameters.TranslationContentFolder); // get contents of translation folder
	foundContent = (folder != null) && (folder.content.length > 0);
	if (foundContent) {
		foundContent = false;
		impexsrc = new File('IMPEX/src');
		pageidsFile = new File(impexsrc, parameters.OutputPageIDsFile);
		pageidsWriter = new FileWriter(pageidsFile, "UTF-8");
		unassign = !!parameters.OutputUnassignmentFile;
		if (unassign) {
			unassignFile = new File(impexsrc, parameters.OutputUnassignmentFile);
			unassignWriter = new FileWriter(unassignFile, "UTF-8");
			unassignWriter.writeLine('<?xml version="1.0" encoding="UTF-8"?>');
			unassignWriter.writeLine('<library xmlns="http://www.demandware.com/xml/impex/library/2006-10-31" library-id="' + ContentMgr.siteLibrary.ID +'">');
		}
		for (var i=0; i<folder.content.length; i++) { // loop through the folder content
			content = folder.content[i];
			if (content.page) {
				foundContent = true;
				pageidsWriter.writeLine(content.ID); // write page ID to the result pages list file
				if (unassign) {
					unassignWriter.writeLine('  <content content-id="' + content.ID + '">'); // write content xml for unassigning the page from the translation folder
					unassignWriter.writeLine('    <folder-links>');

					for (var j=0; j<content.folders.length; j++) {
						contentFolder = content.folders[j];
						unassignWriter.write('      ');    
						if (contentFolder.ID == folder.ID) { // as it is not possible to just delete a folder assignment, all folders a listed without the translation one
							unassignWriter.write('<!-- ');   // an XML comment is used to not include the translation folder, but it is also possible to omit it in the content xml
				        }
						if (contentFolder.ID == content.classificationFolder.ID) {
							unassignWriter.write('<classification-link folder-id="'+contentFolder.ID+'"/>')
						} else {
							unassignWriter.write('<folder-link folder-id="'+contentFolder.ID+'"/>')
						}
						if (contentFolder.ID == folder.ID) {
							unassignWriter.write(' -->');
				        }
						unassignWriter.writeLine('');
					}
					unassignWriter.writeLine('    </folder-links>');
					unassignWriter.writeLine('  </content>');
				}
			}
		}
		pageidsWriter.flush();
		pageidsWriter.close();
		if (unassign) {
			unassignWriter.writeLine('</library>');
			unassignWriter.flush();
			unassignWriter.close();
		}
	}
	if (!foundContent) {
		return new Status(Status[parameters.NoDataFoundStatus], "NO_DATA_FOUND", "No pages were found for translation in folder " + parameters.TranslationContentFolder)
	}
}


/* Exports of the modules */
/**
* @see {@link module:cartridge/scripts/jobsteps/FindPages~DoFindPages} 
*/
exports.DoFindPages = DoFindPages;

steptypes.json

{
	"step-types": {
		"script-module-step": [{
			"@type-id": "custom.PageDesignerTranslate.FindPages",
			"@supports-site-context": "true",
			"@supports-organization-context": "false",
			"module": "bc_page_designer_translate/cartridge/scripts/jobsteps/FindPages.js",
			"description": "Find Page Designer Pages for translation",
			"function": "DoFindPages",
			"parameters": {
				"parameter": [{
						"@name": "IsDisabled",
						"description": "Mark the step as disabled - skips step execution and returns an OK status",
						"@type": "boolean",
						"@required": false,
						"@trim": true
					},
					{
						"@name": "TranslationContentFolder",
						"description": "The content folder for pages for translation",
						"@type": "string",
						"@required": "true",
						"@trim": "true",
						"default-value": "for_translation"
					},
					{
						"@name": "OutputPageIDsFile",
						"description": "File with list of IDs of pages found for translation, relative to the 'Impex/src' folder",
						"@type": "string",
						"@required": "true",
						"@trim": "true",
						"default-value": "library/page_ids.txt"
					},
					{
						"@name": "OutputUnassignmentFile",
						"description": "File with unassignments for the Page Designer pages from the translation folder, relative to the 'Impex/src' folder, not created if omitted",
						"@type": "string",
						"@required": "false",
						"@trim": "true"
					},
					{
						"@name": "NoDataFoundStatus",
						"@type": "string",
						"@required": true,
						"@trim": true,
						"enum-values": {
							"value": [
								"OK",
								"ERROR"
							]
						},
						"default-value": "OK",
						"description": "No Data for translation found exit code"
					}

				]
			},
			"status-codes": {
				"status": [{
						"@code": "ERROR",
						"description": "Used when an error occurred."
					},
					{
						"@code": "OK",
						"description": "Used when execution was successful."
					},
					{
						"@code": "NO_DATA_FOUND",
						"description": "Used when no page designer pages could be found in the source folder."
					},
					{
						"@code": "SKIPPED",
						"description": "Used when step is marked as disabled."
					}
				]
			}
		}]
	}
}
 
로드 중
Salesforce Help | Article