Last active
July 30, 2024 07:12
-
-
Save engalar/f26295c41c9b79c52670387d05e5e52d to your computer and use it in GitHub Desktop.
mendix patch locale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
{{unsupportedbrowser}} | |
<meta charset="utf-8"> | |
<title>Mendix</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
{{themecss}} | |
{{appicons}} | |
{{manifest}} | |
{{startupimages}} | |
</head> | |
<body dir="ltr"> | |
<noscript>To use this application, please enable JavaScript.</noscript> | |
<div id="content"></div> | |
<script> | |
dojoConfig = { | |
isDebug: false, | |
useCustomLogger: true, | |
async: true, | |
baseUrl: "mxclientsystem/dojo/", | |
cacheBust: "{{cachebust}}", | |
rtlRedirect: "index-rtl.html" | |
}; | |
</script> | |
<script> | |
if (!document.cookie || !document.cookie.match(/(^|;) *originURI=/gi)) { | |
const url = new URL(window.location.href); | |
const subPath = url.pathname.substring(0, url.pathname.lastIndexOf("/")); | |
document.cookie = `originURI=${subPath}/login.html${window.location.protocol === "https:" ? ";SameSite=None;Secure" : ""}`; | |
} | |
</script> | |
<script> | |
// Put your patch code here | |
</script> | |
<script src="mxclientsystem/mxui/mxui.js?{{cachebust}}"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function patchLocale(cb) { | |
function update(enumerations, locale) { | |
Object.keys(enumerations).forEach(enumName => { | |
let newCaptions = locale[enumName]; | |
if (newCaptions) { | |
enumerations[enumName].forEach((item, index) => { | |
item[1] = newCaptions[index]; | |
}); | |
} | |
}); | |
} | |
const locale = { | |
"en_US": { | |
"System.WorkflowActivityExecutionState": [ | |
"Created", | |
"InProgress", | |
"Completed", | |
"Paused", | |
"Aborted", | |
"Failed" | |
], | |
"System.UnreferencedFileState": [ | |
"New", | |
"Obsolete", | |
"Deleted" | |
], | |
"System.WorkflowCurrentActivityAction": [ | |
"Do Nothing", | |
"Jump To" | |
], | |
"System.WorkflowUserTaskState": [ | |
"Created", | |
"In Progress", | |
"Completed", | |
"Paused", | |
"Aborted", | |
"Failed" | |
], | |
"System.WorkflowUserTaskCompletionType": [ | |
"Single", | |
"Veto", | |
"Consensus", | |
"Majority", | |
"Threshold", | |
"Custom" | |
], | |
"System.EventStatus": [ | |
"Running", | |
"Completed", | |
"Error", | |
"Stopped" | |
], | |
"System.QueueTaskStatus": [ | |
"Idle", | |
"Running", | |
"Completed", | |
"Failed", | |
"Retrying", | |
"Aborted", | |
"Incompatible" | |
], | |
"System.ProxyConfiguration": [ | |
"UseAppSettings", | |
"Override", | |
"NoProxy" | |
], | |
"System.WorkflowState": [ | |
"In Progress", | |
"Paused", | |
"Completed", | |
"Aborted", | |
"Incompatible", | |
"失败" | |
], | |
"System.WorkflowActivityType": [ | |
"Start", | |
"End", | |
"Decision", | |
"Parallel Split", | |
"End of Parallel Split Branch", | |
"Merge of Parallel Split", | |
"User task", | |
"Call Microflow", | |
"Call Workflow", | |
"Jump", | |
"Multi User Task", | |
"Wait for Notification", | |
"Wait for timer" | |
], | |
"System.WorkflowEventType": [ | |
"WorkflowCompleted", | |
"WorkflowInitiated", | |
"WorkflowRestarted", | |
"WorkflowFailed", | |
"WorkflowAborted", | |
"WorkflowPaused", | |
"WorkflowUnpaused", | |
"WorkflowRetried", | |
"WorkflowUpdated", | |
"WorkflowUpgraded", | |
"WorkflowConflicted", | |
"WorkflowResolved", | |
"WorkflowJumpToOptionApplied", | |
"StartEventExecuted", | |
"EndEventExecuted", | |
"DecisionExecuted", | |
"JumpExecuted", | |
"ParallelSplitExecuted", | |
"ParallelMergeExecuted", | |
"CallWorkflowStarted", | |
"CallWorkflowEnded", | |
"CallMicroflowStarted", | |
"CallMicroflowEnded", | |
"WaitForNotificationStarted", | |
"WaitForNotificationEnded", | |
"WaitForTimerStarted", | |
"WaitForTimerEnded", | |
"UserTaskStarted", | |
"MultiUserTaskOutcomeSelected", | |
"UserTaskEnded" | |
], | |
"System.WorkflowActivityState": [ | |
"Started", | |
"Suspended", | |
"Finished", | |
"Replaced", | |
"Aborted", | |
"Failed" | |
], | |
"System.ContextType": [ | |
"System", | |
"User", | |
"Anonymous", | |
"ScheduledEvent" | |
], | |
"System.UserType": [ | |
"Internal", | |
"External" | |
] | |
}, "zh_CN": { | |
"System.WorkflowActivityExecutionState": [ | |
"创建", | |
"进行中", | |
"已完成", | |
"已暂停", | |
"已中止", | |
"失败" | |
], | |
"System.UnreferencedFileState": [ | |
"新建", | |
"过时", | |
"已删除" | |
], | |
"System.WorkflowCurrentActivityAction": [ | |
"不执行任何操作", | |
"跳转至" | |
], | |
"System.WorkflowUserTaskState": [ | |
"创建", | |
"进行中", | |
"已完成", | |
"已暂停", | |
"已中止", | |
"失败" | |
], | |
"System.WorkflowUserTaskCompletionType": [ | |
"单一", | |
"否决", | |
"一致", | |
"多数", | |
"阈值", | |
"自定义" | |
], | |
"System.EventStatus": [ | |
"运行中", | |
"已完成", | |
"错误", | |
"已停止" | |
], | |
"System.QueueTaskStatus": [ | |
"空闲", | |
"运行中", | |
"已完成", | |
"失败", | |
"重试中", | |
"已中止", | |
"不兼容" | |
], | |
"System.ProxyConfiguration": [ | |
"使用应用设置", | |
"覆盖", | |
"无代理" | |
], | |
"System.WorkflowState": [ | |
"进行中", | |
"已暂停", | |
"已完成", | |
"已中止", | |
"不兼容", | |
"失败" | |
], | |
"System.WorkflowActivityType": [ | |
"开始", | |
"结束", | |
"决策", | |
"并行分支", | |
"并行分支结束", | |
"并行合并", | |
"用户任务", | |
"调用微流程", | |
"调用工作流", | |
"跳转", | |
"多用户任务", | |
"等待通知", | |
"等待定时器" | |
], | |
"System.WorkflowEventType": [ | |
"工作流已完成", | |
"工作流已启动", | |
"工作流已重新启动", | |
"工作流失败", | |
"工作流已中止", | |
"工作流已暂停", | |
"工作流已恢复", | |
"工作流已重试", | |
"工作流已更新", | |
"工作流已升级", | |
"工作流冲突", | |
"工作流已解决", | |
"工作流跳转选项已应用", | |
"开始事件已执行", | |
"结束事件已执行", | |
"决策已执行", | |
"跳转已执行", | |
"并行分支已执行", | |
"并行合并已执行", | |
"调用工作流已启动", | |
"调用工作流已结束", | |
"调用微流程已启动", | |
"调用微流程已结束", | |
"等待通知已启动", | |
"等待通知已结束", | |
"等待定时器已启动", | |
"等待定时器已结束", | |
"用户任务已启动", | |
"多用户任务结果已选择", | |
"用户任务已结束" | |
], | |
"System.WorkflowActivityState": [ | |
"已启动", | |
"已挂起", | |
"已完成", | |
"已替换", | |
"已中止", | |
"失败" | |
], | |
"System.ContextType": [ | |
"系统", | |
"用户", | |
"匿名", | |
"计划事件" | |
], | |
"System.UserType": [ | |
"内部", | |
"外部" | |
] | |
} | |
}; | |
function patchLocale(cb) { | |
let originMx, originSessionData; | |
Object.defineProperty(window, "mx", { | |
get() { | |
return originMx; | |
}, | |
set(rawMx) { | |
originMx = rawMx; | |
Object.defineProperty(rawMx.session, "sessionData", { | |
get() { | |
return originSessionData; | |
}, | |
set(sd) { | |
originSessionData = sd; | |
const enumerations = sd.enumerations; | |
cb(enumerations); | |
}, | |
configurable: true | |
}); | |
}, | |
configurable: true | |
}); | |
} | |
patchLocale(enumerations => update(enumerations, locale[mx.session.getConfig("locale").code])); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment