미디어위키:Common.js: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
375번째 줄: 375번째 줄:


mw.loader.using(['jquery']).then(function () {
mw.loader.using(['jquery']).then(function () {
 
    // ----------------------------
     // 언어 이름 매핑 : lang code → 한국어 언어 이름
     // 1. 인터랭 텍스트 한국어 병기
    // ----------------------------
     const langMap = {
     const langMap = {
         'ko': '한국어',
         'ko': '한국어',
404번째 줄: 405번째 줄:
         $a.find('span').text(`${autonym} (${koreanName})`);
         $a.find('span').text(`${autonym} (${koreanName})`);
     });
     });
   
    // ----------------------------
    // 2. 변환된 인터랭을 헤더로 복사
    // ----------------------------
    const $interLangList = $('#p-lang .vector-menu-content-list');
    if ($interLangList.length === 0) return;
    var langDiv = document.getElementById('right-navigation');
    if (!langDiv) return;
    var navHTML =
        '<nav id="p-cactions" class="mw-portlet mw-portlet-cactions vector-menu-dropdown-noicon vector-menu vector-menu-dropdown" aria-labelledby="p-cactions-label" role="navigation">' +
            '<input type="checkbox" id="p-cactions-checkbox" role="button" aria-haspopup="true" class="vector-menu-checkbox" aria-labelledby="p-cactions-label">' +
            '<label id="p-cactions-label" class="vector-menu-heading">' +
                '<span class="select-language"></span>' +
                '<span class="vector-menu-heading-label">Language</span>' +
            '</label>' +
            '<div class="vector-menu-content">' +
                '<ul class="vector-menu-content-list" id="header-lang-list"></ul>' +
            '</div>' +
        '</nav>';
    langDiv.insertAdjacentHTML('afterbegin', navHTML);
    const $headerList = $('#header-lang-list');
    // 변환된 인터랭 li 를 그대로 복사
    $interLangList.find('li.interlanguage-link').each(function () {
        const $a = $(this).find('a');
        const href = $a.attr('href');
        const title = $a.attr('title') || '';
        const text = $a.find('span').text();  // 이미 한국어 병기된 값
        const newLi =
            '<li class="mw-list-item">' +
                '<a href="' + href + '" title="' + title + '">' +
                    '<span>' + text + '</span>' +
                '</a>' +
            '</li>';
        $headerList.append(newLi);
    });   


});
});