first release of translation facility

* runtime - loading and translating
 * design-time - works with *.ts file (pip_tr utility)
 * compile-time - CMake macro for compile *.ts
This commit is contained in:
2024-11-05 13:49:00 +03:00
parent 73ed51e3d4
commit 57f8c1313e
52 changed files with 1571 additions and 480 deletions

View File

@@ -19,7 +19,6 @@
#include "piresourcesstorage.h"
#include "pichunkstream.h"
#include "piset.h"
@@ -42,11 +41,11 @@ void PIResourcesStorage::Section::add(const PIResourcesStorage::Section & s) {
void PIResourcesStorage::Section::purge() {
PIVector<PIByteArray *> bav = entries.values();
PISet<PIByteArray *> bas;
piForeach(PIByteArray * i, bav) {
for (auto i: bav) {
if (i) bas << i;
}
bav = bas.toVector();
piForeach(PIByteArray * i, bav)
for (auto i: bav)
delete i;
entries.clear();
}
@@ -76,14 +75,14 @@ void PIResourcesStorage::registerSection(const uchar * rc_data, const uchar * rc
PIVector<PIResourcesStorage::__RCEntry> el;
dba >> el;
PIMap<PIString, PIVector<PIResourcesStorage::__RCEntry>> ebs;
piForeachC(PIResourcesStorage::__RCEntry & e, el) {
for (const auto & e: el) {
ebs[e.section] << e;
}
auto it = ebs.makeIterator();
while (it.next()) {
PIResourcesStorage::Section s;
const PIVector<PIResourcesStorage::__RCEntry> & itv(it.value());
piForeachC(PIResourcesStorage::__RCEntry & e, itv) {
for (const auto & e: itv) {
// piCout << "add" << e.name << e.alias << PIString::readableSize(e.size);
PIByteArray * eba = new PIByteArray(&(rc_data[e.offset]), e.size);
s.entries[e.name] = eba;
@@ -123,7 +122,7 @@ PIByteArray PIResourcesStorage::get(const PIString & entry_name) const {
void PIResourcesStorage::clear() {
// piCout << "PIResourcesStorage clear";
PIVector<Section *> sv = sections.values();
piForeach(Section * i, sv) {
for (auto i: sv) {
if (i) i->purge();
}
sections.clear();