| 1 | Enable_Interface=True;
|
|---|
| 2 | local MyPanel;
|
|---|
| 3 | local Load_text= "CzWoW načteno. Díky addonu by měl fungovat překlad výprav, NPC textů, textů knížek, rozhraní klienta, tutoriál, chybové hlášení uprostřed obrazovky. Pomoci překladu můžete na stránkách http://wowpreklad.zdechov.net/ Pro popis příkazů napiš příkaz /czwow help";
|
|---|
| 4 | --DEFAULT_CHAT_FRAME:AddMessage("NPC");
|
|---|
| 5 |
|
|---|
| 6 | Debug = false; --turn this when you want to compare trim english text with text database
|
|---|
| 7 |
|
|---|
| 8 | -------------------
|
|---|
| 9 | --global function--
|
|---|
| 10 | -------------------
|
|---|
| 11 |
|
|---|
| 12 | local trim=function(text)
|
|---|
| 13 | if not text then
|
|---|
| 14 | return nil;
|
|---|
| 15 | end
|
|---|
| 16 | text = string.lower(text);
|
|---|
| 17 | text = gsub(text, "%s+", " ");
|
|---|
| 18 | text = gsub(text, "^%s+", "");
|
|---|
| 19 | text = gsub(text, "%s+$", "");
|
|---|
| 20 | return text;
|
|---|
| 21 | end
|
|---|
| 22 |
|
|---|
| 23 | local DoTranslate=function(text)
|
|---|
| 24 | local en = text;
|
|---|
| 25 | text = trim(text);
|
|---|
| 26 | for i=1, CZWOW_QuestTitle_count, 1 do
|
|---|
| 27 | if getglobal("CZWOW_QuestTitle_"..i)[text] then
|
|---|
| 28 | return getglobal("CZWOW_QuestTitle_"..i)[text];
|
|---|
| 29 | end
|
|---|
| 30 | end
|
|---|
| 31 | for i=1, CZWOW_QuestObjective_count, 1 do
|
|---|
| 32 | if getglobal("CZWOW_QuestObjective_"..i)[text] then
|
|---|
| 33 | return getglobal("CZWOW_QuestObjective_"..i)[text];
|
|---|
| 34 | end
|
|---|
| 35 | end
|
|---|
| 36 | for i=1, CZWOW_QuestDescription_count, 1 do
|
|---|
| 37 | if getglobal("CZWOW_QuestDescription_"..i)[text] then
|
|---|
| 38 | return getglobal("CZWOW_QuestDescription_"..i)[text];
|
|---|
| 39 | end
|
|---|
| 40 | end
|
|---|
| 41 | for i=1, CZWOW_QuestProgress_count, 1 do
|
|---|
| 42 | if getglobal("CZWOW_QuestProgress_"..i)[text] then
|
|---|
| 43 | return getglobal("CZWOW_QuestProgress_"..i)[text];
|
|---|
| 44 | end
|
|---|
| 45 | end
|
|---|
| 46 | for i=1, CZWOW_QuestReward_count, 1 do
|
|---|
| 47 | if getglobal("CZWOW_QuestReward_"..i)[text] then
|
|---|
| 48 | return getglobal("CZWOW_QuestReward_"..i)[text];
|
|---|
| 49 | end
|
|---|
| 50 | end
|
|---|
| 51 | for i=1, CZWOW_NPCAction_count, 1 do
|
|---|
| 52 | if getglobal("CZWOW_NPCAction_"..i)[text] then
|
|---|
| 53 | return getglobal("CZWOW_NPCAction_"..i)[text];
|
|---|
| 54 | end
|
|---|
| 55 | end
|
|---|
| 56 | for i=1, CZWOW_BookPage_count, 1 do
|
|---|
| 57 | if getglobal("CZWOW_BookPage_"..i)[text] then
|
|---|
| 58 | return getglobal("CZWOW_BookPage_"..i)[text];
|
|---|
| 59 | end
|
|---|
| 60 | end
|
|---|
| 61 | for i=1, CZWOW_NPCText_count, 1 do
|
|---|
| 62 | if getglobal("CZWOW_NPCText_"..i)[text] then
|
|---|
| 63 | return getglobal("CZWOW_NPCText_"..i)[text];
|
|---|
| 64 | end
|
|---|
| 65 | end
|
|---|
| 66 | return en;
|
|---|
| 67 |
|
|---|
| 68 | end
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | local Translate=function(text)
|
|---|
| 73 | if Debug then
|
|---|
| 74 | if (text == nil) then else
|
|---|
| 75 | print("En: "..trim(text));
|
|---|
| 76 | text = DoTranslate(text);
|
|---|
| 77 | print("Cz: "..text);
|
|---|
| 78 | return text;
|
|---|
| 79 | end
|
|---|
| 80 | else
|
|---|
| 81 | return DoTranslate(text);
|
|---|
| 82 | end
|
|---|
| 83 | end
|
|---|
| 84 |
|
|---|
| 85 | ------------------
|
|---|
| 86 | --addon function--
|
|---|
| 87 | ------------------
|
|---|
| 88 |
|
|---|
| 89 | CzWoW_OnEvent=function(self, event, ...)
|
|---|
| 90 | if (event == "VARIABLES_LOADED") then
|
|---|
| 91 | CzWoW_OnLoadVar();
|
|---|
| 92 | end
|
|---|
| 93 | if Debug then print (event); end
|
|---|
| 94 |
|
|---|
| 95 | end
|
|---|
| 96 |
|
|---|
| 97 | CzWoW_OnLoad=function(self)
|
|---|
| 98 |
|
|---|
| 99 | self:RegisterEvent("VARIABLES_LOADED");
|
|---|
| 100 | -- self:RegisterEvent("PLAYER_ENTERING_WORLD");
|
|---|
| 101 | -- self:RegisterEvent("COMBAT_LOG_EVENT");
|
|---|
| 102 | self:RegisterEvent("ITEM_TEXT_TRANSLATION");
|
|---|
| 103 | -- self:RegisterEvent("ITEM_TEXT_BEGIN");
|
|---|
| 104 | -- self:RegisterEvent("ITEM_TEXT_CLOSED");
|
|---|
| 105 | -- self:RegisterEvent("ITEM_PUSH");
|
|---|
| 106 | -- self:RegisterEvent("SHOW_COMPARE_TOOLTIP");
|
|---|
| 107 | self:RegisterEvent("OnTooltipSetItem");
|
|---|
| 108 |
|
|---|
| 109 | if(GameTooltip:GetScript("OnTooltipSetItem")) then
|
|---|
| 110 | GameTooltip:HookScript("OnTooltipSetItem",ItemChangeName);
|
|---|
| 111 | else
|
|---|
| 112 | GameTooltip:SetScript("OnTooltipSetItem",ItemChangeName);
|
|---|
| 113 | end
|
|---|
| 114 |
|
|---|
| 115 | end
|
|---|
| 116 |
|
|---|
| 117 | function ItemChangeName(this)
|
|---|
| 118 | local name,link = this:GetItem();
|
|---|
| 119 | -- this:SetText("Fs");
|
|---|
| 120 | -- this:UpdateTooltip(this);
|
|---|
| 121 | -- this:SetText("Fa");
|
|---|
| 122 |
|
|---|
| 123 | -- this:AddLine("Item name: "..name);
|
|---|
| 124 | -- this:Show();
|
|---|
| 125 | end
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 | CzWoW_OnLoadVar=function()
|
|---|
| 129 | SLASH_CZWOW1 = "/czwow";
|
|---|
| 130 | SlashCmdList["CZWOW"]=CzWoW_CMD;
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | DEFAULT_CHAT_FRAME:AddMessage(Load_text);
|
|---|
| 134 |
|
|---|
| 135 | if Enable_Interface then
|
|---|
| 136 | --načtení UI
|
|---|
| 137 | TranslateInterface();
|
|---|
| 138 | end
|
|---|
| 139 |
|
|---|
| 140 | end
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 | CzWoW_CMD=function(msg)
|
|---|
| 144 | DEFAULT_CHAT_FRAME:AddMessage(Load_text);
|
|---|
| 145 | if msg == "help" then
|
|---|
| 146 | print("Nápověda pro nastavení překladového addonu")
|
|---|
| 147 | print("/czwow interface - pro povolení/zakázání překládání uživatelského rozhraní")
|
|---|
| 148 | end
|
|---|
| 149 |
|
|---|
| 150 | if msg == "config" then
|
|---|
| 151 | InterfaceOptionsFrame_OpenToCategory(MyPanel);
|
|---|
| 152 | end
|
|---|
| 153 |
|
|---|
| 154 | if msg == "debug" then
|
|---|
| 155 | Debug = not Debug;
|
|---|
| 156 | end
|
|---|
| 157 |
|
|---|
| 158 | if msg == "interface" then
|
|---|
| 159 | Enable_Interface = not Enable_Interface;
|
|---|
| 160 | if Enable_Interface then
|
|---|
| 161 | print("Nyní bylo povoleno překládání rozhraní clienta, může se projevit nestabilita wow. Pokud k tomu bude docházet doporučuji zakázat.")
|
|---|
| 162 | TranslateInterface();
|
|---|
| 163 | else
|
|---|
| 164 | print("Nyní bylo zakázáno překládání rozhraní clienta. Aby se změny projevily je zapotřebí restart wow, nebo znovunačtení uživatelského rozhraní, které se prování příkazem: /run ReloadUI()")
|
|---|
| 165 | end
|
|---|
| 166 | end
|
|---|
| 167 | end
|
|---|
| 168 |
|
|---|
| 169 | function SC_ChaChingPanel_OnLoad(panel)
|
|---|
| 170 | panel.name = "CzWoW";
|
|---|
| 171 | panel.okay = function (self) SC_ChaChingPanel_Close(); end;
|
|---|
| 172 | panel.cancel = function (self) SC_ChaChingPanel_CancelOrLoad(); end;
|
|---|
| 173 | InterfaceOptions_AddCategory(panel);
|
|---|
| 174 | MyPanel = panel;
|
|---|
| 175 | end
|
|---|
| 176 |
|
|---|
| 177 | ----------------------
|
|---|
| 178 | --translate function--
|
|---|
| 179 | ----------------------
|
|---|
| 180 |
|
|---|
| 181 | CZWOW_OnUpdate=function()
|
|---|
| 182 | if GossipFrame:IsShown() then GossipFrameUpdate() end
|
|---|
| 183 | if QuestFrameProgressPanel:IsVisible() then QuestFrameProgressPanel_OnShow(); end
|
|---|
| 184 | if QuestFrameRewardPanel:IsVisible() then QuestFrameRewardPanel_OnShow(); end
|
|---|
| 185 | if ItemTextFrame:IsVisible() then ItemTextFrame_OnEvent(); end
|
|---|
| 186 | end
|
|---|
| 187 |
|
|---|
| 188 | --formuláře výprav u NPC
|
|---|
| 189 | QuestFrameProgressPanel_OnShow=function()
|
|---|
| 190 | if getglobal("CZWOW_QuestTitle_1")[trim(GetTitleText())] then
|
|---|
| 191 | QuestProgressTitleText:SetText(Translate(GetTitleText()));
|
|---|
| 192 | QuestProgressText:SetText(Translate(GetProgressText()));
|
|---|
| 193 | end
|
|---|
| 194 | end
|
|---|
| 195 |
|
|---|
| 196 | QuestFrameRewardPanel_OnShow=function()
|
|---|
| 197 | -- if getglobal("CZWOW_QuestTitle_1")[trim(GetTitleText())] then
|
|---|
| 198 | -- QuestRewardTitleText:SetText(Translate(GetTitleText()));
|
|---|
| 199 | -- QuestRewardText:SetText(Translate(GetRewardText()));
|
|---|
| 200 | -- end;
|
|---|
| 201 | end
|
|---|
| 202 | --konec formuláře výprav
|
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 | -- překládání textů questů u zadávání a v quest logu
|
|---|
| 206 | local old_QuestInfo_Display=QuestInfo_Display;
|
|---|
| 207 | QuestInfo_Display=function(...)
|
|---|
| 208 | old_QuestInfo_Display(...);
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 | if ( QuestInfoFrame.questLog ) then
|
|---|
| 212 | questTitle = GetQuestLogTitle(GetQuestLogSelection());
|
|---|
| 213 | questDescription, questObjectives=GetQuestLogQuestText();
|
|---|
| 214 | else
|
|---|
| 215 | questTitle = GetTitleText();
|
|---|
| 216 | questDescription = GetQuestText();
|
|---|
| 217 | questObjectives = GetObjectiveText();
|
|---|
| 218 | end
|
|---|
| 219 |
|
|---|
| 220 | if getglobal("CZWOW_QuestTitle_1")[trim(questTitle)] then
|
|---|
| 221 | QuestInfoTitleHeader:SetText(Translate(questTitle));
|
|---|
| 222 | QuestInfoRewardText:SetText(Translate(questLogTitleText));
|
|---|
| 223 | QuestInfoDescriptionText:SetText(Translate(questDescription));
|
|---|
| 224 | QuestInfoObjectivesText:SetText(Translate(questObjectives));
|
|---|
| 225 | QuestInfoRewardText:SetText(Translate(GetRewardText()));
|
|---|
| 226 | end
|
|---|
| 227 | end
|
|---|
| 228 |
|
|---|
| 229 | --překládání titulů questů v seznamu questů
|
|---|
| 230 | local old_QuestLog_Update=QuestLog_Update;
|
|---|
| 231 | QuestLog_Update=function()
|
|---|
| 232 | old_QuestLog_Update();
|
|---|
| 233 | local buttons = QuestLogScrollFrame.buttons;
|
|---|
| 234 | local numButtons = #buttons;
|
|---|
| 235 | local scrollOffset = HybridScrollFrame_GetOffset(QuestLogScrollFrame);
|
|---|
| 236 |
|
|---|
| 237 | local questIndex, questTitleTag, questNumGroupMates, questNormalText, questCheck;
|
|---|
| 238 | local title, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily;
|
|---|
| 239 | local partyMembersOnQuest, tempWidth, textWidth;
|
|---|
| 240 | for i=1, numButtons do
|
|---|
| 241 | local questLogTitle = buttons[i];
|
|---|
| 242 | questIndex = i + scrollOffset;
|
|---|
| 243 | questLogTitle:SetID(questIndex);
|
|---|
| 244 | title, _, _, _, _, _, _, _ = GetQuestLogTitle(questIndex);
|
|---|
| 245 | if questLogTitle then questLogTitle:SetText(Translate(title)); end
|
|---|
| 246 | end
|
|---|
| 247 | end
|
|---|
| 248 | --konec questlog
|
|---|
| 249 |
|
|---|
| 250 | --Formuláře NPC postav
|
|---|
| 251 | local old_GossipFrameOptionsUpdate=GossipFrameOptionsUpdate;
|
|---|
| 252 | GossipFrameOptionsUpdate=function(...)
|
|---|
| 253 | if select("#", ...)>0 then
|
|---|
| 254 | old_GossipFrameOptionsUpdate(...);
|
|---|
| 255 | for i=1, NUMGOSSIPBUTTONS, 1 do
|
|---|
| 256 | titleButton=getglobal("GossipTitleButton" .. i);
|
|---|
| 257 | local en=trim(titleButton:GetText());
|
|---|
| 258 | if getglobal("CZWOW_NPCAction_1")[en] then
|
|---|
| 259 | titleButton:SetText(Translate(en));
|
|---|
| 260 | GossipResize(titleButton);
|
|---|
| 261 | end
|
|---|
| 262 | -- TODO: kontrolovat také s bez "The"
|
|---|
| 263 | end
|
|---|
| 264 | end
|
|---|
| 265 | end
|
|---|
| 266 |
|
|---|
| 267 | local old_GossipFrameUpdate=GossipFrameUpdate;
|
|---|
| 268 | GossipFrameUpdate=function()
|
|---|
| 269 | old_GossipFrameUpdate();
|
|---|
| 270 | local en=trim(GossipGreetingText:GetText());
|
|---|
| 271 | GossipGreetingText:SetText(Translate(en));
|
|---|
| 272 | end;
|
|---|
| 273 |
|
|---|
| 274 | local old_GossipFrameActiveQuestsUpdate=GossipFrameActiveQuestsUpdate;
|
|---|
| 275 | GossipFrameActiveQuestsUpdate=function(...)
|
|---|
| 276 | local titleButton;
|
|---|
| 277 | local titleIndex = 1;
|
|---|
| 278 | old_GossipFrameActiveQuestsUpdate(...);
|
|---|
| 279 | for i=1, select("#", ...), 3 do
|
|---|
| 280 | titleButton = _G["GossipTitleButton" .. titleIndex];
|
|---|
| 281 | if getglobal("CZWOW_QuestTitle_1")[trim(select(i, ...))] then
|
|---|
| 282 | titleButton:SetText(Translate(select(i, ...)));
|
|---|
| 283 | end
|
|---|
| 284 | titleIndex = titleIndex + 1;
|
|---|
| 285 | end
|
|---|
| 286 | end
|
|---|
| 287 |
|
|---|
| 288 | local old_GossipFrameAvailableQuestsUpdate=GossipFrameAvailableQuestsUpdate;
|
|---|
| 289 | GossipFrameAvailableQuestsUpdate=function(...)
|
|---|
| 290 | local titleButton;
|
|---|
| 291 | local titleIndex = 1;
|
|---|
| 292 | old_GossipFrameAvailableQuestsUpdate(...);
|
|---|
| 293 | for i=1, select("#", ...), 3 do
|
|---|
| 294 | titleButton = _G["GossipTitleButton" .. titleIndex];
|
|---|
| 295 | if getglobal("CZWOW_QuestTitle_1")[trim(select(i, ...))] then
|
|---|
| 296 | titleButton:SetText(Translate(select(i, ...)));
|
|---|
| 297 | end
|
|---|
| 298 | titleIndex = titleIndex + 1;
|
|---|
| 299 | end
|
|---|
| 300 | end
|
|---|
| 301 | --konec formuláře NPC postav
|
|---|
| 302 |
|
|---|
| 303 | --page texty
|
|---|
| 304 | ItemTextFrame_OnEvent=function(self, event, ...)
|
|---|
| 305 | local en=ItemTextGetText();
|
|---|
| 306 | if getglobal("CZWOW_BookPage_1")[trim(en)] then
|
|---|
| 307 | ItemTextPageText:SetText(Translate(en));
|
|---|
| 308 | end
|
|---|
| 309 | end;
|
|---|
| 310 | --konec page texty
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|