Kaydet (Commit) c27b2e37 authored tarafından David Tardon's avatar David Tardon

let uiex produce more translations in one run

uiex differs from the other *ex tools in that translation for every
language must be in a standalone file, named after the language code. So
uiex should take an output _directory_ instead of a file.

Change-Id: If3ed966147c6d11d1fe85c484463f1bca4eec172
üst 58aca95a
......@@ -9,6 +9,8 @@
#include <sal/main.h>
#include <osl/file.hxx>
#include <rtl/strbuf.hxx>
#include <libexslt/exslt.h>
......@@ -125,22 +127,76 @@ namespace
}
return sReturn.makeStringAndClear();
}
bool lcl_MergeLang(
const MergeDataHashMap &rMap,
const rtl::OString &rLanguage,
const rtl::OString &rDestinationFile)
{
std::ofstream aDestination(
rDestinationFile.getStr(), std::ios_base::out | std::ios_base::trunc);
if (!aDestination.is_open()) {
return false;
}
aDestination << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
aDestination << "<t>\n";
for (MergeDataHashMap::const_iterator aI = rMap.begin(), aEnd = rMap.end(); aI != aEnd; ++aI)
{
if (aI->second->sGID.isEmpty())
continue;
PFormEntrys* pFoo = aI->second->GetPFormEntries();
rtl::OString sOut;
pFoo->GetText( sOut, STRING_TYP_TEXT, rLanguage );
if (sOut.isEmpty())
continue;
aDestination << " <e "
<< "g=\"" << aI->second->sGID.getStr() << "\" "
<< "i=\"" << aI->second->sLID.getStr() << "\">"
<< QuotHTML(sOut).getStr() << "</e>\n";
}
aDestination << "</t>";
aDestination.close();
return true;
}
}
bool Merge(
const rtl::OString &rSDFFile,
const rtl::OString &rSourceFile,
const rtl::OString &rDestinationFile)
const rtl::OString &rDestinationDir)
{
Export::InitLanguages( true );
std::ofstream aDestination(
rDestinationFile.getStr(), std::ios_base::out | std::ios_base::trunc);
if (!aDestination.is_open()) {
return false;
{
bool bDestinationIsDir(false);
const rtl::OUString aDestDir(rtl::OStringToOUString(rDestinationDir, RTL_TEXTENCODING_UTF8));
rtl::OUString aDestDirUrl;
if (osl::FileBase::E_None == osl::FileBase::getFileURLFromSystemPath(aDestDir, aDestDirUrl))
{
osl::DirectoryItem aTmp;
if (osl::DirectoryItem::E_None == osl::DirectoryItem::get(aDestDirUrl, aTmp))
{
osl::FileStatus aDestinationStatus(osl_FileStatus_Mask_Type);
if (osl::DirectoryItem::E_None == aTmp.getFileStatus(aDestinationStatus))
bDestinationIsDir = aDestinationStatus.isDirectory();
}
}
if (!bDestinationIsDir)
{
fprintf(stderr, "%s must be a directory\n", rDestinationDir.getStr());
return false;
}
}
aDestination << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
aDestination << "<t>\n";
Export::InitLanguages( true );
MergeDataFile aMergeDataFile( rSDFFile, rSourceFile, sal_False );
rtl::OString sTmp( Export::sLanguages );
......@@ -150,34 +206,20 @@ bool Merge(
std::vector<rtl::OString> aLanguages = Export::GetLanguages();
const MergeDataHashMap& rMap = aMergeDataFile.getMap();
const rtl::OString aDestinationDir(rDestinationDir + "/");
bool bResult = true;
for(size_t n = 0; n < aLanguages.size(); ++n)
{
rtl::OString sCur = aLanguages[ n ];
if (sCur.isEmpty() || sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")))
continue;
for (MergeDataHashMap::const_iterator aI = rMap.begin(), aEnd = rMap.end(); aI != aEnd; ++aI)
{
if (aI->second->sGID.isEmpty())
continue;
PFormEntrys* pFoo = aI->second->GetPFormEntries();
rtl::OString sOut;
pFoo->GetText( sOut, STRING_TYP_TEXT, sCur);
if (sOut.isEmpty())
continue;
aDestination << " <e "
<< "g=\"" << aI->second->sGID.getStr() << "\" "
<< "i=\"" << aI->second->sLID.getStr() << "\">"
<< QuotHTML(sOut).getStr() << "</e>\n";
}
const rtl::OString aDestinationFile(aDestinationDir + sCur + ".ui");
if (!lcl_MergeLang(rMap, sCur, aDestinationFile))
bResult = false;
}
aDestination << "</t>";
aDestination.close();
return sal_True;
return bResult;
}
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
......
......@@ -22,7 +22,7 @@ echo $(POFILES) > $${MERGEINPUT} && \
$(call gb_Helper_abbreviate_dirs,\
$(gb_UILocalizeTarget_COMMAND) \
-i $(UI_FILE) \
-o $(1) \
-o $(dir $(1)) \
-l $(UI_LANG) \
-m $${MERGEINPUT} ) && \
rm -rf $${MERGEINPUT}
......
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