Enable_Interface=True; local MyPanel; 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"; --DEFAULT_CHAT_FRAME:AddMessage("NPC"); Debug = false; --turn this when you want to compare trim english text with text database ------------------- --global function-- ------------------- local trim=function(text) if not text then return nil; end text = string.lower(text); text = gsub(text, "%s+", " "); text = gsub(text, "^%s+", ""); text = gsub(text, "%s+$", ""); text = gsub(text, " ", ""); return text; end local DoTranslate=function(text) local en = text; text = trim(text); for i=1, CZWOW_QuestTitle_count, 1 do if getglobal("CZWOW_QuestTitle_"..i)[text] then return getglobal("CZWOW_QuestTitle_"..i)[text]; end end for i=1, CZWOW_QuestObjective_count, 1 do if getglobal("CZWOW_QuestObjective_"..i)[text] then return getglobal("CZWOW_QuestObjective_"..i)[text]; end end for i=1, CZWOW_QuestDescription_count, 1 do if getglobal("CZWOW_QuestDescription_"..i)[text] then return getglobal("CZWOW_QuestDescription_"..i)[text]; end end for i=1, CZWOW_QuestProgress_count, 1 do if getglobal("CZWOW_QuestProgress_"..i)[text] then return getglobal("CZWOW_QuestProgress_"..i)[text]; end end for i=1, CZWOW_QuestReward_count, 1 do if getglobal("CZWOW_QuestReward_"..i)[text] then return getglobal("CZWOW_QuestReward_"..i)[text]; end end for i=1, CZWOW_NPCAction_count, 1 do if getglobal("CZWOW_NPCAction_"..i)[text] then return getglobal("CZWOW_NPCAction_"..i)[text]; end end for i=1, CZWOW_BookPage_count, 1 do if getglobal("CZWOW_BookPage_"..i)[text] then return getglobal("CZWOW_BookPage_"..i)[text]; end end for i=1, CZWOW_NPCText_count, 1 do if getglobal("CZWOW_NPCText_"..i)[text] then return getglobal("CZWOW_NPCText_"..i)[text]; end end for i=1, CZWOW_ItemName_count, 1 do if getglobal("CZWOW_ItemName_"..i)[text] then return getglobal("CZWOW_ItemName_"..i)[text]; end end for i=1, CZWOW_ItemDescription_count, 1 do if getglobal("CZWOW_ItemDescription_"..i)[text] then return getglobal("CZWOW_ItemDescription_"..i)[text]; end end for i=1, CZWOW_ObjectName_count, 1 do if getglobal("CZWOW_ObjectName_"..i)[text] then return getglobal("CZWOW_ObjectName_"..i)[text]; end end return en; end local Translate=function(text) if Debug then if (text == nil) then else print("Or: "..text); print("En: "..trim(text)); text = DoTranslate(text); print("Cz: "..text); return text; end else return DoTranslate(text); end end ------------------ --addon function-- ------------------ CzWoW_OnEvent=function(self, event, ...) if (event == "VARIABLES_LOADED") then CzWoW_OnLoadVar(); end if Debug then print (event); end end CzWoW_OnLoad=function(self) self:RegisterEvent("VARIABLES_LOADED"); -- self:RegisterEvent("PLAYER_ENTERING_WORLD"); -- self:RegisterEvent("COMBAT_LOG_EVENT"); self:RegisterEvent("ITEM_TEXT_TRANSLATION"); -- self:RegisterEvent("ITEM_TEXT_BEGIN"); -- self:RegisterEvent("ITEM_TEXT_CLOSED"); -- self:RegisterEvent("ITEM_PUSH"); -- self:RegisterEvent("SHOW_COMPARE_TOOLTIP"); self:RegisterEvent("OnTooltipSetItem"); self:RegisterEvent("QUEST_LOG_UPDATE"); GameTooltip:HookScript("OnUpdate",GameObjectChange); if(GameTooltip:GetScript("OnTooltipSetItem")) then GameTooltip:HookScript("OnTooltipSetItem",ItemChangeName); else GameTooltip:SetScript("OnTooltipSetItem",ItemChangeName); end for nn, tooltip in ipairs(TooltipList) do if tooltip then for _, methodName in ipairs(MethodList) do hooksecurefunc(tooltip, methodName, ItemChangeName); end end end end --------Translate item------------------ TooltipList = { ItemRefTooltip, GameTooltip, ShoppingTooltip1, ShoppingTooltip2, ComparisonTooltip1, ComparisonTooltip2, } MethodList = { "SetLootItem", "SetHyperlink", "SetBagItem", "SetInventoryItem", "SetAuctionItem", "SetAuctionSellItem", "SetLootRollItem", "SetTradeSkillItem", "SetTrainerService", "SetInboxItem", "SetSendMailItem", "SetQuestItem", "SetQuestLogItem", "SetTradePlayerItem", "SetTradeTargetItem", "SetMerchantItem", "SetHyperlinkCompareItem", "SetBuybackItem", } function TranslateTooltip(this) if this then local text = this:GetText(); for i=1, CZWOW_ItemName_count, 1 do if getglobal("CZWOW_ItemName_"..i)[trim(text)] then text = getglobal("CZWOW_ItemName_"..i)[trim(text)]; end end -- text = "bleble"; -- DEFAULT_CHAT_FRAME:AddMessage(text); this:SetText(text); end end function ItemChangeName(this) local name = "test ěščřžýáíéůú fsd fa"; if CZWOW_ItemName_count > 0 then TranslateTooltip(GameTooltipTextLeft1); TranslateTooltip(ItemRefTooltipTextLeft1); TranslateTooltip(ShoppingTooltip1TextLeft2); TranslateTooltip(ShoppingTooltip2TextLeft2); TranslateTooltip(ComparisonTooltip1TextLeft4); TranslateTooltip(ComparisonTooltip2TextLeft6); --/run end if CZWOW_ItemDescription_count > 0 then for i=1,GameTooltip:NumLines()do local mytext=_G["GameTooltipTextLeft"..i]; if "\"" == strsub(mytext:GetText(), 0,1) then local text = strsub(mytext:GetText(), 2,strlen(mytext:GetText())-2); text = text.."."; for i=1, CZWOW_ItemDescription_count, 1 do if getglobal("CZWOW_ItemDescription_"..i)[trim(text)] then text = getglobal("CZWOW_ItemDescription_"..i)[trim(text)]; end end mytext:SetText("\""..text.."\""); end end end this:Show(); end ---------item at vendor------ local old_MerchantFrame_UpdateMerchantInfo = MerchantFrame_UpdateMerchantInfo; function MerchantFrame_UpdateMerchantInfo() old_MerchantFrame_UpdateMerchantInfo(); local numMerchantItems = GetMerchantNumItems(); for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do local index = (((MerchantFrame.page - 1) * MERCHANT_ITEMS_PER_PAGE) + i); if ( index <= numMerchantItems ) then name, texture, price, quantity, numAvailable, isUsable, extendedCost = GetMerchantItemInfo(index); local text = name; for i=1, CZWOW_ItemName_count, 1 do if getglobal("CZWOW_ItemName_"..i)[trim(text)] then text = getglobal("CZWOW_ItemName_"..i)[trim(text)]; end end getglobal("MerchantItem"..i.."Name"):SetText(text); end end end -------item at loot-------------------- local old_LootFrame_Update = LootFrame_Update; function LootFrame_Update() old_LootFrame_Update(); local numLootItems = LootFrame.numLootItems; --Logic to determine how many items to show per page local numLootToShow = LOOTFRAME_NUMBUTTONS; if ( numLootItems > LOOTFRAME_NUMBUTTONS ) then numLootToShow = numLootToShow - 1; end local texture, item, quantity, quality; local button, countString, color; for index = 1, LOOTFRAME_NUMBUTTONS do local slot = (numLootToShow * (LootFrame.page - 1)) + index; texture, item, quantity, quality = GetLootSlotInfo(slot); local text = item; for i=1, CZWOW_ItemName_count, 1 do if getglobal("CZWOW_ItemName_"..i)[trim(text)] then text = getglobal("CZWOW_ItemName_"..i)[trim(text)]; end end getglobal("LootButton"..index.."Text"):SetText(text); end end ---------translate gameobject---------- function GameObjectChange(this) if 1 == GameTooltip:NumLines() or 2 == GameTooltip:NumLines() then if CZWOW_ObjectName_count > 0 then if GameTooltipTextLeft1 then for i=1, CZWOW_ObjectName_count, 1 do local text = GameTooltipTextLeft1:GetText(); if getglobal("CZWOW_ObjectName_"..i)[trim(text)] then GameTooltipTextLeft1:SetText(getglobal("CZWOW_ObjectName_"..i)[trim(text)]); end end GameTooltip:Show(); end; end end end CzWoW_OnLoadVar=function() SLASH_CZWOW1 = "/czwow"; SlashCmdList["CZWOW"]=CzWoW_CMD; DEFAULT_CHAT_FRAME:AddMessage(Load_text); if Enable_Interface then --načtení UI TranslateInterface(); end end CzWoW_CMD=function(msg) DEFAULT_CHAT_FRAME:AddMessage(Load_text); if msg == "help" then print("Nápověda pro nastavení překladového addonu") print("/czwow interface - pro povolení/zakázání překládání uživatelského rozhraní") end if msg == "config" then InterfaceOptionsFrame_OpenToCategory(MyPanel); end if msg == "debug" then Debug = not Debug; end if msg == "interface" then Enable_Interface = not Enable_Interface; if Enable_Interface then 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.") TranslateInterface(); else 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()") end end end function SC_ChaChingPanel_OnLoad(panel) panel.name = "CzWoW"; panel.okay = function (self) SC_ChaChingPanel_Close(); end; panel.cancel = function (self) SC_ChaChingPanel_CancelOrLoad(); end; InterfaceOptions_AddCategory(panel); MyPanel = panel; end ---------------------- --translate function-- ---------------------- CZWOW_OnUpdate=function() if GossipFrame:IsShown() then GossipFrameUpdate() end if QuestFrameProgressPanel:IsVisible() then QuestFrameProgressPanel_OnShow(); end if QuestFrameRewardPanel:IsVisible() then QuestFrameRewardPanel_OnShow(); end if ItemTextFrame:IsVisible() then ItemTextFrame_OnEvent(); end if ( QuestInfoFrame.questLog ) then QuestLog_Update(); end end --formuláře výprav u NPC QuestFrameProgressPanel_OnShow=function() if getglobal("CZWOW_QuestTitle_1")[trim(GetTitleText())] then QuestProgressTitleText:SetText(Translate(GetTitleText())); QuestProgressText:SetText(Translate(GetProgressText())); end end QuestFrameRewardPanel_OnShow=function() -- if getglobal("CZWOW_QuestTitle_1")[trim(GetTitleText())] then -- QuestRewardTitleText:SetText(Translate(GetTitleText())); -- QuestRewardText:SetText(Translate(GetRewardText())); -- end; end --konec formuláře výprav -- překládání textů questů u zadávání a v quest logu local old_QuestInfo_Display=QuestInfo_Display; QuestInfo_Display=function(...) old_QuestInfo_Display(...); if ( QuestInfoFrame.questLog ) then questTitle = GetQuestLogTitle(GetQuestLogSelection()); questDescription, questObjectives=GetQuestLogQuestText(); else questTitle = GetTitleText(); questDescription = GetQuestText(); questObjectives = GetObjectiveText(); end if getglobal("CZWOW_QuestTitle_1")[trim(questTitle)] then QuestInfoTitleHeader:SetText(Translate(questTitle)); QuestInfoRewardText:SetText(Translate(questLogTitleText)); QuestInfoDescriptionText:SetText(Translate(questDescription)); QuestInfoObjectivesText:SetText(Translate(questObjectives)); QuestInfoRewardText:SetText(Translate(GetRewardText())); end end --překládání titulů questů v seznamu questů local old_QuestLog_Update=QuestLog_Update; QuestLog_Update=function() old_QuestLog_Update(); local buttons = QuestLogScrollFrame.buttons; local numButtons = #buttons; local scrollOffset = HybridScrollFrame_GetOffset(QuestLogScrollFrame); local questIndex, questTitleTag, questNumGroupMates, questNormalText, questCheck; local title, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily; local partyMembersOnQuest, tempWidth, textWidth; for i=1, numButtons do local questLogTitle = buttons[i]; questIndex = i + scrollOffset; questLogTitle:SetID(questIndex); title, _, _, _, _, _, _, _ = GetQuestLogTitle(questIndex); if questLogTitle then questLogTitle:SetText(Translate(title)); end end end --konec questlog --Formuláře NPC postav local old_GossipFrameOptionsUpdate=GossipFrameOptionsUpdate; GossipFrameOptionsUpdate=function(...) if select("#", ...)>0 then old_GossipFrameOptionsUpdate(...); for i=1, NUMGOSSIPBUTTONS, 1 do titleButton=getglobal("GossipTitleButton" .. i); local en=titleButton:GetText(); titleButton:SetText(Translate(en)); GossipResize(titleButton); -- TODO: kontrolovat také s bez "The" end end end local old_GossipFrameUpdate=GossipFrameUpdate; GossipFrameUpdate=function() old_GossipFrameUpdate(); local en=GossipGreetingText:GetText(); GossipGreetingText:SetText(Translate(en)); end; local old_GossipFrameActiveQuestsUpdate=GossipFrameActiveQuestsUpdate; GossipFrameActiveQuestsUpdate=function(...) local titleButton; local titleIndex = 1; old_GossipFrameActiveQuestsUpdate(...); for i=1, select("#", ...), 3 do titleButton = _G["GossipTitleButton" .. titleIndex]; if getglobal("CZWOW_QuestTitle_1")[trim(select(i, ...))] then titleButton:SetText(Translate(select(i, ...))); end titleIndex = titleIndex + 1; end end local old_GossipFrameAvailableQuestsUpdate=GossipFrameAvailableQuestsUpdate; GossipFrameAvailableQuestsUpdate=function(...) local titleButton; local titleIndex = 1; old_GossipFrameAvailableQuestsUpdate(...); for i=1, select("#", ...), 3 do titleButton = _G["GossipTitleButton" .. titleIndex]; titleButton:SetText(Translate(select(i, ...))); titleIndex = titleIndex + 1; end end --konec formuláře NPC postav --page texty ItemTextFrame_OnEvent=function(self, event, ...) local en=ItemTextGetText(); ItemTextPageText:SetText(Translate(en)); end; --konec page texty