l10ntools/source/uimerge.cxx | 98 +++++++++++++++++------- solenv/gbuild/TargetLocations.mk | 5 - solenv/gbuild/UI.mk | 154 +++++++++++++-------------------------- 3 files changed, 127 insertions(+), 130 deletions(-)
New commits: commit 7e1c81e53d436407cae7f8ac915650839ec6d069 Author: David Tardon <[email protected]> Date: Thu Dec 27 16:11:29 2012 +0100 fix delivery of qtz "translations" Change-Id: I2f0ae1eff5bd009a7cb467b38c1743eff51dc563 (cherry picked from commit f45a07d6f4eefc75d983d7aca2b57d075749b4e7) Signed-off-by: David Tardon <[email protected]> diff --git a/solenv/gbuild/UI.mk b/solenv/gbuild/UI.mk index b56c858..00572b0 100644 --- a/solenv/gbuild/UI.mk +++ b/solenv/gbuild/UI.mk @@ -17,6 +17,19 @@ gb_UILocalizeTarget_TARGET := $(call gb_Executable_get_target_for_build,uiex) gb_UILocalizeTarget_COMMAND := $(gb_Helper_set_ld_path) $(gb_UILocalizeTarget_TARGET) gb_UILocalizeTarget_LANGS := $(filter-out qtz,$(filter-out en-US,$(gb_WITH_LANG))) +# If translatable strings from a .ui file are not merged into the +# respective .po file yet, the produced translated files are empty (that +# is, they only contain the root element), but qtz is not created at all +# which breaks delivery. This hack avoids the problem by creating a +# dummy translation file. +define gb_UILocalizeTarget__fix_missing_qtz +$(if $(filter qtz,$(gb_WITH_LANG)),\ + && if [ ! -f $(1)/qtz.ui ]; then \ + echo '<?xml version="1.0"?><t></t>' > $(1)/qtz.ui; \ + fi \ +) +endef + define gb_UILocalizeTarget__command $(call gb_Output_announce,$(2),$(true),UIX,1) MERGEINPUT=`$(gb_MKTEMP)` && \ @@ -27,6 +40,7 @@ $(call gb_Helper_abbreviate_dirs,\ -o $(call gb_UILocalizeTarget_get_workdir,$(2)) \ -l all \ -m $${MERGEINPUT} \ + $(call gb_UILocalizeTarget__fix_missing_qtz,$(call gb_UILocalizeTarget_get_workdir,$(2))) \ && touch $(1) \ ) && \ rm -rf $${MERGEINPUT} commit d250f6f5626056e94409cc0a6d64f5377bacfe84 Author: David Tardon <[email protected]> Date: Thu Dec 27 12:15:08 2012 +0100 simplify UI packaging Change-Id: Id829cd4f12cb4d3fc8cb08dc5b297ee3cfc7591b (cherry picked from commit 4faaf5579937e2e2fc91aef28ba4974020d2fa9f) Signed-off-by: David Tardon <[email protected]> diff --git a/solenv/gbuild/UI.mk b/solenv/gbuild/UI.mk index 5a3f8fc..b56c858 100644 --- a/solenv/gbuild/UI.mk +++ b/solenv/gbuild/UI.mk @@ -115,24 +115,21 @@ endif $$(eval $$(call gb_Module_register_target,$(call gb_UI_get_target,$(1)),$(call gb_UI_get_clean_target,$(1)))) endef -# gb_UI__get_outdir_filename target file lang? -gb_UI__get_outdir_filename = xml/uiconfig/$(1)/ui/$(if $(3),res/$(3)/)$(notdir $(2))$(if $(3),,.ui) - -# gb_UI__add_uifile target package destfile srcfile lang? +# gb_UI__package_uifile target package destfile srcfile define gb_UI__package_uifile -$(call gb_Package_add_file,$(2),$(call gb_UI__get_outdir_filename,$(1),$(3),$(5)),$(4)) +$(call gb_Package_add_file,$(2),xml/uiconfig/$(1)/ui/$(3),$(4)) endef # gb_UI__add_uifile target file define gb_UI__add_uifile -$(call gb_UI__package_uifile,$(1),$(1)_ui,$(2),$(2).ui) +$(call gb_UI__package_uifile,$(1),$(1)_ui,$(notdir $(2)).ui,$(2).ui) endef # gb_UI__add_uifile_for_lang target file lang define gb_UI__add_uifile_for_lang -$(call gb_UI__package_uifile,$(1),$(1)_ui_localized,$(2),$(2)/$(3).ui,$(3)) +$(call gb_UI__package_uifile,$(1),$(1)_ui_localized,res/$(3)/$(notdir $(2)),$(2)/$(3).ui) endef commit 90c34cdfa0689167d9dee5df6459ed7449b76301 Author: David Tardon <[email protected]> Date: Thu Dec 27 10:54:04 2012 +0100 create all translations for a .ui file in one uiex call This should help a lot with Windows release build times (i.e., move it from "glacially slow" category to just "slow"). Change-Id: I6d397eb5d1ec1779616c3eef8e51f9cf29d5acec (cherry picked from commit b209dec8bbc9be5471438837a4da64adfa350298) Signed-off-by: David Tardon <[email protected]> diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk index 32887be..9aef6d3 100644 --- a/solenv/gbuild/TargetLocations.mk +++ b/solenv/gbuild/TargetLocations.mk @@ -161,8 +161,8 @@ gb_SrsTemplateTarget_get_include_dir = $(WORKDIR)/SrsTemplatePartTarget/$(firstw gb_SrsTemplateTarget_get_target = $(WORKDIR)/SrsTemplateTarget/$(1) gb_ThesaurusIndexTarget_get_target = $(WORKDIR)/ThesaurusIndexTarget/$(basename $(1)).idx gb_UI_get_target = $(WORKDIR)/UI/$(1).done -gb_UILocalizeTarget_get_target = $(WORKDIR)/UILocalizeTarget/$(1).ui -gb_UITarget_get_target = $(WORKDIR)/UITarget/$(1).done +gb_UILocalizeTarget_get_target = $(WORKDIR)/UILocalizeTarget/$(1).done +gb_UILocalizeTarget_get_workdir = $(WORKDIR)/UILocalizeTarget/$(1) gb_UnoApiTarget_get_external_headers_target = $(WORKDIR)/UnoApiTarget/$(1).external gb_UnoApiTarget_get_headers_target = $(WORKDIR)/UnoApiTarget/$(1).headers gb_UnoApiTarget_get_target = $(WORKDIR)/UnoApiTarget/$(1).rdb @@ -264,7 +264,6 @@ $(eval $(call gb_Helper_make_clean_targets,\ ExternalProject \ UI \ UILocalizeTarget \ - UITarget \ UnoApiHeadersTarget \ UnoApiTarget \ UnpackedTarball \ diff --git a/solenv/gbuild/UI.mk b/solenv/gbuild/UI.mk index a529adc..5a3f8fc 100644 --- a/solenv/gbuild/UI.mk +++ b/solenv/gbuild/UI.mk @@ -9,11 +9,13 @@ # class UILocalizeTarget +# Produces translations for one .ui file. + gb_UILocalizeTarget_WORKDIR := $(WORKDIR)/UILocalizeTarget gb_UILocalizeTarget_TARGET := $(call gb_Executable_get_target_for_build,uiex) gb_UILocalizeTarget_COMMAND := $(gb_Helper_set_ld_path) $(gb_UILocalizeTarget_TARGET) -gb_UILocalizeTarge_LANGS := $(filter-out qtz,$(filter-out en-US,$(gb_WITH_LANG))) +gb_UILocalizeTarget_LANGS := $(filter-out qtz,$(filter-out en-US,$(gb_WITH_LANG))) define gb_UILocalizeTarget__command $(call gb_Output_announce,$(2),$(true),UIX,1) @@ -22,13 +24,17 @@ echo $(POFILES) > $${MERGEINPUT} && \ $(call gb_Helper_abbreviate_dirs,\ $(gb_UILocalizeTarget_COMMAND) \ -i $(UI_FILE) \ - -o $(dir $(1)) \ - -l $(UI_LANG) \ - -m $${MERGEINPUT} ) && \ + -o $(call gb_UILocalizeTarget_get_workdir,$(2)) \ + -l all \ + -m $${MERGEINPUT} \ + && touch $(1) \ +) && \ rm -rf $${MERGEINPUT} - endef +$(dir $(call gb_UILocalizeTarget_get_target,%)).dir : + $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) + $(dir $(call gb_UILocalizeTarget_get_target,%))%/.dir : $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) @@ -42,77 +48,26 @@ $(call gb_UILocalizeTarget_get_clean_target,%) : rm -f $(call gb_UILocalizeTarget_get_target,$*) \ ) -# Translates one .ui file +# Produce translations for one .ui file # -# gb_UILocalizeTarget_UILocalizeTarget target source lang +# gb_UILocalizeTarget_UILocalizeTarget target define gb_UILocalizeTarget_UILocalizeTarget -$(call gb_UILocalizeTarget_get_target,$(1)) : POFILES := $(foreach lang,$(gb_UILocalizeTarge_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(2))).po) -$(call gb_UILocalizeTarget_get_target,$(1)) : UI_FILE := $(SRCDIR)/$(2).ui -$(call gb_UILocalizeTarget_get_target,$(1)) : UI_LANG := $(3) - -$(call gb_UILocalizeTarget_get_target,$(1)) : $(foreach lang,$(gb_UILocalizeTarge_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(2))).po) -$(call gb_UILocalizeTarget_get_target,$(1)) : $(SRCDIR)/$(2).ui -$(call gb_UILocalizeTarget_get_target,$(1)) :| $(dir $(call gb_UILocalizeTarget_get_target,$(1))).dir +$(call gb_UILocalizeTarget__UILocalizeTarget_impl,$(1),$(foreach lang,$(gb_UILocalizeTarget_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po)) -$(foreach lang,$(gb_UILocalizeTarge_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(2))).po) : endef -# class UITarget - -# en-US is a special case -gb_UITarget_LANGS := $(filter-out en-US,$(gb_WITH_LANG)) - -gb_UITarget_LOCALIZED_DIR := $(gb_UILocalizeTarget_WORKDIR) - -gb_UITarget_get_uifile_for_lang = $(subst $(gb_UITarget_LOCALIZED_DIR)/,,$(call gb_UILocalizeTarget_get_target,$(1)/$(2))) - -$(dir $(call gb_UITarget_get_target,%)).dir : - $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) - -$(dir $(call gb_UITarget_get_target,%))%/.dir : - $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) - -$(call gb_UITarget_get_target,%) : - $(call gb_Output_announce,$*,$(true),UI ,2) - $(call gb_Helper_abbreviate_dirs,\ - touch $@ \ - ) - -.PHONY : $(call gb_UITarget_get_clean_target,%) -$(call gb_UITarget_get_clean_target,%) : - $(call gb_Output_announce,$*,$(false),UI ,2) - $(call gb_Helper_abbreviate_dirs,\ - rm -f $(call gb_UITarget_get_target,$*) \ - ) +# gb_UILocalizeTarget__UILocalizeTarget_impl target pofiles +define gb_UILocalizeTarget__UILocalizeTarget_impl +$(call gb_UILocalizeTarget_get_target,$(1)) : POFILES := $(2) +$(call gb_UILocalizeTarget_get_target,$(1)) : UI_FILE := $(SRCDIR)/$(1).ui -# Translates a set of .ui files -# -# gb_UITarget_UITarget modulename -define gb_UITarget_UITarget -$(call gb_UITarget_get_target,$(1)) :| $(dir $(call gb_UITarget_get_target,$(1))).dir - -endef +$(call gb_UILocalizeTarget_get_target,$(1)) : $(2) +$(call gb_UILocalizeTarget_get_target,$(1)) : $(SRCDIR)/$(1).ui +$(call gb_UILocalizeTarget_get_target,$(1)) :| \ + $(dir $(call gb_UILocalizeTarget_get_target,$(1))).dir \ + $(call gb_UILocalizeTarget_get_workdir,$(1))/.dir -define gb_UITarget__add_uifile_for_lang -$(call gb_UILocalizeTarget_UILocalizeTarget,$(2)/$(3),$(2),$(3)) -$(call gb_UITarget_get_target,$(1)) : $(call gb_UILocalizeTarget_get_target,$(2)/$(3)) -$(call gb_UITarget_get_clean_target,$(1)) : $(call gb_UILocalizeTarget_get_clean_target,$(2)/$(3)) - -endef - -# Adds an .ui file for translation -# -# gb_UITarget_add_uifile target uifile -define gb_UITarget_add_uifile -$(foreach lang,$(gb_UITarget_LANGS),$(call gb_UITarget__add_uifile_for_lang,$(1),$(2),$(lang))) - -endef - -# Adds multiple .ui files for translation -# -# gb_UITarget_add_uifiles target uifile(s) -define gb_UITarget_add_uifiles -$(foreach uifile,$(2),$(call gb_UITarget_add_uifile,$(1),$(uifile))) +$(2) : endef @@ -120,7 +75,8 @@ endef # Handles UI description files (suffix .ui) for the new layouting mechanism. -gb_UI_LANGS := $(gb_UITarget_LANGS) +# en-US is the default, so there is no translation for it +gb_UI_LANGS := $(filter-out en-US,$(gb_WITH_LANG)) $(dir $(call gb_UI_get_target,%)).dir : $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) @@ -129,12 +85,14 @@ $(dir $(call gb_UI_get_target,%))%/.dir : $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) $(call gb_UI_get_target,%) : + $(call gb_Output_announce,$*,$(true),UI ,2) $(call gb_Helper_abbreviate_dirs,\ touch $@ \ ) .PHONY : $(call gb_UI_get_clean_target,%) $(call gb_UI_get_clean_target,%) : + $(call gb_Output_announce,$*,$(false),UI ,2) $(call gb_Helper_abbreviate_dirs,\ rm -f $(call gb_UI_get_target,$*) \ ) @@ -149,11 +107,8 @@ $(call gb_UI_get_target,$(1)) :| $(call gb_Package_get_target,$(1)_ui) $(call gb_UI_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(1)_ui) ifneq ($(gb_UI_LANGS),) -$(call gb_UITarget_UITarget,$(1)) -$(call gb_Package_Package_internal,$(1)_ui_localized,$(gb_UITarget_LOCALIZED_DIR)) -$(call gb_UI_get_target,$(1)) : $(call gb_UITarget_get_target,$(1)) +$(call gb_Package_Package_internal,$(1)_ui_localized,$(gb_UILocalizeTarget_WORKDIR)) $(call gb_UI_get_target,$(1)) :| $(call gb_Package_get_target,$(1)_ui_localized) -$(call gb_UI_get_clean_target,$(1)) : $(call gb_UITarget_get_clean_target,$(1)) $(call gb_UI_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(1)_ui_localized) endif @@ -169,25 +124,15 @@ $(call gb_Package_add_file,$(2),$(call gb_UI__get_outdir_filename,$(1),$(3),$(5) endef -# gb_UI__add_uifile_direct target file -define gb_UI__add_uifile_direct +# gb_UI__add_uifile target file +define gb_UI__add_uifile $(call gb_UI__package_uifile,$(1),$(1)_ui,$(2),$(2).ui) endef # gb_UI__add_uifile_for_lang target file lang define gb_UI__add_uifile_for_lang -$(call gb_UI__package_uifile,$(1),$(1)_ui_localized,$(2),$(call gb_UITarget_get_uifile_for_lang,$(2),$(3)),$(3)) - -endef - -define gb_UI__add_uifile -$(call gb_UI__add_uifile_direct,$(1),$(2)) - -ifneq ($(gb_UI_LANGS),) -$(call gb_UITarget_add_uifile,$(1),$(2)) -$(foreach lang,$(gb_UI_LANGS),$(call gb_UI__add_uifile_for_lang,$(1),$(2),$(lang))) -endif +$(call gb_UI__package_uifile,$(1),$(1)_ui_localized,$(2),$(2)/$(3).ui,$(3)) endef @@ -200,7 +145,11 @@ define gb_UI_add_uifile $(call gb_UI__add_uifile,$(1),$(2)) ifneq ($(gb_UI_LANGS),) -$(call gb_UITarget_add_uifile,$(1),$(2)) +$(call gb_UILocalizeTarget_UILocalizeTarget,$(2)) +$(call gb_UI_get_target,$(1)) : $(call gb_UILocalizeTarget_get_target,$(2)) +$(call gb_UI_get_clean_target,$(1)) : $(call gb_UILocalizeTarget_get_clean_target,$(2)) +$(call gb_Package_get_preparation_target,$(1)_ui_localized) : $(call gb_UILocalizeTarget_get_target,$(2)) +$(foreach lang,$(gb_UI_LANGS),$(call gb_UI__add_uifile_for_lang,$(1),$(2),$(lang))) endif endef @@ -209,11 +158,7 @@ endef # # gb_UI_add_uifiles target uifile(s) define gb_UI_add_uifiles -$(foreach uifile,$(2),$(call gb_UI__add_uifile,$(1),$(uifile))) - -ifneq ($(gb_UI_LANGS),) -$(call gb_UITarget_add_uifiles,$(1),$(2)) -endif +$(foreach uifile,$(2),$(call gb_UI_add_uifile,$(1),$(uifile))) endef commit 743e16e71c5b623b3545f19a3ff5640c2ba43cd2 Author: David Tardon <[email protected]> Date: Wed Dec 26 15:40:21 2012 +0100 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 (cherry picked from commit c27b2e377f612de2476ff0aa0ddc909ff214fcb2) Signed-off-by: David Tardon <[email protected]> diff --git a/l10ntools/source/uimerge.cxx b/l10ntools/source/uimerge.cxx index 4192ed7..d14b9b7 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> @@ -126,22 +128,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 ); @@ -151,34 +207,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 47a1a78..a529adc 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} _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
