| 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 | local trim=function(text)
|
|---|
| 7 | if not text then
|
|---|
| 8 | return nil;
|
|---|
| 9 | end
|
|---|
| 10 | text = string.lower(text);
|
|---|
| 11 | text = gsub(text, "%s+", " ");
|
|---|
| 12 | text = gsub(text, "^%s+", "");
|
|---|
| 13 | text = gsub(text, "%s+$", "");
|
|---|
| 14 | return text;
|
|---|
| 15 | end
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | local Translate=function(text)
|
|---|
| 20 | local en = text;
|
|---|
| 21 | text = trim(text);
|
|---|
| 22 | for i=1, CZWOW_QuestTitle_count, 1 do
|
|---|
| 23 | if getglobal("CZWOW_QuestTitle_"..i)[text] then
|
|---|
| 24 | return getglobal("CZWOW_QuestTitle_"..i)[text];
|
|---|
| 25 | end
|
|---|
| 26 | end
|
|---|
| 27 | for i=1, CZWOW_QuestObjective_count, 1 do
|
|---|
| 28 | if getglobal("CZWOW_QuestObjective_"..i)[text] then
|
|---|
| 29 | return getglobal("CZWOW_QuestObjective_"..i)[text];
|
|---|
| 30 | end
|
|---|
| 31 | end
|
|---|
| 32 | for i=1, CZWOW_QuestDescription_count, 1 do
|
|---|
| 33 | if getglobal("CZWOW_QuestDescription_"..i)[text] then
|
|---|
| 34 | return getglobal("CZWOW_QuestDescription_"..i)[text];
|
|---|
| 35 | end
|
|---|
| 36 | end
|
|---|
| 37 | for i=1, CZWOW_QuestProgress_count, 1 do
|
|---|
| 38 | if getglobal("CZWOW_QuestProgress_"..i)[text] then
|
|---|
| 39 | return getglobal("CZWOW_QuestProgress_"..i)[text];
|
|---|
| 40 | end
|
|---|
| 41 | end
|
|---|
| 42 | for i=1, CZWOW_QuestReward_count, 1 do
|
|---|
| 43 | if getglobal("CZWOW_QuestReward_"..i)[text] then
|
|---|
| 44 | return getglobal("CZWOW_QuestReward_"..i)[text];
|
|---|
| 45 | end
|
|---|
| 46 | end
|
|---|
| 47 | for i=1, CZWOW_NPCAction_count, 1 do
|
|---|
| 48 | if getglobal("CZWOW_NPCAction_"..i)[text] then
|
|---|
| 49 | return getglobal("CZWOW_NPCAction_"..i)[text];
|
|---|
| 50 | end
|
|---|
| 51 | end
|
|---|
| 52 | for i=1, CZWOW_BookPage_count, 1 do
|
|---|
| 53 | if getglobal("CZWOW_BookPage_"..i)[text] then
|
|---|
| 54 | return getglobal("CZWOW_BookPage_"..i)[text];
|
|---|
| 55 | end
|
|---|
| 56 | end
|
|---|
| 57 | for i=1, CZWOW_NPCText_count, 1 do
|
|---|
| 58 | if getglobal("CZWOW_NPCText_"..i)[text] then
|
|---|
| 59 | return getglobal("CZWOW_NPCText_"..i)[text];
|
|---|
| 60 | end
|
|---|
| 61 | end
|
|---|
| 62 | return en;
|
|---|
| 63 | end
|
|---|
| 64 |
|
|---|
| 65 | function SC_ChaChingPanel_OnLoad(panel)
|
|---|
| 66 | panel.name = "CzWoW";
|
|---|
| 67 | panel.okay = function (self) SC_ChaChingPanel_Close(); end;
|
|---|
| 68 | panel.cancel = function (self) SC_ChaChingPanel_CancelOrLoad(); end;
|
|---|
| 69 | InterfaceOptions_AddCategory(panel);
|
|---|
| 70 | MyPanel = panel;
|
|---|
| 71 | end
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | CzWoW_OnLoad=function()
|
|---|
| 75 | SLASH_CZWOW1 = "/czwow";
|
|---|
| 76 | SlashCmdList["CZWOW"]=CzWoW_CMD;
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 | DEFAULT_CHAT_FRAME:AddMessage(Load_text);
|
|---|
| 80 |
|
|---|
| 81 | if Enable_Interface then
|
|---|
| 82 | --načtení UI
|
|---|
| 83 | TranslateInterface();
|
|---|
| 84 | end
|
|---|
| 85 |
|
|---|
| 86 | end
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | CzWoW_CMD=function(msg)
|
|---|
| 90 | DEFAULT_CHAT_FRAME:AddMessage(Load_text);
|
|---|
| 91 | if msg == "help" then
|
|---|
| 92 | print("Nápověda pro nastavení překladového addonu")
|
|---|
| 93 | print("/czwow interface - pro povolení/zakázání překládání uživatelského rozhraní")
|
|---|
| 94 | end
|
|---|
| 95 |
|
|---|
| 96 | if msg == "config" then
|
|---|
| 97 | InterfaceOptionsFrame_OpenToCategory(MyPanel);
|
|---|
| 98 | end
|
|---|
| 99 |
|
|---|
| 100 | if msg == "interface" then
|
|---|
| 101 | Enable_Interface = not Enable_Interface;
|
|---|
| 102 | if Enable_Interface then
|
|---|
| 103 | 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.")
|
|---|
| 104 | TranslateInterface();
|
|---|
| 105 | else
|
|---|
| 106 | 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()")
|
|---|
| 107 | end
|
|---|
| 108 | end
|
|---|
| 109 | end
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | CZWOW_OnUpdate=function()
|
|---|
| 113 |
|
|---|
| 114 | if QuestFrameProgressPanel:IsVisible() then QuestFrameProgressPanel_OnShow(); end
|
|---|
| 115 | if QuestFrameRewardPanel:IsVisible() then QuestFrameRewardPanel_OnShow(); end
|
|---|
| 116 | if ItemTextFrame:IsVisible() then ItemTextFrame_OnEvent(); end
|
|---|
| 117 | end
|
|---|
| 118 |
|
|---|
| 119 | --formuláře výprav u NPC
|
|---|
| 120 | QuestFrameProgressPanel_OnShow=function()
|
|---|
| 121 | if getglobal("CZWOW_QuestTitle_1")[trim(GetTitleText())] then
|
|---|
| 122 | QuestProgressTitleText:SetText(Translate(GetTitleText()));
|
|---|
| 123 | QuestProgressText:SetText(Translate(GetProgressText()));
|
|---|
| 124 | end
|
|---|
| 125 | end
|
|---|
| 126 |
|
|---|
| 127 | QuestFrameRewardPanel_OnShow=function()
|
|---|
| 128 | -- if getglobal("CZWOW_QuestTitle_1")[trim(GetTitleText())] then
|
|---|
| 129 | -- QuestRewardTitleText:SetText(Translate(GetTitleText()));
|
|---|
| 130 | -- QuestRewardText:SetText(Translate(GetRewardText()));
|
|---|
| 131 | -- end;
|
|---|
| 132 | end
|
|---|
| 133 | --konec formuláře výprav
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | -- překládání textů questů u zadávání a v quest logu
|
|---|
| 137 | local old_QuestInfo_Display=QuestInfo_Display;
|
|---|
| 138 | QuestInfo_Display=function(...)
|
|---|
| 139 | old_QuestInfo_Display(...);
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 | if ( QuestInfoFrame.questLog ) then
|
|---|
| 143 | questTitle = GetQuestLogTitle(GetQuestLogSelection());
|
|---|
| 144 | questDescription, questObjectives=GetQuestLogQuestText();
|
|---|
| 145 | else
|
|---|
| 146 | questTitle = GetTitleText();
|
|---|
| 147 | questDescription = GetQuestText();
|
|---|
| 148 | questObjectives = GetObjectiveText();
|
|---|
| 149 | end
|
|---|
| 150 |
|
|---|
| 151 | if getglobal("CZWOW_QuestTitle_1")[trim(questTitle)] then
|
|---|
| 152 | QuestInfoTitleHeader:SetText(Translate(questTitle));
|
|---|
| 153 | QuestInfoRewardText:SetText(Translate(questLogTitleText));
|
|---|
| 154 | QuestInfoDescriptionText:SetText(Translate(questDescription));
|
|---|
| 155 | QuestInfoObjectivesText:SetText(Translate(questObjectives));
|
|---|
| 156 | QuestInfoRewardText:SetText(Translate(GetRewardText()));
|
|---|
| 157 | end
|
|---|
| 158 | end
|
|---|
| 159 |
|
|---|
| 160 | --překládání titulů questů v seznamu questů
|
|---|
| 161 | local old_QuestLog_Update=QuestLog_Update;
|
|---|
| 162 | QuestLog_Update=function()
|
|---|
| 163 | old_QuestLog_Update();
|
|---|
| 164 | local buttons = QuestLogScrollFrame.buttons;
|
|---|
| 165 | local numButtons = #buttons;
|
|---|
| 166 | local scrollOffset = HybridScrollFrame_GetOffset(QuestLogScrollFrame);
|
|---|
| 167 |
|
|---|
| 168 | local questIndex, questTitleTag, questNumGroupMates, questNormalText, questCheck;
|
|---|
| 169 | local title, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily;
|
|---|
| 170 | local partyMembersOnQuest, tempWidth, textWidth;
|
|---|
| 171 | for i=1, numButtons do
|
|---|
| 172 | local questLogTitle = buttons[i];
|
|---|
| 173 | questIndex = i + scrollOffset;
|
|---|
| 174 | questLogTitle:SetID(questIndex);
|
|---|
| 175 | title, _, _, _, _, _, _, _ = GetQuestLogTitle(questIndex);
|
|---|
| 176 | if questLogTitle then questLogTitle:SetText(Translate(title)); end
|
|---|
| 177 | end
|
|---|
| 178 | end
|
|---|
| 179 | --konec questlog
|
|---|
| 180 |
|
|---|
| 181 | --Formuláře NPC postav
|
|---|
| 182 | local old_GossipFrameOptionsUpdate=GossipFrameOptionsUpdate;
|
|---|
| 183 | GossipFrameOptionsUpdate=function(...)
|
|---|
| 184 | if select("#", ...)>0 then
|
|---|
| 185 | old_GossipFrameOptionsUpdate(...);
|
|---|
| 186 | for i=1, NUMGOSSIPBUTTONS, 1 do
|
|---|
| 187 | titleButton=getglobal("GossipTitleButton" .. i);
|
|---|
| 188 | local en=trim(titleButton:GetText());
|
|---|
| 189 | if getglobal("CZWOW_NPCAction_1")[en] then
|
|---|
| 190 | titleButton:SetText(Translate(en));
|
|---|
| 191 | GossipResize(titleButton);
|
|---|
| 192 | end
|
|---|
| 193 | -- TODO: kontrolovat také s bez "The"
|
|---|
| 194 | end
|
|---|
| 195 | end
|
|---|
| 196 | end
|
|---|
| 197 |
|
|---|
| 198 | local old_GossipFrameUpdate=GossipFrameUpdate;
|
|---|
| 199 | GossipFrameUpdate=function()
|
|---|
| 200 | old_GossipFrameUpdate();
|
|---|
| 201 | local en=trim(GossipGreetingText:GetText());
|
|---|
| 202 | GossipGreetingText:SetText(Translate(en));
|
|---|
| 203 | end;
|
|---|
| 204 |
|
|---|
| 205 | local old_GossipFrameActiveQuestsUpdate=GossipFrameActiveQuestsUpdate;
|
|---|
| 206 | GossipFrameActiveQuestsUpdate=function(...)
|
|---|
| 207 | local titleButton;
|
|---|
| 208 | local titleIndex = 1;
|
|---|
| 209 | old_GossipFrameActiveQuestsUpdate(...);
|
|---|
| 210 | for i=1, select("#", ...), 3 do
|
|---|
| 211 | titleButton = _G["GossipTitleButton" .. titleIndex];
|
|---|
| 212 | if getglobal("CZWOW_QuestTitle_1")[trim(select(i, ...))] then
|
|---|
| 213 | titleButton:SetText(Translate(select(i, ...)));
|
|---|
| 214 | end
|
|---|
| 215 | titleIndex = titleIndex + 1;
|
|---|
| 216 | end
|
|---|
| 217 | end
|
|---|
| 218 |
|
|---|
| 219 | local old_GossipFrameAvailableQuestsUpdate=GossipFrameAvailableQuestsUpdate;
|
|---|
| 220 | GossipFrameAvailableQuestsUpdate=function(...)
|
|---|
| 221 | local titleButton;
|
|---|
| 222 | local titleIndex = 1;
|
|---|
| 223 | old_GossipFrameAvailableQuestsUpdate(...);
|
|---|
| 224 | for i=1, select("#", ...), 3 do
|
|---|
| 225 | titleButton = _G["GossipTitleButton" .. titleIndex];
|
|---|
| 226 | if getglobal("CZWOW_QuestTitle_1")[trim(select(i, ...))] then
|
|---|
| 227 | titleButton:SetText(Translate(select(i, ...)));
|
|---|
| 228 | end
|
|---|
| 229 | titleIndex = titleIndex + 1;
|
|---|
| 230 | end
|
|---|
| 231 | end
|
|---|
| 232 | --konec formuláře NPC postav
|
|---|
| 233 |
|
|---|
| 234 | --page texty
|
|---|
| 235 | ItemTextFrame_OnEvent=function(self, event, ...)
|
|---|
| 236 | local en=ItemTextGetText();
|
|---|
| 237 | if getglobal("CZWOW_BookPage_1")[trim(en)] then
|
|---|
| 238 | ItemTextPageText:SetText(Translate(en));
|
|---|
| 239 | end
|
|---|
| 240 | end;
|
|---|
| 241 | --konec page texty
|
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|