summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000g@gmail.com>2012-11-21 22:40:13 +0100
committerZolnai Tamás <zolnaitamas2000g@gmail.com>2012-11-21 22:52:13 +0100
commit9c4f31c168e12fc5432ebdd15f247c285358ffc8 (patch)
treea3ad2021ee916d5bb9ce42f84d839375de1c9e0d
parent8ae3ddca7e99d2bdbaadd5e0c82de2f0fbd30f91 (diff)
Get language id from path of po file
Language ids in po headers can be various so its simpler to extract from path. Change-Id: I3e9447359f3c054aea32b5417b2168025168c556
-rw-r--r--l10ntools/source/merge.cxx37
1 files changed, 17 insertions, 20 deletions
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index af2ebdc5e78e..3ff54009a036 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -39,7 +39,7 @@ namespace
static bool lcl_ReadPoChecked(
PoEntry& o_rPoEntry, PoIfstream& rPoFile,
- const std::string& rFileName)
+ const OString& rFileName)
{
try
{
@@ -51,7 +51,7 @@ namespace
{
printf(
"Warning : %s contains invalid entry\n",
- rFileName.c_str() );
+ rFileName.getStr() );
return false;
}
}
@@ -159,19 +159,20 @@ MergeDataFile::MergeDataFile(
printf("Warning : Can't open po path container file");
return;
}
- std::string sPoFileName;
- aInputStream >> sPoFileName;
+ std::string sPoFile;
+ aInputStream >> sPoFile;
bool bFirstLang = true;
while( !aInputStream.eof() )
{
const OString sHack("HACK");
const OString sFileName( lcl_NormalizeFilename(rFile) );
const bool bReadAll = sFileName.isEmpty();
+ const OString sPoFileName(sPoFile.data(), sPoFile.length());
PoIfstream aPoInput;
- aPoInput.open( OString(sPoFileName.data(), sPoFileName.length()) );
+ aPoInput.open( sPoFileName );
if ( !aPoInput.isOpen() )
{
- printf( "Warning : Can't open %s\n", sPoFileName.c_str() );
+ printf( "Warning : Can't open %s\n", sPoFileName.getStr() );
return;
}
PoHeader aPoHeader;
@@ -185,24 +186,20 @@ MergeDataFile::MergeDataFile(
{
printf(
"Warning : %s has invalid header\n",
- sPoFileName.c_str() );
+ sPoFileName.getStr() );
return;
}
}
+
OString sLang;
- try
- {
- sLang = aPoHeader.getLanguage().replaceAll("_","-");
- }
- catch( PoHeader::Exception& aException )
+ //Get language id from path
{
- if( aException == PoHeader::NOLANG )
- {
- printf(
- "Warning : %s' header not has language specification\n",
- sPoFileName.c_str() );
- return;
- }
+ const OString sTransSource("translations/source/");
+ const sal_Int32 nStart =
+ sPoFileName.indexOf(sTransSource)+sTransSource.getLength();
+ const sal_Int32 nCount =
+ sPoFileName.indexOf("/",nStart) - nStart;
+ sLang = sPoFileName.copy(nStart,nCount);
}
aLanguageSet.insert( sLang );
PoEntry aNextPo;
@@ -276,7 +273,7 @@ MergeDataFile::MergeDataFile(
}
}
aPoInput.close();
- aInputStream >> sPoFileName;
+ aInputStream >> sPoFile;
bFirstLang = false;
}
aInputStream.close();