미디어위키:Common.js: 두 판 사이의 차이
Resultofunion (토론 | 기여) 편집 요약 없음 |
Resultofunion (토론 | 기여) 편집 요약 없음 |
||
| 32번째 줄: | 32번째 줄: | ||
if (!wcs_add) var wcs_add = {}; | if (!wcs_add) var wcs_add = {}; | ||
wcs_add['wa'] = 'ab0e0ecee3c040'; | wcs_add['wa'] = 'ab0e0ecee3c040'; | ||
/* TOP 버튼 */ | /* TOP 버튼 */ | ||
| 318번째 줄: | 307번째 줄: | ||
// 데스크탑 언어 | // 데스크탑 언어 | ||
var langDiv = document.getElementById('right-navigation'); | |||
if(langDiv){ | |||
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" data-event-name="ui.dropdown-p-cactions" class="vector-menu-checkbox" aria-labelledby="p-cactions-label">' + | |||
'<label id="p-cactions-label" aria-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">' + | |||
'<li class="mw-list-item"><a href="https://churchofgod.wiki" title="하나님의 교회 지식사전"><span>Korean</span></a></li>' + | |||
'<li class="mw-list-item"><a href="https://churchofgod.wiki/en" title="Church of God Knowledge Encyclopedia"><span>English</span></a></li>' + | |||
'<li class="mw-list-item"><a href="https://churchofgod.wiki/es" title="ChurchEnciclopedia de conocimiento de la Iglesia de Dios"><span>Spanish</span></a></li>' + | |||
'<li class="mw-list-item"><a href="https://churchofgod.wiki/vi" title="Từ điển tri thức Hội Thánh của Đức Chúa Trời"><span>Vietnamese</span></a></li>' + | |||
'<li class="mw-list-item"><a href="https://churchofgod.wiki/ne" title="नेपाली"><span>Nepali</span></a></li>' + | |||
'<li class="mw-list-item"><a href="https://churchofgod.wiki/pt" title="ENCICLOPÉDIA DO CONHECIMENTO DA IGREJA DE DEUS"><span>português</span></a></li>' + | |||
'</ul>' + | |||
'</div>' + | |||
'</nav>'; | |||
langDiv.insertAdjacentHTML('afterbegin', navHTML); | |||
} | |||
/* GA4: single ID + language tagging (MediaWiki 1.42.3) */ | |||
(function () { | |||
// 중복 로드 방지 | |||
if (window.__GA4_LOADED__) return; | |||
window.__GA4_LOADED__ = true; | |||
var GA_ID = 'G-YGT3D2Q9QW'; | |||
// | // 언어 결정: 가장 신뢰도 높은 wgContentLanguage, 없으면 경로 프리픽스로 보완 | ||
var pathLang = (location.pathname.split('/')[1] || '').toLowerCase(); | |||
var lang = (mw.config && mw.config.get('wgContentLanguage')) | |||
|| (['en','es','ko','vi','pt','ne'].includes(pathLang) ? pathLang : 'ko'); | |||
// <head>에 gtag 로더 삽입 | |||
var s = document.createElement('script'); | |||
s.async = true; | |||
s.src = 'https://www.googletagmanager.com/gtag/js?id=' + encodeURIComponent(GA_ID); | |||
document.head.appendChild(s); | |||
window.dataLayer = window.dataLayer || []; | |||
function gtag(){ dataLayer.push(arguments); } | |||
window.gtag = gtag; | |||
gtag('js', new Date()); | |||
// 🔹 자동 page_view 끄기 | |||
gtag('config', GA_ID, { | |||
send_page_view: false, | |||
debug_mode: true | |||
}); | |||
// 사용자 속성 | |||
gtag('set', 'user_properties', { | |||
site_language: lang, | |||
browser_language: navigator.language || navigator.userLanguage | |||
}); | |||
gtag('event', 'page_view', { | |||
page_location: location.href, | |||
page_path: location.pathname + location.search, | |||
page_title: document.title, | |||
content_group: lang | |||
}); | |||
console.log('gtag', lang, document.title, navigator.language || navigator.userLanguage); | |||
})(); | |||
mw.loader.using(['jquery']).then(function () { | |||
// | // 언어 이름 매핑 : lang code → 한국어 언어 이름 | ||
const langMap = { | |||
' | 'ko': '한국어', | ||
' | 'en': '영어', | ||
' | 'es': '스페인어', | ||
'vi': '베트남어', | |||
' | 'ne': '네팔어', | ||
'pt': '포르투갈어' | |||
' | }; | ||
' | |||
// 인터위키 언어 목록 선택자 | |||
const $items = $('.vector-menu-content-list .interlanguage-link a'); | |||
$items.each(function () { | |||
const $a = $(this); | |||
const langCode = $a.attr('lang'); // en, es, vi, ne, pt … | |||
const autonym = $a.find('span').text(); // English, Español, Tiếng Việt … | |||
const | const koreanName = langMap[langCode]; | ||
if (!koreanName) return; // 배열에 없는 언어는 스킵 | |||
// 이미 한국어 형식이 적용된 경우 중복 적용 방지 | |||
if (autonym.includes('(')) return; | |||
$ | // 링크 텍스트 변경: "English" → "English (영어)" | ||
$a.find('span').text(`${autonym} (${koreanName})`); | |||
}); | }); | ||
}); | }); | ||