diff options
-rw-r--r-- | l10ntools/source/uimerge.cxx | 98 | ||||
-rw-r--r-- | solenv/gbuild/UI.mk | 2 |
2 files changed, 71 insertions, 29 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) diff --git a/solenv/gbuild/UI.mk b/solenv/gbuild/UI.mk index e29fd1ab0058..cbf4bbed344b 100644 --- a/solenv/gbuild/UI.mk +++ b/solenv/gbuild/UI.mk @@ -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} |