Merge develop into main (#305)
## New features - Implement translations for apps - Created `tt::settings::setLanguage` and `::getLanguage()` - External app errors are now reported to the user via an AlertDialog - Store system settings in `/data/settings.properties` - Created a "Region & Language" app and moved the timezone setting there. ## Other changes - Change `/data` and `/system` filesystem sector size from 4096 to 512 bytes to allow for more small files (60+ files of 4kB were over the limit of 256kB for the filesystem) - Increased size of `/data` and `/system` - Moved `tt::time::*` to `tt::settings` - Removed the timezone setting from the "Time & Date" setting app - Reverse encoder direction of Lilygo T-Lora Pager - Improved partability of `Time.cpp` (removed separate set of functions for PC/sim)
This commit is contained in:
committed by
GitHub
parent
ee5a5a7181
commit
8c8ccd8783
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/i18n/TextResources.h"
|
||||
|
||||
// WARNING: This file is auto-generated. Do not edit manually.
|
||||
|
||||
namespace tt::i18n::core {
|
||||
|
||||
enum class Text {
|
||||
OK = 0,
|
||||
YES = 1,
|
||||
NO = 2,
|
||||
CANCEL = 3,
|
||||
RETRY = 4,
|
||||
CLOSE = 5,
|
||||
OPEN = 6,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tt::i18n {
|
||||
|
||||
/**
|
||||
* Holds localized text data.
|
||||
*
|
||||
* It is used with data generated from Translations/ with the python generation scripts.
|
||||
* It's used with a header file that specifies the indexes, and generated text files (.i18n)
|
||||
*/
|
||||
class TextResources {
|
||||
|
||||
std::vector<std::string> data;
|
||||
std::string path;
|
||||
static std::string ERROR_RESULT;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @param[in] path
|
||||
*/
|
||||
TextResources(const std::string& path) : path(path) {}
|
||||
|
||||
const std::string& get(const int index) const {
|
||||
if (index < data.size()) {
|
||||
return data[index];
|
||||
} else {
|
||||
return ERROR_RESULT;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename EnumType>
|
||||
const std::string& get(EnumType value) const { return get(static_cast<int>(value)); }
|
||||
|
||||
const std::string& operator[](const int index) const { return get(index); }
|
||||
|
||||
template <typename EnumType>
|
||||
const std::string& operator[](const EnumType index) const { return get(index); }
|
||||
|
||||
/**
|
||||
* Load or reload an i18n file with the system's current locale settings.
|
||||
* @return true on success
|
||||
*/
|
||||
bool load();
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace tt::settings {
|
||||
|
||||
enum class Language {
|
||||
en_GB,
|
||||
en_US,
|
||||
fr_FR,
|
||||
nl_BE,
|
||||
nl_NL,
|
||||
count
|
||||
};
|
||||
|
||||
void setLanguage(Language language);
|
||||
|
||||
Language getLanguage();
|
||||
|
||||
std::string toString(Language language);
|
||||
|
||||
bool fromString(const std::string& text, Language& language);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Language.h"
|
||||
|
||||
namespace tt::settings {
|
||||
|
||||
struct SettingsProperties {
|
||||
Language language;
|
||||
bool timeFormat24h;
|
||||
};
|
||||
|
||||
bool loadSettingsProperties(SettingsProperties& properties);
|
||||
|
||||
bool saveSettingsProperties(const SettingsProperties& properties);
|
||||
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace tt::time {
|
||||
namespace tt::settings {
|
||||
|
||||
/**
|
||||
* Set the timezone
|
||||
Reference in New Issue
Block a user