diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-04-20 09:20:31 +0200 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-04-21 18:57:17 +0200 |
commit | 36b3bcefcf13996610239f95b1dce9f291bde95d (patch) | |
tree | 4796801ca25a41422381fce137fee5c21f3fef64 /l10ntools/source/treemerge.cxx | |
parent | 8560c2df78072533007b84b31fc930b82191e9a3 (diff) |
Some changes in qtz handling
Executalbes, which work one language, generat qtz by own.
(stringex,helpex,treex,propex)
So these executables can generate qtz without po file
when use them with qtz, call them with "-m" flag without parameter.
Change-Id: I56c34db7151dc3ef0ce1c85ed607719e4cbb5e92
Diffstat (limited to 'l10ntools/source/treemerge.cxx')
-rw-r--r-- | l10ntools/source/treemerge.cxx | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/l10ntools/source/treemerge.cxx b/l10ntools/source/treemerge.cxx index d80203df459a..2870a2e7b5b9 100644 --- a/l10ntools/source/treemerge.cxx +++ b/l10ntools/source/treemerge.cxx @@ -153,25 +153,39 @@ namespace { if( !xmlStrcmp(pCurrent->name, pNodeName) ) { - if( pMergeDataFile ) + if( rLang != "en-US" ) { + OString sNewText; xmlChar* pID = xmlGetProp(pCurrent, (const xmlChar*)("id")); ResData aResData( helper::xmlStrToOString( pID ), static_cast<OString>(io_pSource->name) ); xmlFree( pID ); aResData.sResTyp = helper::xmlStrToOString( pNodeName ); - MergeEntrys* pEntrys = - pMergeDataFile->GetMergeEntrys( &aResData ); - if( pEntrys ) + if( pMergeDataFile ) + { + MergeEntrys* pEntrys = + pMergeDataFile->GetMergeEntrys( &aResData ); + if( pEntrys ) + { + pEntrys->GetText( sNewText, STRING_TYP_TEXT, rLang ); + } + } + else if( rLang == "qtz" ) + { + xmlChar* pText = xmlGetProp(pCurrent, (const xmlChar*)("title")); + const OString sOriginText = helper::xmlStrToOString(pText); + xmlFree( pText ); + sNewText = MergeEntrys::GetQTZText(aResData, sOriginText); + } + if( !sNewText.isEmpty() ) { - OString sNewText; - pEntrys->GetText( sNewText, STRING_TYP_TEXT, rLang ); xmlSetProp( pCurrent, (const xmlChar*)("title"), (const xmlChar*)(sNewText.getStr())); } } + lcl_MergeLevel( io_pSource, pCurrent, (const xmlChar *)("node"), pMergeDataFile, rLang, rXhpRoot ); @@ -242,32 +256,27 @@ void TreeParser::Merge( assert( m_bIsInitialized ); const xmlNodePtr pRootNode = xmlDocGetRootElement( m_pSource ); - if( m_sLang == "en-US" ) - { - lcl_MergeLevel( - m_pSource, pRootNode, (const xmlChar *)("help_section"), - 0, m_sLang, rXhpRoot ); - } - else + MergeDataFile* pMergeDataFile = 0; + if( m_sLang != "qtz" && m_sLang != "en-US" ) { - MergeDataFile aMergeDataFile( + pMergeDataFile = new MergeDataFile( rMergeSrc, static_cast<OString>( m_pSource->name ), false, false ); - const std::vector<OString> vLanguages = aMergeDataFile.GetLanguages(); - if( vLanguages.size()>=2 && - vLanguages[vLanguages[0]=="qtz" ? 1 : 0] != m_sLang ) + const std::vector<OString> vLanguages = pMergeDataFile->GetLanguages(); + if( vLanguages.size()>=1 && vLanguages[0] != m_sLang ) { std::cerr << "Treex error: given language conflicts with " << "language of Mergedata file: " << m_sLang.getStr() << " - " - << vLanguages[vLanguages[0]=="qtz" ? 1 : 0].getStr() << std::endl; + << vLanguages[0].getStr() << std::endl; return; } - lcl_MergeLevel( - m_pSource, pRootNode, (const xmlChar *)("help_section"), - &aMergeDataFile, m_sLang, rXhpRoot ); } + lcl_MergeLevel( + m_pSource, pRootNode, (const xmlChar *)("help_section"), + pMergeDataFile, m_sLang, rXhpRoot ); + delete pMergeDataFile; xmlSaveFile( rDestinationFile.getStr(), m_pSource ); xmlFreeDoc( m_pSource ); xmlCleanupParser(); |