Kaydet (Commit) b57f55cf authored tarafından Andras Timar's avatar Andras Timar

remove unused (and buggy) language fallback functionality

Fallback to en-US is done in translations module. Fallback to
other languages is not supported, but if we ever needed it, it
would be easier to solve the problem in a script language
instead of C++ in translations module.
üst e6a2e730
......@@ -181,7 +181,6 @@ public:
sal_uInt16 nTitleRefId;
ByteString sTextTyp;
ByteStringHashMap aFallbackData;
ByteStringHashMap aMergedLanguages;
ExportList *pStringList;
......@@ -193,8 +192,6 @@ public:
ByteString sPForm;
void Dump();
void addFallbackData( ByteString& sId , const ByteString& sText );
bool getFallbackData( ByteString& sId , ByteString& sText);
void addMergedLanguage(rtl::OString& rLang);
bool isMerged(rtl::OString& rLang);
......@@ -353,9 +350,6 @@ public:
static void getRandomName( const ByteString& sPrefix , ByteString& sRandStr , const ByteString& sPostfix );
static void getCurrentDir( std::string& dir );
static ByteString GetFallbackLanguage( const ByteString nLanguage );
static void FillInFallbacks( ResData *pResData );
static void FillInListFallbacks( ExportList *pList, const ByteString &nSource, const ByteString &nFallback );
static ByteString GetTimeStamp();
static sal_Bool ConvertLineEnds( ByteString sSource, ByteString sDestination );
static ByteString GetNativeFile( ByteString sSource );
......@@ -376,8 +370,6 @@ private:
ByteString FullId(); // creates cur. GID
bool PairedListFallback( ByteString& sText , ResData& aResData );
ByteString GetPairedListID ( const ByteString& sText );
ByteString GetPairedListString ( const ByteString& sText );
ByteString StripList ( const ByteString& sText );
......
......@@ -32,7 +32,6 @@
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
#include <memory> /* auto_ptr */
#include "tools/isofallback.hxx"
#define MOVEFILE_REPLACE_EXISTING 0x01
......@@ -44,10 +43,6 @@ private:
bool bUTF8;
bool bHasInputList;
/// Copy fallback language String (ENUS,DE) into position of the numeric language iso code
/// @PRECOND 0 < langIdx_in < MAX_IDX
static void FillInFallbacks( LangHashMap& rElem_out, ByteString sLangIdx_in );
#if OSL_DEBUG_LEVEL > 2
/// Debugmethod, prints the content of the map to stdout
static void Dump(LangHashMap* rElem_in , const ByteString sKey_in);
......
......@@ -53,7 +53,6 @@ private:
bool bQuiet;
std::vector<ByteString> aLanguages;
void FillInFallbacks( ByteStringHashMap Text );
bool isNextGroup( ByteString &sGroup_out , ByteString &sLine_in);
void ReadLine( const ByteString &sLine_in , ByteStringHashMap &rText_inout );
void WriteSDF( SvFileStream &aSDFStream , ByteStringHashMap &rText_inout ,
......
......@@ -36,7 +36,6 @@
#include "tools/string.hxx"
#define ENABLE_BYTESTRING_STREAM_OPERATORS
#include "tools/stream.hxx"
#include "tools/isofallback.hxx"
#include "export.hxx"
#include "xmlutil.hxx"
......
......@@ -188,10 +188,7 @@ main( int argc, char* argv[])
fprintf( stdout, " -g[:dtd]: enables generation of properties (dtds if :dtd is set) - in this case FileOut is the output path\n" );
fprintf( stdout, " -d: enables generation of *.don if work is done\n" );
fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
fprintf( stdout, " A fallback language can be defined like this: l1=f1.\n" );
fprintf( stdout, " f1, f2,... are also elements of (de,en-US...)\n" );
fprintf( stdout, " Example: -L de,es=en-US\n" );
fprintf( stdout, " Restriction to de and es, en-US will be fallback for es\n" );
return 1;
}
......
......@@ -350,14 +350,6 @@ void ResData::Dump(){
printf("\n");
}
void ResData::addFallbackData( ByteString& sId_in , const ByteString& sText_in ){
aFallbackData[ sId_in ] = sText_in;
}
bool ResData::getFallbackData( ByteString& sId_in , ByteString& sText_inout ){
sText_inout = aFallbackData[ sId_in ];
return sText_inout.Len() > 0;
}
void ResData::addMergedLanguage(rtl::OString& rLang)
{
aMergedLanguages[rLang] = rtl::OString(RTL_CONSTASCII_STRINGPARAM("1"));
......@@ -1169,8 +1161,6 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
( pResData->sTitle[ SOURCE_LANGUAGE ].getLength()))
{
FillInFallbacks( pResData );
ByteString sGID = pResData->sGId;
ByteString sLID;
if ( !sGID.Len())
......@@ -1255,7 +1245,6 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
}
}
}
FillInFallbacks( pResData );
if ( pResData->pStringList ) {
ByteString sList( "stringlist" );
WriteExportList( pResData, pResData->pStringList, sList, bCreateNew );
......@@ -1476,27 +1465,6 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine )
}else
(*pCurEntry)[ m_sListLang ] = rText;
// Remember en-US fallback string, so each list has the same amount of elements
if ( Export::isSourceLanguage( m_sListLang ) ) {
if( nList == LIST_PAIRED ){
const ByteString sPlist("pairedlist");
ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sId , GetPairedListID( rLine ) , sFilename );
pResData->addFallbackData( sKey , rText );
}
// new fallback
else{
const ByteString sPlist("list");
ByteString a( pResData->sGId );
a.Append( "." );
a.Append( pResData->sId );
sal_Int64 x = nListIndex+1;
ByteString b(rtl::OString::valueOf(x));
ByteString sKey = MergeDataFile::CreateKey( sPlist , a , b , sFilename );
pResData->addFallbackData( sKey , rText );
}
// new fallback
}
if ( Export::isSourceLanguage( m_sListLang ) ) {
if( nList == LIST_PAIRED ){
(*pCurEntry)[ SOURCE_LANGUAGE ] = rLine;
......@@ -1507,7 +1475,6 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine )
pList->NewSourceLanguageListEntry();
}
//printf("Export::InsertListEntry ResData.id = %s ResData.ListData = %s\n",pResData->sId.GetBuffer() ,(*pCurEntry)[ m_sListLang ].GetBuffer());
nListIndex++;
}
......@@ -2135,23 +2102,6 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
if( !bText )
bText = pEntrys->GetTransex3Text( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , sal_False );
// Use fallback, if data is missing in sdf file
if( !bText && bPairedList )
{
if( pResData->isMerged( sCur ) )
break;
const ByteString sPlist("pairedlist");
ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename );
bText = pResData->getFallbackData( sKey , sText );
}
else if ( !bText ) // new fallback
{
if( pResData->isMerged( sCur ) ) break;
const ByteString sPlist("list");
ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename );
bText = pResData->getFallbackData( sKey , sText );
} // new fallback
if ( bText && sText.Len())
{
if ( nIdx == 1 )
......
......@@ -30,7 +30,6 @@
#include "precompiled_l10ntools.hxx"
#include "export.hxx"
#include <tools/datetime.hxx>
#include <tools/isofallback.hxx>
#include <stdio.h>
#include <osl/time.h>
#include <osl/process.h>
......@@ -377,84 +376,6 @@ void Export::InitForcedLanguages( bool bMergeMode ){
}
}
/*****************************************************************************/
ByteString Export::GetFallbackLanguage( const ByteString nLanguage )
/*****************************************************************************/
{
rtl::OString sFallback=nLanguage;
GetIsoFallback( sFallback );
return sFallback;
}
/*****************************************************************************/
void Export::FillInFallbacks( ResData *pResData )
/*****************************************************************************/
{
for (size_t n = 0; n < aLanguages.size(); ++n)
{
ByteString sCur = aLanguages[ n ];
if (isAllowed(sCur))
{
ByteString nFallbackIndex = GetFallbackLanguage( sCur );
if( nFallbackIndex.Len() )
{
if (pResData->sText[ sCur ].isEmpty())
pResData->sText[ sCur ] =
pResData->sText[ nFallbackIndex ];
if (pResData->sHelpText[ sCur ].isEmpty())
pResData->sHelpText[ sCur ] =
pResData->sHelpText[ nFallbackIndex ];
if (pResData->sQuickHelpText[ sCur ].isEmpty())
pResData->sQuickHelpText[ sCur ] =
pResData->sQuickHelpText[ nFallbackIndex ];
if (!pResData->sTitle[ sCur ].isEmpty())
pResData->sTitle[ sCur ] =
pResData->sTitle[ nFallbackIndex ];
if ( pResData->pStringList )
FillInListFallbacks(
pResData->pStringList, sCur, nFallbackIndex );
if ( pResData->pPairedList )
FillInListFallbacks(
pResData->pPairedList, sCur, nFallbackIndex );
if ( pResData->pFilterList )
FillInListFallbacks(
pResData->pFilterList, sCur, nFallbackIndex );
if ( pResData->pItemList )
FillInListFallbacks(
pResData->pItemList, sCur, nFallbackIndex );
if ( pResData->pUIEntries )
FillInListFallbacks(
pResData->pUIEntries, sCur, nFallbackIndex );
}
}
}
}
/*****************************************************************************/
void Export::FillInListFallbacks(
ExportList *pList, const ByteString &nSource, const ByteString &nFallback )
/*****************************************************************************/
{
for (size_t i = 0; i < pList->size(); ++i)
{
ExportListEntry *pEntry = (*pList)[ i ];
if ( (*pEntry )[nSource].isEmpty() )
{
( *pEntry )[ nSource ] = ( *pEntry )[ nFallback ];
ByteString x = ( *pEntry )[ nSource ];
ByteString y = ( *pEntry )[ nFallback ];
}
}
}
/*****************************************************************************/
ByteString Export::GetTimeStamp()
/*****************************************************************************/
......
......@@ -181,10 +181,6 @@ void Help()
fprintf( stdout, " FileOut: Destination file (*.*)\n" );
fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (en-US,fr,de...)\n" );
fprintf( stdout, " A fallback language can be defined like this: l1=f1.\n" );
fprintf( stdout, " f1, f2,... are also elements of (en-US,fr,de...)\n" );
fprintf( stdout, " Example: -L fr=en-US\n" );
fprintf( stdout, " Restriction to fr, en-US will be fallback for fr\n" );
fprintf( stdout, " -LF: Force the creation of that languages\n" );
}
......
......@@ -48,38 +48,6 @@
#include <direct.h>
#endif
/*****************************************************************************/
void HelpParser::FillInFallbacks( LangHashMap& rElem_out, ByteString sLangIdx_in ){
/*****************************************************************************/
static const ByteString ENGLISH_LANGUAGECODE( "en-US" );
ByteString sCur;
XMLElement* pTmp = NULL;
XMLElement* pTmp2 = NULL;
sCur = sLangIdx_in;
rtl::OString sFallback( sCur );
GetIsoFallback( sFallback );
if( (rElem_out.find( sFallback ) != rElem_out.end()) && rElem_out[ sFallback ] != NULL ){
pTmp2 = rElem_out[ sFallback ];
pTmp = new XMLElement( *pTmp2 ) ; // Copy
pTmp->SetPos( pTmp2->GetPos()+1 );
pTmp->ChangeLanguageTag( String( sLangIdx_in , RTL_TEXTENCODING_ASCII_US) );
rElem_out[ sLangIdx_in ] = pTmp;
pTmp2 = NULL;
}
else if( (rElem_out.find( ENGLISH_LANGUAGECODE ) != rElem_out.end()) && rElem_out[ ENGLISH_LANGUAGECODE ] != NULL ){// No English
pTmp2 = rElem_out[ ENGLISH_LANGUAGECODE ];
pTmp = new XMLElement( *pTmp2 ) ; // Copy
pTmp->SetPos( pTmp2->GetPos()+1 );
pTmp->ChangeLanguageTag( String( sLangIdx_in , RTL_TEXTENCODING_ASCII_US) );
rElem_out[ sCur ] = pTmp;
pTmp2 = NULL;
}else{
fprintf(stdout,"ERROR: No Fallback found for language %s:\n",sCur.GetBuffer());
rElem_out[ sCur ]=new XMLElement(); // Use dummy element
}
}
#if OSL_DEBUG_LEVEL > 2
void HelpParser::Dump(XMLHashMap* rElem_in)
{
......@@ -201,10 +169,6 @@ bool HelpParser::CreateSDF(
for( unsigned int n = 0; n < aLanguages.size(); n++ )
{
sCur = aLanguages[ n ];
if(pElem->find( sCur )==pElem->end())
{
FillInFallbacks( *pElem , sCur );
}
pXMLElement = (*pElem)[ sCur ];
if( pXMLElement != NULL )
......
......@@ -159,10 +159,6 @@ void Help()
fprintf( stdout, " FileOut: Destination file (*.*)\n" );
fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
fprintf( stdout, " A fallback language can be defined like this: l1=f1.\n" );
fprintf( stdout, " f1, f2,... are also elements of (de,en-US...)\n" );
fprintf( stdout, " Example: -L de,es=en-US\n" );
fprintf( stdout, " Restriction to de and es, en-US will be fallback for es\n" );
}
/*****************************************************************************/
......
......@@ -85,23 +85,6 @@ LngParser::~LngParser()
delete pLines;
}
/*****************************************************************************/
void LngParser::FillInFallbacks( ByteStringHashMap Text )
/*****************************************************************************/
{
ByteString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
if( Export::isAllowed( sCur ) ){
ByteString sFallbackLang = Export::GetFallbackLanguage( sCur );
if( sFallbackLang.Len() ){
Text[ sCur ] = Text[ sFallbackLang ];
}
}
}
}
/*****************************************************************************/
sal_Bool LngParser::CreateSDF(
const ByteString &rSDFFile, const ByteString &rPrj,
......@@ -163,7 +146,6 @@ sal_Bool LngParser::CreateSDF(
if ( bExport ) {
ByteString sTimeStamp( Export::GetTimeStamp());
ByteString sCur;
FillInFallbacks( rText_inout );
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
ByteString sAct = rText_inout[ sCur ];
......
......@@ -273,10 +273,6 @@ main( int argc, char* argv[])
fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" );
fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
fprintf( stdout, " A fallback language can be defined like this: l1=f1.\n" );
fprintf( stdout, " f1, f2,... are also elements of (de,en-US...)\n" );
fprintf( stdout, " Example: -L de,es=en-US\n" );
fprintf( stdout, " Restriction to de and es, en-US will be fallback for es\n" );
return 1;
}
......
......@@ -193,10 +193,6 @@ main( int argc, char* argv[])
fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" );
fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US,es...)\n" );
fprintf( stdout, " A fallback language can be defined like this: l1=f1.\n" );
fprintf( stdout, " f1, f2,... are also elements of (de,en-US,es...)\n" );
fprintf( stdout, " Example: -L en-US,es=de\n" );
fprintf( stdout, " Restriction to es and en-US, de will be fallback for 99\n" );
return 1;
}
pFile = GetXrmFile();
......
......@@ -537,9 +537,6 @@ void XRMResExport::EndOfText(
(void) rCloseTag; // FIXME
if ( pResData && pOutputStream ) {
Export::FillInFallbacks( pResData );
ByteString sTimeStamp( Export::GetTimeStamp());
ByteString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment