Skip to content

Instantly share code, notes, and snippets.

@DrSpeedy
Last active September 24, 2023 17:42
Show Gist options
  • Save DrSpeedy/b81481982525b9822a46624a2d8cd8c4 to your computer and use it in GitHub Desktop.
Save DrSpeedy/b81481982525b9822a46624a2d8cd8c4 to your computer and use it in GitHub Desktop.
Datarazer Sample Language Pack Plugin (3 files)
// Thetadyn Datarazer Copyright (c) 2023 Thetadyn LLC, All Rights Reserved.
// Sample Datarazer language pack plugin
#include "api/Plugin.h"
#include "util/Logger.hpp"
#include "util/Registry.hpp"
#include "locale/Locale.h"
#include "my_plugin/LEnglish.h"
using namespace api;
class LEnglish_Plugin : public Plugin {
private:
util::Registry* _reg;
util::Logger* _log;
public:
void Init(PluginComponents comps) override;
void Start() override;
void Stop() override;
};
void LEnglish_Plugin::Init(PluginComponents comps) {
_reg = comps.reg;
_log = comps.log;
}
void LEnglish_Plugin::Start() {
_log->LogInfo("Loading English Language Pack!");
// Load the language map giving it a name
locale::LKey::LoadLanguage("en_US", my_plugin::LEnglish::Get());
// Set your language explicitly here
_reg->Set('g', __G_LOCALE, new StringObject("en_US"));
// Test it!
//
// L_MY_PLUGIN_HELLO_WORLD is defined in LEnglish.cpp
// Calling just the LKey will print it's string value
// But you may also call it with arguments, either as a
// std::map (using named pairs) or std::vector (left to right)
_log->LogDebug(L_MY_PLUGIN_HELLO_WORLD({"Brian"}));
// Example of calling without args:
_log->LogWarn(L_MY_PLUGIN_CONTINUE_ON);
}
void LEnglish_Plugin::Stop() {}
extern "C" Plugin* CreatePlugin() {
return new LEnglish_Plugin();
}
// Thetadyn Datarazer Copyright (c) 2023 Thetadyn LLC, All Rights Reserved.
// Sample Datarazer language pack plugin
#include "my_plugin/LEnglish.h"
#include "locale/Locale.h"
namespace my_plugin {
std::map<locale::LKey, std::string> LEnglish::Get() {
return std::map<locale::LKey, std::string>({
{ L_MY_PLUGIN_HELLO_WORLD, "Hello, world! My name is: {{ name }}." },
{ L_MY_PLUGIN_CONTINUE_ON, "Alright, lets continue!" },
// Main Window
{ L_MW_HEADER_PAGE_TITLE_DISK_WRITER, "Disk Writer" },
{ L_MW_HEADER_SELECTED_WIPE_METHOD_LABEL, "Selected Method: " },
{ L_MW_HEADER_CONNECTED_DRIVES_LABEL, "Connected Drives: " },
{ L_MW_HEADER_PAGE_LABEL, "Page: " },
{ L_MW_DRIVE_TBL_HEADER_PATH, "Path " },
{ L_MW_DRIVE_TBL_HEADER_GRADE, "Grade " },
{ L_MW_DRIVE_TBL_HEADER_MODEL_SERIAL, "Model/Serial " },
{ L_MW_DRIVE_TBL_HEADER_STATUS, "Status" },
{ L_MW_DRIVE_TBL_WIPE_STATUS_GOOD, "WIPED" },
{ L_MW_DRIVE_TBL_WIPE_STATUS_BAD, "NOT WIPED" },
{ L_MW_DRIVE_TBL_ERRORS, " Errors: " },
{ L_MW_DRIVE_TBL_GRADE, "Grade: " },
{ L_MW_DRIVE_TBL_POWER_ON_HOURS, "POH: " },
{ L_MW_DRIVE_TBL_MODEL, "MDL: " },
{ L_MW_DRIVE_TBL_SERIAL, "SN: " },
{ L_MW_CONTROLS_HEADER, "Controls:" },
{ L_MW_CONTROLS_SCROLL_DRIVE_TBL, "[Up/Down] Scroll Drive Table" },
{ L_MW_CONTROLS_NAVIGATE_TABS, "[Left/Right] Navigate Tabs"},
{ L_MW_CONTROLS_START_OVERWRITE, "[Enter] Start Overwrite" },
{ L_MW_CONTROLS_MENU, "[M] Menu" },
{ L_MW_INPUT_FREE_VERSION_LIMIT_MSG_1, "This free version of DATARAZER is limited to 4 wiping instances" },
{ L_MW_INPUT_FREE_VERSION_LIMIT_MSG_2, "If you'd like to wipe unlimited drives, consider purchasing a Professional" },
{ L_MW_INPUT_FREE_VERSION_LIMIT_MSG_3, "license from: https://thetadyn.com/datarazer" },
{ L_MW_INPUT_ENTER_CONFIRM_PHRASE, "Enter the confirm phrase '{{confirm_phrase}}' to continue: " },
{ L_MW_INPUT_CONFIRM_PHRASE_BAD, "Confirm phrase did not match, Aborting..." },
{ L_MW_INPUT_DRIVE_INSTANCE_RUNNING_ALREADY, "An instance is already running on {{drive_path}}!" },
{ L_MW_DISK_INFO_INVALID_DISK, "INVALID DISK" },
{ L_MW_DISK_INFO_HEADER, "Disk Info:" },
{ L_MW_DISK_INFO_DISK_ATTRIBUTES, "Disk Attributes:" },
{ L_MW_DISK_INFO_HPA_INFO_READ, "HPA Info Read:" },
{ L_MW_DISK_INFO_HPA_SECTORS_DETECTED, "HPA Sectors Detected:" },
{ L_MW_DISK_INFO_DRIVE_TYPE, "Drive Type:" },
{ L_MW_DISK_INFO_ROTATION_RATE, "Rotation Rate:" },
{ L_MW_DISK_INFO_TOTAL_SECTORS_INCLUDING_HPA, "Total Sectors (Inluding HPAs):" },
{ L_MW_DISK_INFO_RPM_SFX, " RPM"},
{ L_MW_SETTINGS_HEADER, "Settings:" },
{ L_MW_SETTINGS_JOB_NUMBER, "Job#:" },
{ L_MW_SETTINGS_ASSET_NUMBER, "Asset#:" },
{ L_MW_SETTINGS_USE_FINGERPRINT, "Use Fingerprint:"},
{ L_MW_SETTINGS_USE_VERIFICATION, "Use Verification:" },
{ L_MW_SETTINGS_VERIFICATION_QUOTA, "Verification Quota:" },
{ L_MW_SETTINGS_ERROR_ALLOWANCE, "Error Allowance:" },
{ L_MW_SETTINGS_BLOCK_SIZE_MULTIPLIER, "Block Size Multiplier:" },
{ L_MW_SETTINGS_RESUMED_ERASURE_ENABLED, "Resumed Erasure Enabled:" },
{ L_MW_SETTINGS_RESUMED_ERASURE_STEP_SIZE, "Resumed Erasure Step Size:" },
{ L_MW_SETTINGS_CLEAR_HPAS, "Clear HPAs:" },
{ L_MW_SETTINGS_RESET_DCO, "Reset DCO:" },
{ L_MW_FP_INVALID_DISK, "INVALID DISK" },
{ L_MW_FP_UNKNOWN, "UNKNOWN" },
{ L_MW_FP_NOT_FOUND, "NOT FOUND" },
{ L_MW_FP_SECTION_TITLE, "Fingerprint Data:" },
{ L_MW_FP_HEADER, "Header:" },
{ L_MW_FP_RESUMED_ERASURE_USED, "Resumed Erasure Used:" },
{ L_MW_FP_IN_PROGRESS_ERASURE, "In Progress Erasure:" },
{ L_MW_FP_WIPE_METHOD, "Wipe Method:" },
{ L_MW_FP_WIPE_STATUS, "Wipe Status:" },
{ L_MW_FP_ERROR_COUNT, "Error Count:" },
{ L_MW_FP_HPAS_AT_START, "HPAs At Start:" },
{ L_MW_FP_HPAS_CLEARED, "HPAs Cleared:" },
{ L_MW_FP_DCO_RESET, "DCO Reset:" },
{ L_MW_FP_START_TIME, "Start Time:" },
{ L_MW_FP_END_TIME, "End Time:" },
{ L_MW_FP_DURATION, "Duration:" },
{ L_MW_FP_LAST_RESUME_OFST, "Last Resume OFST:" },
{ L_MW_FP_LAST_RESUME_PASS, "Last Resume Pass:" },
{ L_MW_FP_TOTAL_BLOCKS, "Total Blocks:" },
{ L_MW_FP_BLOCK_SIZE, "Block Size:" },
{ L_MW_FP_BLOCKS_VERIFIED, "Blocks Verified:" },
{ L_MW_FP_BLOCKS_MARKED_FOR_RESUME, "Blocks Marked For Resume:" },
// Menus
// Select Wipe Method
{ L_MENU_WIPE_METHOD_HEADER_PAGE_TITLE, "Select Overwrite Method" },
{ L_MENU_WIPE_METHOD_HEADER_PAGE_LABEL, "Page: " },
// Database Settings
{ L_MENU_DB_HEADER_PAGE_TITLE, "Settings Menu > Database Settings" },
{ L_MENU_DB_MENU_TITLE, "Database Settings" },
{ L_MENU_DB_USERNAME_LABEL, "Username:" },
{ L_MENU_DB_PASSWORD_LABEL, "Password:" },
{ L_MENU_DB_PORT_LABEL, "Port:" },
{ L_MENU_DB_ADDRESS_LABEL, "Address:" },
{ L_MENU_DB_SCHEMA_LABEL, "Schema:" },
{ L_MENU_DB_USERNAME_PROMPT, "Enter DB Username: " },
{ L_MENU_DB_PASSWORD_PROMPT, "Enter DB Password: " },
{ L_MENU_DB_PORT_PROMPT, "Enter DB Port: " },
{ L_MENU_DB_ADDRESS_PROMPT, "Enter DB Address: " },
{ L_MENU_DB_SCHEMA_PROMPT, "Enter Schema/DB Name: " },
{ L_MENU_DB_USERNAME_SET_MSG, "Set DB username to: " },
{ L_MENU_DB_PASSWORD_SET_MSG, "New DB password set" },
{ L_MENU_DB_PASSWORD_SET_MSG, "Set DB port to: " },
{ L_MENU_DB_ADDRESS_SET_MSG, "Set DB address to: " },
{ L_MENU_DB_SCHEMA_SET_MSG, "Set DB schema to: " },
{ L_MENU_DB_LOST_CONN_OPT_HELP_TEXT_1, "Stops exesive connection warnings when not connected to the DB." },
{ L_MENU_DB_SUPPRESS_LOST_CONN_WARNINGS_LABEL, "Suppress Connection Warnings" },
{ L_MENU_DB_USE_SSL_LABEL, "Use SSL" },
{ L_MENU_DB_SSL_CERT_PATH_LABEL, "SSL Certificate Path:" },
{ L_MENU_DB_SSL_KEY_PATH_LABEL, "SSL Private Key Path:" },
{ L_MENU_DB_SSL_CERT_PATH_PROMPT, "Enter ssl certificate path: " },
{ L_MENU_DB_SSL_KEY_PATH_PROMPT, "Enter ssl private key path: " },
{ L_MENU_DB_SSL_CERT_PATH_SET_MSG, "SSL Cert path set to: " },
{ L_MENU_DB_SSL_KEY_PATH_SET_MSG, "SSL Key path set to: " },
{ L_MENU_DB_AUTO_LOGIN_LABEL, "Automatic Login" },
{ L_MENU_DB_ATTEMPT_LOGIN_LABEL, "Attempt Login" },
{ L_MENU_DB_GO_BACK, "Go Back" },
{ L_MENU_DB_CURRENTLY_CONFIGURED_PATH, "Currently configured path:" },
// Main settings menu
{ L_MENU_M_HEADER_PAGE_TITLE, "Settings Menu" },
{ L_MENU_M_HEADER_MENU_TITLE, "Settings Menu" },
{ L_MENU_M_HELP_GENERAL_WARNING_LABEL, "WARNING:" },
{ L_MENU_M_HELP_GENERAL_WARNING_DESC_1, "Changing this value from its default value is highly experimental." },
{ L_MENU_M_HELP_GENERAL_WARNING_DESC_2, "It's recomended to leave this value " },
{ L_MENU_M_HELP_GENERAL_WARNING_DESC_3, "ENABLED" },
{ L_MENU_M_HELP_CURRENT_SELECTED_WIPE_METHOD, "Current Selected Method: " },
{ L_MENU_M_SUB_SELECT_WIPE_METHOD_LABEL, "Select Wipe Method" },
{ L_MENU_M_SUB_DB_MENU_LABEL, "Database Settings" },
{ L_MENU_M_HELP_DB_MENU_TEXT, "Configuration settings for MySQL database" },
{ L_MENU_M_SUB_OTHER_MENU_LABEL, "Other Settings" },
{ L_MENU_M_HELP_OTHER_MENU_TEXT, "Aditional reporting and misc options" },
{ L_MENU_M_OPT_USE_FINGERPRINT_LABEL, "Use Fingerprint" },
{ L_MENU_M_OPT_USE_VERIFICATION_LABEL, "Use Verification" },
{ L_MENU_M_OPT_VERIFICATION_QUOTA_LABEL, "Verification Quota" },
{ L_MENU_M_OPT_VERIFICATION_QUOTA_PROMPT, "Enter new verification quota (%): " },
{ L_MENU_M_OPT_VERIFICATION_QUOTA_SET_TEXT_BAD, "Verification Quota must be set between 1-100" },
{ L_MENU_M_OPT_VERIFICATION_QUOTA_HELPTEXT, "" },
{ L_MENU_M_OPT_ERROR_ALLOWANCE_LABEL, "Error Allowance" },
{ L_MENU_M_OPT_ERROR_ALLOWANCE_PROMPT, "Enter new error allowance: " },
{ L_MENU_M_OPT_ERROR_ALLOWANCE_SET_TEXT_BAD, "Error allowance must be set greater than 0" },
{ L_MENU_M_OPT_USE_RESUMED_ERASURE_LABEL, "Resumed Erasure Enabled" },
{ L_MENU_M_OPT_RESUMED_ERASURE_STEP_SIZE_LABEL, "Resumed Erasure Step Size" },
{ L_MENU_M_OPT_RESUMED_ERASURE_STEP_SIZE_PROMPT, "Enter new resumed erasure step size (%): " },
{ L_MENU_M_OPT_RESUMED_ERASURE_STEP_SIZE_SET_TEXT_BAD, "Resume Step Size must be set as a percentage between 1-100" },
{ L_MENU_M_OPT_CLEAR_HPAS_LABEL, "Clear HPAs If Present" },
{ L_MENU_M_OPT_RESET_DCO_LABEL, "Reset DCO" },
{ L_MENU_M_OPT_SET_JOB_NUMBER_LABEL, "Set Job#" },
{ L_MENU_M_OPT_SET_JOB_NUMBER_PROMPT, "Enter new Job#: " },
{ L_MENU_M_OPT_SET_JOB_NUMBER_SET_TEXT_GOOD, "Set current Job# to: " },
{ L_MENU_M_OPT_SET_JOB_NUMBER_SET_TEXT_BAD, "Job# entered contains illegal characters, please check to ensure you're entered it correctly" },
{ L_MENU_M_OPT_SET_ASSET_NUMBER_LABEL, "Set Asset#" },
{ L_MENU_M_OPT_SET_ASSET_NUMBER_PROMPT, "Enter new Asset#: " },
{ L_MENU_M_OPT_SET_ASSET_NUMBER_SET_TEXT_GOOD, "Set current Asset# to: " },
{ L_MENU_M_OPT_SET_ASSET_NUMBER_SET_TEXT_BAD, "Asset# entered contains illegal characters, please check to ensure you've entered it correctly" },
{ L_MENU_M_OPT_GO_BACK_LABEL, "Go Back" },
// Settings menu, Other settings
{ L_MENU_OT_HEADER_PAGE_TITLE, "Settings Menu > Other Settings" },
{ L_MENU_OT_HEADER_MENU_TITLE, "Other Settings" },
{ L_MENU_OT_OPT_USE_SQL_DUMP_LABEL, "Dump SQL Statement To File" },
{ L_MENU_OT_OPT_SQL_DUMP_OUTPUT_PATH_LABEL, "SQL Dump Output Path" },
{ L_MENU_OT_OPT_SQL_DUMP_OUTPUT_PATH_PROMPT, "Enter path to save Certificate SQL Dumps: " },
{ L_MENU_OT_OPT_SQL_DUMP_OUTPUT_PATH_SET_TEXT_GOOD, "Using sql dump path: " },
{ L_MENU_OT_OPT_SQL_DUMP_OUTPUT_PATH_SET_TEXT_BAD, "Unable to use this path, please try another" },
{ L_MENU_OT_OPT_USE_TXT_DUMP_LABEL, "Dump Cert To TXT File" },
{ L_MENU_OT_OPT_TXT_DUMP_OUTPUT_PATH_LABEL, "TXT Dump Output Path" },
{ L_MENU_OT_OPT_TXT_DUMP_OUTPUT_PATH_PROMPT, "Enter path to save Certificate TXT Dumps: " },
{ L_MENU_OT_OPT_TXT_DUMP_OUTPUT_PATH_SET_TEXT_GOOD, "Using TXT dump path: " },
{ L_MENU_OT_OPT_TXT_DUMP_OUTPUT_PATH_SET_TEXT_BAD, "Unable to use this path, please try another" },
{ L_MENU_OT_OPT_USE_PDF_DUMP_LABEL, "Save Certificate To PDF File" },
{ L_MENU_OT_OPT_PDF_DUMP_OUTPUT_PATH_LABEL, "PDF Save Path" },
{ L_MENU_OT_OPT_PDF_DUMP_OUTPUT_PATH_PROMPT, "Enter path to save Certificate PDFs: " },
{ L_MENU_OT_OPT_PDF_DUMP_OUTPUT_PATH_SET_TEXT_GOOD, "Using PDF save path: " },
{ L_MENU_OT_OPT_PDF_DUMP_OUTPUT_PATH_SET_TEXT_BAD, "Unable to use this path, please try another" },
{ L_MENU_OT_OPT_USE_BW_SAFTEY_CODE_LABEL, "Overwrite Confirm" },
{ L_MENU_OT_OPT_SET_BW_SAFTEY_CODE_LABEL, "Overwrite Confirm Code" },
{ L_MENU_OT_OPT_SET_BW_SAFTEY_CODE_PROMPT, "Enter a new confirm code phrase: " },
{ L_MENU_OT_OPT_SET_BW_SAFTEY_CODE_SET_TEXT_GOOD, "Using new confirm phrase: " },
{ L_MENU_OT_OPT_USE_SKIP_MOUNTED_DRIVES_LABEL, "Skip Mounted Drive Mapping" },
{ L_MENU_OT_OPT_USE_SKIP_MOUNTED_DRIVES_HELPTEXT_1, "If a drive is mounted on the system, it will not be mapped by the disk controller Furthermore, if a drive" },
{ L_MENU_OT_OPT_USE_SKIP_MOUNTED_DRIVES_HELPTEXT_2, "is already mapped and this setting becomes enabled; the drive will be removed from the mapping table" },
{ L_MENU_OT_OPT_SET_PLUGIN_DIR_LABEL, "Plugin Directory" },
{ L_MENU_OT_OPT_SET_PLUGIN_DIR_PROMPT, "Enter plugin directory: " },
{ L_MENU_OT_OPT_SET_PLUGIN_DIR_SET_TEXT_GOOD_1, "Plugin directory set to: " },
{ L_MENU_OT_OPT_SET_PLUGIN_DIR_SET_TEXT_GOOD_2, "Restart applcation for this change to take effect" },
{ L_MENU_OT_OPT_GO_BACK_LABEL, "Go Back" },
{ L_MENU_OT_GEN_HELPTEXT_CURRENTLY_CONFIGURED_PATH, "Currently configured path: " },
{ L_MENU_OT_BW_SAFTEY_CODE_CURRENTLY_CONFIGURED_CODE, "Current code phrase: " },
// ViewWindowController
{ L_VC_HEADER_VERSION_BUILD, "Build: " },
{ L_VC_HEADER_VERSION_BUILD_UNKNOWN, "Build: UNKNOWN"},
{ L_VC_HEADER_VERSION_BRANCH, " Branch: " },
{ L_VC_HEADER_CONN_STATUS, "Status: " },
{ L_VC_HEADER_CONN_STATUS_GOOD, "Logged In" },
{ L_VC_HEADER_CONN_STATUS_BAD, "Logged Out" },
// General
{ L_YES, "YES" },
{ L_NO, "NO"},
{ L_NA, "N/A" },
{ L_SUCCESS, "SUCCESS" },
{ L_FAILED, "FAILED" }
});
}
}
// Thetadyn Datarazer Copyright (c) 2023 Thetadyn LLC, All Rights Reserved.
// Sample Datarazer language pack plugin
#ifndef _DATARAZER_LOCALE_LENGLISH_H_
#define _DATARAZER_LOCALE_LENGLISH_H_
#include "locale/LKey.h"
#include <map>
namespace my_plugin {
struct LEnglish {
static std::map<locale::LKey, std::string> Get();
};
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment