auto state = item->getState();
Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, state);
if (!state) {
- auto buf = TranslatedString{"IDS_ST_MBODY_SCREEN_READER_HTTS"}.str() + " " +
- TranslatedString{"IDS_ST_BODY_OFF"}.str();
- Singleton<TextToSpeech>::instance().play(buf);
+ auto buf = TranslatedString{"IDS_ST_MBODY_SCREEN_READER_HTTS"} + " " + TranslatedString{"IDS_ST_BODY_OFF"};
+ Singleton<TextToSpeech>::instance().play(buf.str());
}
},
GenlistItem::WidgetType::toggle});
TranslatedString::TranslatedString(const std::string &str)
: value(std::string{gettext(str.c_str())})
-{
-}
+{}
TranslatedString::TranslatedString(const char *str)
: value(std::string{gettext(str), strlen(gettext(str))})
+{}
+
+TranslatedString &TranslatedString::operator+=(const TranslatedString &ts)
{
+ value += ts.value;
+ return *this;
}
bool TranslatedString::empty() const
{
return value.c_str();
}
+
+TranslatedString operator+(TranslatedString lString, const TranslatedString &rString)
+{
+ lString += rString;
+ return lString;
+}
\ No newline at end of file
#ifndef TRANSLATED_STRING_HPP
#define TRANSLATED_STRING_HPP
+#include "AccessibilitySettingLog.hpp"
+
#include <string>
/**
* Class containing strings translated with usage of internatonalization API
TranslatedString(const std::string &str);
TranslatedString(const char *str);
+ TranslatedString &operator+=(const TranslatedString &ts);
+
+ template <typename... ARGS>
+ static TranslatedString create(const char *str, const ARGS &... args)
+ {
+ char buf[1024] = {0};
+ auto ret = snprintf(buf, sizeof(buf), gettext(str), args...);
+ if (ret > 1024) {
+ ERROR("snprintf failed");
+ return {};
+ }
+ return {buf};
+ }
+
bool empty() const;
std::string str() const;
std::string value;
};
+TranslatedString operator+(TranslatedString lString, const TranslatedString &rString);
+
#endif
"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_PAUSE_ON_FIRST",
str,
[this](auto item) {
- char str[512] = {0,};
- auto ret = snprintf(str, sizeof(str), _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SET_VALUE_DESC_PAUSE_ON_FIRST"), context_.us_configuration.auto_scan_interval, context_.us_configuration.auto_scan_interval + context_.us_configuration.pause_on_first_value);
- if (ret > 511) {
- ERROR("snprintf failed");
- return;
- }
-
setValuePage_ = std::make_unique<SetValuePage>(ValueEditorType::NUMERIC_SWITCH, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_PAUSE_ON_FIRST"));
setValuePage_->setSwitch(context_.us_configuration.pause_on_first_state);
setValuePage_->addValueChangedCb([this](auto val) {
setValuePage_->addSwitchChangedCb([this](auto state) {
this->pauseOnFirstSwitchChangedCb(state);
});
- setValuePage_->setDescription(str);
+ //FIXME: below description is not displayed at runtime
+ auto totalPauseOnFirstItem = context_.us_configuration.auto_scan_interval + context_.us_configuration.pause_on_first_value;
+ setValuePage_->setDescription(TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SET_VALUE_DESC_PAUSE_ON_FIRST", context_.us_configuration.auto_scan_interval, totalPauseOnFirstItem).c_str());
setValuePage_->setRange(RANGE_MIN_PAUSE_ON_FIRST, RANGE_MAX_PAUSE_ON_FIRST, STEP_PAUSE_ON_FIRST);
setValuePage_->setValue(context_.us_configuration.pause_on_first_value, "seconds"); },
[this](auto item) {