MCPcopy Index your code
hub / github.com/crisxuan/bestJavaer / localizeSidebarGroupLabels

Function localizeSidebarGroupLabels

assets/article-cards.js:302–327  ·  view source on GitHub ↗
(sidebar, locale)

Source from the content-addressed store, hash-verified

300 }
301
302 function localizeSidebarGroupLabels(sidebar, locale) {
303 var replacements = {};
304
305 sidebarGroupLabels.forEach(function (label) {
306 replacements[label.enText] = locale === 'zh' ? label.zhText : label.enText;
307 replacements[label.zhText] = locale === 'zh' ? label.zhText : label.enText;
308 });
309
310 Array.from(sidebar.querySelectorAll('li')).forEach(function (item) {
311 Array.from(item.childNodes).some(function (node) {
312 var text = node.textContent ? node.textContent.trim() : '';
313
314 if (node.nodeType === 3 && replacements[text]) {
315 node.textContent = replacements[text];
316 return true;
317 }
318
319 if (node.nodeType === 1 && node.tagName === 'P' && replacements[text]) {
320 node.textContent = replacements[text];
321 return true;
322 }
323
324 return false;
325 });
326 });
327 }
328
329 function syncSidebarActiveState(sidebar, route, locale) {
330 var activeHref = getActiveSidebarHref(route, locale);

Callers 1

localizeSidebarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected