Fix: tooltips de wowhead en el idioma de la web (no siempre inglés)

El script de tooltips prioriza el atributo data-wowhead sobre el subdominio del
href, y su parámetro `domain` codifica idioma + versión: el 1.er segmento va al
mapa de locales ({es:6,...}) y el resto a la versión (wotlk=WRATH). Antes se
enviaba `domain=wotlk` (sin idioma) → locale 0 = inglés siempre.

Ahora `wowheadData(type,id,locale)` genera `domain=es.wotlk` en español (locale 6)
y `domain=wotlk` en inglés. Verificado: el endpoint de datos con locale 6 devuelve
los nombres en español.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-14 22:41:58 +00:00
parent 7d1abab9f1
commit 033ebc6861
4 changed files with 23 additions and 11 deletions
@@ -66,7 +66,7 @@ export default async function QuestCharacterPage({ params }: { params: Promise<{
{o.link ? (
<a
href={wowheadUrl(o.link.type as WowheadType, o.link.id, locale)}
data-wowhead={wowheadData(o.link.type as WowheadType, o.link.id)}
data-wowhead={wowheadData(o.link.type as WowheadType, o.link.id, locale)}
target="_blank"
rel="noopener noreferrer"
className="icontinyl"
@@ -96,8 +96,8 @@ export default async function QuestCharacterPage({ params }: { params: Promise<{
<ul>
<li>
{t.rich('quest.hodir', {
hodir: (c) => <a href={wowheadUrl('faction', 1119, locale)} data-wowhead={wowheadData('faction', 1119)} target="_blank" rel="noopener noreferrer">{c}</a>,
lille: (c) => <a href={wowheadUrl('npc', 32540, locale)} data-wowhead={wowheadData('npc', 32540)} target="_blank" rel="noopener noreferrer">{c}</a>,
hodir: (c) => <a href={wowheadUrl('faction', 1119, locale)} data-wowhead={wowheadData('faction', 1119, locale)} target="_blank" rel="noopener noreferrer">{c}</a>,
lille: (c) => <a href={wowheadUrl('npc', 32540, locale)} data-wowhead={wowheadData('npc', 32540, locale)} target="_blank" rel="noopener noreferrer">{c}</a>,
})}
</li>
</ul>
+1 -1
View File
@@ -78,7 +78,7 @@ export function RecruitPanel({
<>
<a
href={wowheadUrl('item', r.item_id, locale)}
data-wowhead={wowheadData('item', r.item_id)}
data-wowhead={wowheadData('item', r.item_id, locale)}
target="_blank"
rel="noopener noreferrer"
className={`icontinyl ${quality || ''}`}
+1 -1
View File
@@ -25,7 +25,7 @@ export function WowheadLink({
return (
<a
href={wowheadUrl(type, id, locale)}
data-wowhead={wowheadData(type, id)}
data-wowhead={wowheadData(type, id, locale)}
target="_blank"
rel="noopener noreferrer"
className={className}
+18 -6
View File
@@ -43,10 +43,22 @@ export function wowheadIcon(name: string, size: IconSize = 'large'): string {
return `https://wow.zamimg.com/images/wow/icons/${size}/${name}.${ext}`
}
/**
* Valor del atributo `data-wowhead`, para que el script de tooltips lo reconozca
* con la rama WotLK aunque el href no baste (iconos, celdas sin enlace, etc.).
*/
export function wowheadData(type: WowheadType, id: number | string): string {
return `${type}=${id}&domain=wotlk`
// Código de idioma de wowhead para el parámetro `domain` del tooltip. El inglés
// es la base (sin prefijo). El script mapea el 1.er segmento a locale
// ({es:6,fr:2,de:3,...}) y el resto a la versión del juego (wotlk = WRATH).
const LOCALE_WH_CODE: Record<string, string> = { es: 'es' }
function wowheadDomain(locale: string): string {
const code = LOCALE_WH_CODE[locale]
return code ? `${code}.wotlk` : 'wotlk'
}
/**
* Valor del atributo `data-wowhead`, para que el tooltip salga en la rama WotLK
* y EN EL IDIOMA de la web. El `domain` lleva el idioma (p.ej. `es.wotlk`) porque
* el script prioriza este atributo sobre el subdominio del href; sin el idioma
* aquí, el tooltip saldría en inglés aunque el enlace sea es.wowhead.com.
*/
export function wowheadData(type: WowheadType, id: number | string, locale: string): string {
return `${type}=${id}&domain=${wowheadDomain(locale)}`
}