Kelsidavis-WoWee/include/pipeline/wowee_localization.hpp
Kelsi 73323f0b9d feat(editor): add WLAN (Localization) — 123rd open format
Novel replacement for the per-language overlay tables
vanilla WoW carried as Locale_*.MPQ patches plus the
Spell.dbc / Item.dbc trailing 16-locale string columns.
Each entry binds one (originalKey, languageCode,
namespace) triple to its localized translation,
forming a per-language overlay applied AFTER any
per-format catalog has resolved its primary text.

Eleven languageCode values cover the canonical WoW
locales (enUS / enGB / deDE / esES / frFR / itIT /
koKR / ptBR / ruRU / zhCN / zhTW) plus Unknown=255 as
escape hatch. Eight namespace values segment the
lookup space (UI / Quest / Item / Spell / Creature /
Tooltip / Gossip / System) so a UI button "Cancel"
doesn't collide with an item description containing
the word "Cancel".

UTF-8 multibyte support is the novel demonstration —
the originalKey field is typically ASCII (English
canonical key), but localizedText holds Korean (취소),
Simplified Chinese (取消), or other non-Latin scripts.
The string-length-prefixed binary serialization
preserves byte-identical round-trip regardless of
encoding.

Three preset emitters: makeUIBasics (5 UI translations
of the "Cancel" button across deDE/frFR/esES/koKR/zhCN
including the Korean and Chinese multibyte UTF-8 strings),
makeQuestSample (3 entries — one quest title in
deDE/frFR/koKR illustrating the dotted-key convention
"QUEST.123.title"), makeTooltipSet (4 item-tooltip
strings in deDE+frFR — the high-volume client
localization use case).

Validator's most novel check is per-(originalKey,
languageCode, namespace) triple uniqueness — two
entries with all three matching would tie at runtime
when the locale-aware text layer looks up an override.
Plus the warning on empty localizedText (the override
would render blank — possibly worse than fallback to
the catalog default).

Format count 122 -> 123. CLI flag count 1283 -> 1288.
2026-05-10 03:13:28 -07:00

141 lines
5.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Localization catalog (.wlan) — novel
// replacement for the per-language overlay tables that
// vanilla WoW carried as Locale_*.MPQ patches plus the
// Spell.dbc / Item.dbc trailing 16-locale string
// columns. Each entry binds one (originalKey,
// languageCode, namespace) triple to its localized
// translation.
//
// Cross-references with previously-added formats:
// No catalog cross-references — WLAN is a pure
// string-table overlay applied AFTER any per-format
// catalog has resolved its primary text. The lookup
// path is: format-default text -> WLAN override (if
// client locale matches a WLAN entry) -> rendered
// text.
//
// Binary layout (little-endian):
// magic[4] = "WLAN"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// stringId (uint32)
// nameLen + name (English / catalog label)
// descLen + description (translator notes)
// languageCode (uint8) — enUS / enGB / deDE /
// esES / frFR / itIT /
// koKR / ptBR / ruRU /
// zhCN / zhTW
// namespace_ (uint8) — UI / Quest / Item /
// Spell / Creature /
// Tooltip / Gossip /
// System
// pad0 (uint8) / pad1 (uint8)
// keyLen + originalKey — lookup key (canonical
// form — usually the
// English source text
// or a dotted ID like
// "QUEST.123.title")
// locLen + localizedText — translation in the
// target language
// iconColorRGBA (uint32)
struct WoweeLocalization {
enum LanguageCode : uint8_t {
enUS = 0, // US English
enGB = 1, // UK English (variant of enUS for
// colour / armour / etc.)
deDE = 2, // German
esES = 3, // European Spanish
frFR = 4, // French
itIT = 5, // Italian
koKR = 6, // Korean
ptBR = 7, // Brazilian Portuguese
ruRU = 8, // Russian
zhCN = 9, // Simplified Chinese
zhTW = 10, // Traditional Chinese
Unknown = 255,
};
enum Namespace : uint8_t {
UI = 0, // button labels, menus
Quest = 1, // quest titles + objective
// text
Item = 2, // item names + descriptions
Spell = 3, // spell names + tooltips
Creature = 4, // creature display names
Tooltip = 5, // shared tooltip strings
Gossip = 6, // NPC gossip dialog
System = 7, // system messages /
// notifications
};
struct Entry {
uint32_t stringId = 0;
std::string name;
std::string description;
uint8_t languageCode = enUS;
uint8_t namespace_ = UI;
uint8_t pad0 = 0;
uint8_t pad1 = 0;
std::string originalKey;
std::string localizedText;
uint32_t iconColorRGBA = 0xFFFFFFFFu;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t stringId) const;
// Returns the localized override (if any) for a
// given (key, language, namespace) lookup. Used at
// every render-call by the locale-aware text layer.
const Entry* findOverride(const std::string& originalKey,
uint8_t languageCode,
uint8_t namespaceKind) const;
// Returns all entries in one language. Used by the
// per-language asset bundling step to package only
// the strings the client needs.
std::vector<const Entry*> findByLanguage(uint8_t languageCode) const;
};
class WoweeLocalizationLoader {
public:
static bool save(const WoweeLocalization& cat,
const std::string& basePath);
static WoweeLocalization load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-lan* variants.
//
// makeUIBasics — 5 UI-button strings translated
// to deDE/frFR/esES/koKR/zhCN
// (5 entries × 1 key — the
// "Cancel" button across 5
// languages).
// makeQuestSample — 3 entries — one quest title
// translated into deDE / frFR /
// koKR.
// makeTooltipSet — 4 item tooltip strings in
// deDE + frFR (high-volume use
// case for client localization).
static WoweeLocalization makeUIBasics(const std::string& catalogName);
static WoweeLocalization makeQuestSample(const std::string& catalogName);
static WoweeLocalization makeTooltipSet(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee