summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2012-12-26 15:40:21 +0100
committerDavid Tardon <dtardon@redhat.com>2012-12-27 17:16:51 +0100
commitc27b2e377f612de2476ff0aa0ddc909ff214fcb2 (patch)
tree229e8100913a8574098bdd2ea314cd762b825479 /l10ntools
parent58aca95aab6a4023468c14078aad771e49d0c103 (diff)
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
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/source/uimerge.cxx98
1 files changed, 70 insertions, 28 deletions
diff --git a/l10ntools/source/uimerge.cxx b/l10ntools/source/uimerge.cxx
index 4da18b7247b6..7b7d315006c6 100644
--- a/l10ntools/source/uimerge.cxx
+++ b/l10ntools/source/uimerge.cxx
@@ -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)