summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-05-16 13:55:24 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-05-16 13:55:29 (GMT)
commitef8ac5ad5af699d87d876a546be43b7f6b744fac (patch)
tree4f4aa47986632d27d43394a2cc2e944be0212a13 /Source
parent0789a8be08005d076568695ff3f85fb47f94620a (diff)
parent72ac7ad98da17f5f13dba9ab70ccddc18bd12ff5 (diff)
downloadCMake-ef8ac5ad5af699d87d876a546be43b7f6b744fac.zip
CMake-ef8ac5ad5af699d87d876a546be43b7f6b744fac.tar.gz
CMake-ef8ac5ad5af699d87d876a546be43b7f6b744fac.tar.bz2
Merge topic 'cpackifw-i18n'
72ac7ad9 CPackIFW: Internationalization Support Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !748
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/IFW/cmCPackIFWCommon.cxx46
-rw-r--r--Source/CPack/IFW/cmCPackIFWCommon.h16
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.cxx50
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.h5
4 files changed, 101 insertions, 16 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx
index 436f4d3..e8f05bd 100644
--- a/Source/CPack/IFW/cmCPackIFWCommon.cxx
+++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx
@@ -11,6 +11,8 @@
#include "cmXMLWriter.h"
#include <sstream>
+#include <utility>
+#include <vector>
cmCPackIFWCommon::cmCPackIFWCommon()
: Generator(CM_NULLPTR)
@@ -72,6 +74,50 @@ bool cmCPackIFWCommon::IsVersionEqual(const char* version)
version);
}
+void cmCPackIFWCommon::ExpandListArgument(
+ const std::string& arg, std::map<std::string, std::string>& argsOut)
+{
+ std::vector<std::string> args;
+ cmSystemTools::ExpandListArgument(arg, args, false);
+ if (args.empty()) {
+ return;
+ }
+
+ std::size_t i = 0;
+ std::size_t c = args.size();
+ if (c % 2) {
+ argsOut[""] = args[i];
+ ++i;
+ }
+
+ --c;
+ for (; i < c; i += 2) {
+ argsOut[args[i]] = args[i + 1];
+ }
+}
+
+void cmCPackIFWCommon::ExpandListArgument(
+ const std::string& arg, std::multimap<std::string, std::string>& argsOut)
+{
+ std::vector<std::string> args;
+ cmSystemTools::ExpandListArgument(arg, args, false);
+ if (args.empty()) {
+ return;
+ }
+
+ std::size_t i = 0;
+ std::size_t c = args.size();
+ if (c % 2) {
+ argsOut.insert(std::pair<std::string, std::string>("", args[i]));
+ ++i;
+ }
+
+ --c;
+ for (; i < c; i += 2) {
+ argsOut.insert(std::pair<std::string, std::string>(args[i], args[i + 1]));
+ }
+}
+
void cmCPackIFWCommon::WriteGeneratedByToStrim(cmXMLWriter& xout)
{
if (!this->Generator) {
diff --git a/Source/CPack/IFW/cmCPackIFWCommon.h b/Source/CPack/IFW/cmCPackIFWCommon.h
index 66b6e89..354d849 100644
--- a/Source/CPack/IFW/cmCPackIFWCommon.h
+++ b/Source/CPack/IFW/cmCPackIFWCommon.h
@@ -5,6 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <map>
#include <string>
class cmCPackIFWGenerator;
@@ -46,6 +47,21 @@ public:
*/
bool IsVersionEqual(const char* version);
+ /** Expand the list argument containing the map of the key-value pairs.
+ * If the number of elements is odd, then the first value is used as the
+ * default value with an empty key.
+ * Any values with the same keys will be permanently overwritten.
+ */
+ static void ExpandListArgument(const std::string& arg,
+ std::map<std::string, std::string>& argsOut);
+
+ /** Expand the list argument containing the multimap of the key-value pairs.
+ * If the number of elements is odd, then the first value is used as the
+ * default value with an empty key.
+ */
+ static void ExpandListArgument(
+ const std::string& arg, std::multimap<std::string, std::string>& argsOut);
+
cmCPackIFWGenerator* Generator;
protected:
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index e6ef421..c5311c3 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -15,6 +15,7 @@
#include <map>
#include <sstream>
#include <stddef.h>
+#include <utility>
//---------------------------------------------------------- CompareStruct ---
cmCPackIFWPackage::CompareStruct::CompareStruct()
@@ -108,8 +109,8 @@ std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component)
void cmCPackIFWPackage::DefaultConfiguration()
{
- this->DisplayName = "";
- this->Description = "";
+ this->DisplayName.clear();
+ this->Description.clear();
this->Version = "";
this->ReleaseDate = "";
this->Script = "";
@@ -136,17 +137,17 @@ int cmCPackIFWPackage::ConfigureFromOptions()
// Display name
if (const char* option = this->GetOption("CPACK_PACKAGE_NAME")) {
- this->DisplayName = option;
+ this->DisplayName[""] = option;
} else {
- this->DisplayName = "Your package";
+ this->DisplayName[""] = "Your package";
}
// Description
if (const char* option =
this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
- this->Description = option;
+ this->Description[""] = option;
} else {
- this->Description = "Your package description";
+ this->Description[""] = "Your package description";
}
// Version
@@ -174,10 +175,10 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
cmsys::SystemTools::UpperCase(component->Name) + "_";
// Display name
- this->DisplayName = component->DisplayName;
+ this->DisplayName[""] = component->DisplayName;
// Description
- this->Description = component->Description;
+ this->Description[""] = component->Description;
// Version
if (const char* optVERSION = this->GetOption(prefix + "VERSION")) {
@@ -262,8 +263,8 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" +
cmsys::SystemTools::UpperCase(group->Name) + "_";
- this->DisplayName = group->DisplayName;
- this->Description = group->Description;
+ this->DisplayName[""] = group->DisplayName;
+ this->Description[""] = group->Description;
// Version
if (const char* optVERSION = this->GetOption(prefix + "VERSION")) {
@@ -358,7 +359,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
if (this->IsSetToEmpty(option)) {
this->DisplayName.clear();
} else if (const char* value = this->GetOption(option)) {
- this->DisplayName = value;
+ this->ExpandListArgument(value, this->DisplayName);
}
// Description
@@ -366,7 +367,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
if (this->IsSetToEmpty(option)) {
this->Description.clear();
} else if (const char* value = this->GetOption(option)) {
- this->Description = value;
+ this->ExpandListArgument(value, this->Description);
}
// Release date
@@ -519,8 +520,29 @@ void cmCPackIFWPackage::GeneratePackageFile()
xout.StartElement("Package");
- xout.Element("DisplayName", this->DisplayName);
- xout.Element("Description", this->Description);
+ // DisplayName (with translations)
+ for (std::map<std::string, std::string>::iterator it =
+ this->DisplayName.begin();
+ it != this->DisplayName.end(); ++it) {
+ xout.StartElement("DisplayName");
+ if (!it->first.empty()) {
+ xout.Attribute("xml:lang", it->first);
+ }
+ xout.Content(it->second);
+ xout.EndElement();
+ }
+
+ // Description (with translations)
+ for (std::map<std::string, std::string>::iterator it =
+ this->Description.begin();
+ it != this->Description.end(); ++it) {
+ xout.StartElement("Description");
+ if (!it->first.empty()) {
+ xout.Attribute("xml:lang", it->first);
+ }
+ xout.Content(it->second);
+ xout.EndElement();
+ }
// Update text
if (!this->UpdateText.empty()) {
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h
index f9e577a..cec59b0 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.h
+++ b/Source/CPack/IFW/cmCPackIFWPackage.h
@@ -7,6 +7,7 @@
#include "cmCPackIFWCommon.h"
+#include <map>
#include <set>
#include <string>
#include <vector>
@@ -69,10 +70,10 @@ public:
// Configuration
/// Human-readable name of the component
- std::string DisplayName;
+ std::map<std::string, std::string> DisplayName;
/// Human-readable description of the component
- std::string Description;
+ std::map<std::string, std::string> Description;
/// Version number of the component
std::string Version;