7 Commits
1.0.1 ... 1.1.2

Author SHA1 Message Date
5311df51ad Link exe statically.
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2021-09-07 18:47:51 +02:00
f95ee90a20 Merge remote-tracking branch 'origin/master'
All checks were successful
continuous-integration/drone Build is passing
2021-09-07 18:39:06 +02:00
d7beb77f1d Better handling of detecting csv separator. 2021-09-07 18:38:19 +02:00
14a8709631 Merge branch 'master' of ssh.p-epsilon.com:Deukhoofd/LangBuilder
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-29 11:35:16 +02:00
f2a4352f44 Remove old api token 2021-08-29 11:35:02 +02:00
ee85947c4c Validate key for conforming to style rules.
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2021-07-23 12:23:56 +02:00
a56ccf68ec Adds a bit more logging. 2021-07-23 12:09:11 +02:00
4 changed files with 38 additions and 10 deletions

View File

@@ -23,7 +23,8 @@ steps:
- name: gitea_release
image: plugins/gitea-release
settings:
api_key: 684b59c5281894a312cfb5f7c158a7720791eff1
api_key:
from_secret: gitea_token
base_url: https://git.p-epsilon.com/
files:
- build-release/LangBuilder

View File

@@ -5,8 +5,9 @@ project(LangBuilder)
add_compile_options(-Wall -Wextra -Werror)
# We like new stuff, so set the c++ standard to c++20.
set(CMAKE_CXX_STANDARD 20)
set(BUILD_SHARED_LIBS OFF)
file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp")
add_executable(LangBuilder ${SRC_FILES})
target_link_libraries(LangBuilder -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
target_link_libraries(LangBuilder -static -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)

View File

@@ -78,11 +78,14 @@ void LocalizationData::WriteToFile(const std::filesystem::path& path) {
tempFilesPositions[file.first] = p1;
}
outFile << "ENDDATA" << std::endl;
size_t numberGlobal = 0;
// actual localization
for (const auto& file : _globalFiles) {
auto pos = outFile.tellp();
for (const auto& kv : file.second.GetMap()) {
outFile << kv.first << "|" << kv.second << std::endl;
numberGlobal++;
}
auto end = outFile.tellp();
auto length = end - pos;
@@ -93,10 +96,13 @@ void LocalizationData::WriteToFile(const std::filesystem::path& path) {
outFile << std::setfill('0') << std::setw(4) << std::hex << length;
outFile.seekp(end);
}
size_t numberTemp = 0;
for (const auto& file : _tempFiles) {
auto pos = outFile.tellp();
for (const auto& kv : file.second.GetMap()) {
outFile << kv.first << "|" << kv.second << std::endl;
numberTemp++;
}
auto end = outFile.tellp();
auto length = end - pos;
@@ -110,5 +116,6 @@ void LocalizationData::WriteToFile(const std::filesystem::path& path) {
outFile.close();
std::cout << "Wrote language file to " << path << std::endl;
std::cout << "Wrote language file to " << path << ". Wrote " << numberGlobal << " global keys and " << numberTemp
<< " temp keys." << std::endl;
}

View File

@@ -1,6 +1,20 @@
#include "LocalizationFile.hpp"
#include <fstream>
#include <iostream>
#include <regex>
const std::regex keyChecker = std::regex("[^a-z0-9_]+");
static bool IsKeyValid(const std::string_view & key){
if (std::regex_search(key.begin(), key.end(), keyChecker)){
return false;
}
return true;
}
const char PossibleSeparators[] = {
',', ';', '|', '\t', ':'
};
void LocalizationFile::LoadFile(const std::filesystem::path& path) {
if (!std::filesystem::exists(path)) {
@@ -21,9 +35,11 @@ void LocalizationFile::LoadFile(const std::filesystem::path& path) {
while (std::getline(file, line)) {
if (firstLine) {
firstLine = false;
if (line.substr(0, 4) == "sep=") {
sep = line[4];
continue;
for (auto& s :PossibleSeparators) {
if (line.find(s) != std::string::npos){
sep = s;
break;
}
}
}
std::string key;
@@ -33,6 +49,9 @@ void LocalizationFile::LoadFile(const std::filesystem::path& path) {
std::getline(linestream, value, sep);
if (key.empty())
continue;
if (!IsKeyValid(key)){
std::cout << "Key not valid: '" << key << "'. Skipping key." << std::endl;
}
_map[key] = value;
}
file.close();