| 118 | } |
| 119 | |
| 120 | BOOL STranslator::LoadFromXml( pugi::xml_node xmlLang ) |
| 121 | { |
| 122 | wcscpy_s(m_szLangName,TR_MAX_NAME_LEN,xmlLang.attribute(L"name").value()); |
| 123 | |
| 124 | OLECHAR szIID[100] = { 0 }; |
| 125 | wcscpy(szIID,xmlLang.attribute(L"guid").value()); |
| 126 | |
| 127 | IIDFromString(szIID,&m_guid); |
| 128 | |
| 129 | int ctxCount=0; |
| 130 | xml_node nodeCtx=xmlLang.child(L"context"); |
| 131 | while(nodeCtx) |
| 132 | { |
| 133 | ctxCount++; |
| 134 | nodeCtx=nodeCtx.next_sibling(L"context"); |
| 135 | } |
| 136 | m_arrEntry->SetCount(ctxCount); |
| 137 | nodeCtx=xmlLang.child(L"context"); |
| 138 | for(int i=0;i<ctxCount;i++) |
| 139 | { |
| 140 | SASSERT(nodeCtx); |
| 141 | int strCount=0; |
| 142 | xml_node nodeStr=nodeCtx.child(L"message"); |
| 143 | while(nodeStr) |
| 144 | { |
| 145 | strCount++; |
| 146 | nodeStr=nodeStr.next_sibling(L"message"); |
| 147 | } |
| 148 | |
| 149 | SStrMapEntry * strMapEntry = new SStrMapEntry; |
| 150 | strMapEntry->strCtx=nodeCtx.attribute(L"name").value(); |
| 151 | strMapEntry->m_arrStrMap.SetCount(strCount); |
| 152 | nodeStr=nodeCtx.child(L"message"); |
| 153 | for(int j=0;j<strCount;j++) |
| 154 | { |
| 155 | SASSERT(nodeStr); |
| 156 | SStrMap * strMap= new SStrMap; |
| 157 | strMap->strSource=nodeStr.child(L"source").text().get(); |
| 158 | strMap->strTranslation=nodeStr.child(L"translation").text().get(); |
| 159 | strMapEntry->m_arrStrMap.SetAt(j,strMap); |
| 160 | nodeStr=nodeStr.next_sibling(L"message"); |
| 161 | } |
| 162 | qsort(strMapEntry->m_arrStrMap.GetData(),strMapEntry->m_arrStrMap.GetCount(),sizeof(SStrMap*),SStrMap::Compare); |
| 163 | m_arrEntry->SetAt(i,strMapEntry); |
| 164 | nodeCtx=nodeCtx.next_sibling(L"context"); |
| 165 | } |
| 166 | |
| 167 | qsort(m_arrEntry->GetData(),m_arrEntry->GetCount(),sizeof(SStrMapEntry*),SStrMapEntry::Compare); |
| 168 | |
| 169 | |
| 170 | //加载字体更换信息 |
| 171 | pugi::xml_node nodeFonts = xmlLang.child(L"fonts"); |
| 172 | pugi::xml_node nodeFont = nodeFonts.child(L"font"); |
| 173 | while(nodeFont) |
| 174 | { |
| 175 | SStringW strName = nodeFont.attribute(L"name").as_string(); |
| 176 | TrFontInfo info; |
| 177 | info.lfCharset =charsetFromString(nodeFont.attribute(L"charset").as_string()); |