Dawn/archive/dawntools/util/Language.cpp
2023-10-31 21:15:03 -05:00

36 lines
804 B
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "Language.hpp"
using namespace Dawn;
int32_t languageSaveStrings(
std::string languagesDir,
std::vector<struct LanguageString> strings
) {
if(languagesDir.size() <= 0) {
std::cout << "Languages dir is not defined" << std::endl;
return 1;
}
File file(languagesDir);
if(!file.mkdirp()) {
std::cout << "Failed to create languages string output dir " << file.filename << std::endl;
return 1;
}
// Now convert to xml
std::string buffer;
auto it = strings.begin();
while(it != strings.end()) {
auto s = *it;
buffer += s.lang + "|" + s.key + "|" + s.text + "|";
++it;
}
file.writeString(buffer);
return 0;
}