mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +00:00
41bdcd4aed
* Update logging * Remove duplicate code * Update unit tests * Clean up includes * Merge ProtobufSerializer into protobuf_util namespace * Precompile regex * Add const * Add Split() convenience method, update log level/ID parsing * Move log.h to legacy folder * Elimininate gotos * Fixes for gcc 13 * Update compiler flags * Update default folder handling * Use references instead of pointers * Move code for better encapsulation * Move code * Remove unused method argument * Move device logger * Remove redundant to_string * Rename for consistency * Update handling of protobuf pointers * Simplify protobuf usage * Memory handling update * Add hasher
78 lines
1.9 KiB
C++
78 lines
1.9 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2021-2023 Uwe Seimet
|
|
//
|
|
// Message localization support. Currently only for messages with up to 3 string parameters.
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "shared/piscsi_util.h"
|
|
#include <string>
|
|
#include <unordered_set>
|
|
#include <unordered_map>
|
|
#include <regex>
|
|
|
|
using namespace std;
|
|
|
|
enum class LocalizationKey {
|
|
ERROR_AUTHENTICATION,
|
|
ERROR_OPERATION,
|
|
ERROR_LOG_LEVEL,
|
|
ERROR_MISSING_DEVICE_ID,
|
|
ERROR_MISSING_FILENAME,
|
|
ERROR_DEVICE_MISSING_FILENAME,
|
|
ERROR_IMAGE_IN_USE,
|
|
ERROR_IMAGE_FILE_INFO,
|
|
ERROR_RESERVED_ID,
|
|
ERROR_NON_EXISTING_DEVICE,
|
|
ERROR_NON_EXISTING_UNIT,
|
|
ERROR_UNKNOWN_DEVICE_TYPE,
|
|
ERROR_MISSING_DEVICE_TYPE,
|
|
ERROR_DUPLICATE_ID,
|
|
ERROR_DETACH,
|
|
ERROR_EJECT_REQUIRED,
|
|
ERROR_DEVICE_NAME_UPDATE,
|
|
ERROR_SHUTDOWN_MODE_MISSING,
|
|
ERROR_SHUTDOWN_MODE_INVALID,
|
|
ERROR_SHUTDOWN_PERMISSION,
|
|
ERROR_FILE_OPEN,
|
|
ERROR_BLOCK_SIZE,
|
|
ERROR_BLOCK_SIZE_NOT_CONFIGURABLE,
|
|
ERROR_SCSI_CONTROLLER,
|
|
ERROR_INVALID_ID,
|
|
ERROR_INVALID_LUN,
|
|
ERROR_LUN0,
|
|
ERROR_INITIALIZATION,
|
|
ERROR_OPERATION_DENIED_STOPPABLE,
|
|
ERROR_OPERATION_DENIED_REMOVABLE,
|
|
ERROR_OPERATION_DENIED_PROTECTABLE,
|
|
ERROR_OPERATION_DENIED_READY
|
|
};
|
|
|
|
class Localizer
|
|
{
|
|
public:
|
|
|
|
Localizer();
|
|
~Localizer() = default;
|
|
|
|
string Localize(LocalizationKey, const string&, const string& = "", const string& = "", const string& = "") const;
|
|
|
|
private:
|
|
|
|
void Add(LocalizationKey, const string&, string_view);
|
|
unordered_map<string, unordered_map<LocalizationKey, string>, piscsi_util::StringHash, equal_to<>> localized_messages;
|
|
|
|
// Supported locales, always lower case
|
|
unordered_set<string, piscsi_util::StringHash, equal_to<>> supported_languages = { "en", "de", "sv", "fr", "es", "zh" };
|
|
|
|
const regex regex1 = regex("%1");
|
|
const regex regex2 = regex("%2");
|
|
const regex regex3 = regex("%3");
|
|
};
|