diff --git a/HISTORY b/HISTORY index 9dfed07..a83ec83 100644 --- a/HISTORY +++ b/HISTORY @@ -223,3 +223,4 @@ Version 0.3.0 Version 0.3.1 - Fixed hide root menu from a subview template +- Fixed translation of grids diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index 97db545..e0cd079 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -92,6 +92,18 @@ cTemplateViewGrid *cTemplateView::GetViewGrid(int gridID) { return hit->second; } +void cTemplateView::InitViewGridIterator(void) { + geIt = viewGrids.begin(); +} + +cTemplateViewGrid *cTemplateView::GetNextViewGrid(void) { + if (geIt == viewGrids.end()) + return NULL; + cTemplateViewGrid *viewGrid = geIt->second; + geIt++; + return viewGrid; +} + cTemplateViewList *cTemplateView::GetViewList(eViewList vl) { map < eViewList, cTemplateViewList* >::iterator hit = viewLists.find(vl); if (hit == viewLists.end()) @@ -415,6 +427,43 @@ void cTemplateView::Translate(void) { } } + //Translate ViewGrids + InitViewGridIterator(); + cTemplateViewGrid *viewGrid = NULL; + while(viewGrid = GetNextViewGrid()) { + viewGrid->InitIterator(); + cTemplatePixmap *pix = NULL; + while(pix = viewGrid->GetNextPixmap()) { + pix->InitIterator(); + cTemplateFunction *func = NULL; + while(func = pix->GetNextFunction()) { + if (func->GetType() == ftDrawText || func->GetType() == ftDrawTextBox) { + string text = func->GetParameter(ptText); + string translation; + bool translated = globals->Translate(text, translation); + if (translated) { + func->SetTranslatedText(translation); + } + } + if (func->GetType() == ftLoop) { + cTemplateLoopFunction *funcsLoop = dynamic_cast(func); + funcsLoop->InitIterator(); + cTemplateFunction *loopFunc = NULL; + while(loopFunc = funcsLoop->GetNextFunction()) { + if (loopFunc->GetType() == ftDrawText || loopFunc->GetType() == ftDrawTextBox) { + string text = loopFunc->GetParameter(ptText); + string translation; + bool translated = globals->Translate(text, translation); + if (translated) { + loopFunc->SetTranslatedText(translation); + } + } + } + } + } + } + } + //Translate Plugin Views for (map < string, map< int, cTemplateView*> >::iterator it = pluginViews.begin(); it != pluginViews.end(); it++) { map< int, cTemplateView*> plugViews = it->second; diff --git a/libtemplate/templateview.h b/libtemplate/templateview.h index 84bc9f1..fa55ba2 100644 --- a/libtemplate/templateview.h +++ b/libtemplate/templateview.h @@ -58,6 +58,7 @@ protected: //helpers to iterate data structures map < eViewElement, cTemplateViewElement* >::iterator veIt; map < eViewList, cTemplateViewList* >::iterator vlIt; + map < int, cTemplateViewGrid* >::iterator geIt; map < eSubView, cTemplateView* >::iterator svIt; vector< cTemplateViewTab* >::iterator vtIt; //helpers to check valid xml templates @@ -89,6 +90,8 @@ public: cTemplateViewElement *GetNextViewElement(void); //access view grids cTemplateViewGrid *GetViewGrid(int gridID); + void InitViewGridIterator(void); + cTemplateViewGrid *GetNextViewGrid(void); //access list elements cTemplateViewList *GetViewList(eViewList vl); void InitViewListIterator(void);