diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-12-26 23:12:38 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-01-06 10:57:51 +0100 |
commit | 46d0619b547a0decb6dfa8836d1ad63c90ef2f9a (patch) | |
tree | ccdda1b714df7d305221bd38dca88b8412717f0f /l10ntools | |
parent | 6242f8262f4d7ac15e9fe20da0e8d3475e9f5cf2 (diff) |
Transex3: modify src list localization/merge part
Avoid using numbers to identify the list items because
using numbers can lead to mixed translations. Use the
corresponding string instead.
Remove a hacky solution for mixed translations.
See: 95ea6cb21a7d7f4f163e642ba4b1e165a427a0d1
Change-Id: I6f1d48bf71fe2146f04f53c6b474dd7c0ce98678
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/inc/export.hxx | 6 | ||||
-rw-r--r-- | l10ntools/source/export.cxx | 93 |
2 files changed, 31 insertions, 68 deletions
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index 453ec518d072..d28df05798c2 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -160,12 +160,6 @@ private: void CleanValue( OString &rValue ); OString GetText(const OString &rSource, int nToken); - /** - Get all MergeEntrys for the ExportList identified by pResData - Check whether list can merge and load all needed MergeEntry from DataBase. - */ - bool GetAllMergeEntrysOfList(ResData *pResData, std::vector<MergeEntrys*>& o_vMergeEntrys); - void ResData2Output( MergeEntrys *pEntry, sal_uInt16 nType, const OString& rTextType ); void MergeRest( ResData *pResData ); void ConvertMergeContent( OString &rText ); diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index fd91eebcf9ff..5694edf53c58 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -1007,55 +1007,6 @@ void Export::ConvertExportContent( OString& rText ) rText = helper::unEscapeAll(rText,"\\n""\\t""\\\\""\\\"","\n""\t""\\""\""); } -bool Export::GetAllMergeEntrysOfList(ResData *pResData, std::vector<MergeEntrys*>& o_vMergeEntrys ) -{ - o_vMergeEntrys.clear(); - - if (!pResData->sGId.isEmpty()) - pResData->sGId = pResData->sGId + OString('.'); - pResData->sGId = pResData->sGId + pResData->sId; - - pResData->sResTyp = lcl_GetListTyp( nList, false ); - - const sal_uInt16 nMaxIndex = pResData->m_aList.size(); - /** - * Check whether count of listentries match with count - * of translated items. If not than write origin items - * to the list to avoid mixed translations - * (exclude pairedlist) - */ - if( nList != LIST_PAIRED ) - { - MergeEntrys* pEntrys; - // MergeData contains longer list - pResData->sId = OString::number(nMaxIndex+1); - pEntrys = pMergeDataFile->GetMergeEntrys( pResData ); - if ( pEntrys ) - return false; - // MergeData contains shorter list - pResData->sId = OString::number(nMaxIndex); - pEntrys = pMergeDataFile->GetMergeEntrys( pResData ); - if ( !pEntrys ) - return false; - pResData->sId = "1"; - } - - for( sal_uInt16 nLIndex = 1; nLIndex <= nMaxIndex; ++nLIndex ) - { - // Set matching pairedlist identifier - if ( nList == LIST_PAIRED ) - { - pResData->sId = GetPairedListID ( pResData->m_aList[ ( nLIndex ) -1 ] ); - } - else - pResData->sId = OString::number(nLIndex); - - MergeEntrys* pEntrys = pMergeDataFile->GetMergeEntrys( pResData ); - o_vMergeEntrys.push_back(pEntrys); - } - return true; - } - void Export::ResData2Output( MergeEntrys *pEntry, sal_uInt16 nType, const OString& rTextType ) { sal_Bool bAddSemicolon = sal_False; @@ -1134,13 +1085,17 @@ void Export::MergeRest( ResData *pResData ) OString sOldGId = pResData->sGId; OString sOldTyp = pResData->sResTyp; + // Set pResData so we can find the corresponding string + if (!pResData->sGId.isEmpty()) + pResData->sGId = pResData->sGId + OString('.'); + pResData->sGId = pResData->sGId + pResData->sId; + + pResData->sResTyp = lcl_GetListTyp( nList, false ); + OString sSpace; for ( sal_uInt16 i = 1; i < nLevel-1; i++ ) sSpace += "\t"; - std::vector<MergeEntrys*> vMergeEntryVector; - bool bTranslateList = GetAllMergeEntrysOfList(pResData, vMergeEntryVector); - OString sCur; for( unsigned int n = 0; n < aLanguages.size(); n++ ) { @@ -1180,17 +1135,31 @@ void Export::MergeRest( ResData *pResData ) } } - if( bTranslateList && nLIndex < vMergeEntryVector.size() && vMergeEntryVector[nLIndex] ) + // Set matching identifier + if ( nList == LIST_PAIRED ) { - OString sText; - bool bText = vMergeEntryVector[nLIndex]->GetText( sText, STRING_TYP_TEXT, sCur, sal_True ); - if ( bText && !sText.isEmpty() ) - { - ConvertMergeContent( sText ); - OString sPre = sLine.copy( 0 , sLine.indexOf('"') ); - OString sPost = sLine.copy( sLine.lastIndexOf('"') + 1 ); - sLine = sPre + sText + sPost; - } + pResData->sId = GetPairedListID ( sLine ); + } + else + { + pResData->sId = + sLine.copy( + sLine.indexOf('"')+1, + sLine.lastIndexOf('"')-sLine.indexOf('"')-1); + ConvertExportContent( pResData->sId ); + } + + MergeEntrys* pEntrys = pMergeDataFile->GetMergeEntrys( pResData ); + OString sText; + bool bText = pEntrys ? pEntrys->GetText( sText, STRING_TYP_TEXT, sCur, sal_True ) : false; + + if( bText && !sText.isEmpty()) + { + ConvertMergeContent( sText ); + sLine = + sLine.copy( 0 , sLine.indexOf('"') ) + + sText + + sLine.copy( sLine.lastIndexOf('"') + 1 ); } OString sText1( "\t" ); |