Almost done with new language tools

This commit is contained in:
2023-02-14 23:03:11 -08:00
parent b7db050a5c
commit b8bab7ebed
45 changed files with 416 additions and 289 deletions

View File

@@ -5,8 +5,12 @@
set(D ${CMAKE_CURRENT_LIST_DIR})
list(APPEND
set(
DAWN_TOOL_SOURCES
${D}/DawnTool.cpp
${D}/File.cpp
${D}/Language.cpp
CACHE INTERNAL
${DAWN_CACHE_TARGET}
)

View File

@@ -20,6 +20,7 @@
#define FILE_PATH_SEP '/'
#define fileMkdir(path, perms) mkdir(path, perms)
#endif
#include <errno.h>
#define FILE_BUFFER_SIZE 512
@@ -31,11 +32,11 @@ namespace Dawn {
class File {
private:
FILE *file = nullptr;
enum FileMode mode;
size_t length;
public:
FILE *file = nullptr;
static std::string normalizeSlashes(std::string str);
static void mkdirp(std::string path);

View File

@@ -0,0 +1,36 @@
// 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;
}

View File

@@ -0,0 +1,19 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "util/Xml.hpp"
#include "util/File.hpp"
struct LanguageString {
std::string key;
std::string lang;
std::string text;
};
static int32_t languageSaveStrings(
std::string languagesDir,
std::vector<struct LanguageString> strings
);