Format: use fmt::format correctly with runtime format strings

The `fmt::format` can process the format string at compile time. Currently, we
don't seem to be using that as we don't use `FMT_STRING`. Starting with C++20,
that will be the default though, and one has to explicitly opt out in places
where the string is not known at compile time using `fmt::runtime(...)`.
Currently, our code does not compile as C++20 because of that. Unfortunately, we
have many places with runtime format strings, because of i18n.

Pull Request: https://projects.blender.org/blender/blender/pulls/130392
This commit is contained in:
Jacques Lucke
2024-11-20 10:41:29 +01:00
parent 251731accc
commit e62aa986b2
31 changed files with 254 additions and 200 deletions

View File

@@ -95,78 +95,87 @@ void CombinedKeyingResult::generate_reports(ReportList *reports, const eReportTy
Vector<std::string> errors;
if (this->get_count(SingleKeyingResult::UNKNOWN_FAILURE) > 0) {
const int error_count = this->get_count(SingleKeyingResult::UNKNOWN_FAILURE);
errors.append(
fmt::format(RPT_("There were {:d} keying failures for unknown reasons."), error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("There were {:d} keying failures for unknown reasons.")), error_count));
}
if (this->get_count(SingleKeyingResult::CANNOT_CREATE_FCURVE) > 0) {
const int error_count = this->get_count(SingleKeyingResult::CANNOT_CREATE_FCURVE);
errors.append(fmt::format(RPT_("Could not create {:d} F-Curve(s). This can happen when only "
"inserting to available F-Curves."),
error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("Could not create {:d} F-Curve(s). This can happen when only "
"inserting to available F-Curves.")),
error_count));
}
if (this->get_count(SingleKeyingResult::FCURVE_NOT_KEYFRAMEABLE) > 0) {
const int error_count = this->get_count(SingleKeyingResult::FCURVE_NOT_KEYFRAMEABLE);
errors.append(
fmt::format(RPT_("{:d} F-Curve(s) are not keyframeable. They might be locked or sampled."),
fmt::format(fmt::runtime(RPT_(
"{:d} F-Curve(s) are not keyframeable. They might be locked or sampled.")),
error_count));
}
if (this->get_count(SingleKeyingResult::NO_KEY_NEEDED) > 0) {
const int error_count = this->get_count(SingleKeyingResult::NO_KEY_NEEDED);
errors.append(fmt::format(
RPT_("Due to the setting 'Only Insert Needed', {:d} keyframe(s) have not been inserted."),
fmt::runtime(RPT_(
"Due to the setting 'Only Insert Needed', {:d} keyframe(s) have not been inserted.")),
error_count));
}
if (this->get_count(SingleKeyingResult::UNABLE_TO_INSERT_TO_NLA_STACK) > 0) {
const int error_count = this->get_count(SingleKeyingResult::UNABLE_TO_INSERT_TO_NLA_STACK);
errors.append(
fmt::format(RPT_("Due to the NLA stack setup, {:d} keyframe(s) have not been inserted."),
error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("Due to the NLA stack setup, {:d} keyframe(s) have not been inserted.")),
error_count));
}
if (this->get_count(SingleKeyingResult::ID_NOT_EDITABLE) > 0) {
const int error_count = this->get_count(SingleKeyingResult::ID_NOT_EDITABLE);
errors.append(fmt::format(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"they are not editable."),
error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"they are not editable.")),
error_count));
}
if (this->get_count(SingleKeyingResult::ID_NOT_ANIMATABLE) > 0) {
const int error_count = this->get_count(SingleKeyingResult::ID_NOT_ANIMATABLE);
errors.append(fmt::format(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"they cannot be animated."),
error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"they cannot be animated.")),
error_count));
}
if (this->get_count(SingleKeyingResult::CANNOT_RESOLVE_PATH) > 0) {
const int error_count = this->get_count(SingleKeyingResult::CANNOT_RESOLVE_PATH);
errors.append(fmt::format(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"the RNA path wasn't valid for them."),
error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"the RNA path wasn't valid for them.")),
error_count));
}
if (this->get_count(SingleKeyingResult::NO_VALID_LAYER) > 0) {
const int error_count = this->get_count(SingleKeyingResult::NO_VALID_LAYER);
errors.append(fmt::format(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"there were no layers that could accept the keys."),
error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"there were no layers that could accept the keys.")),
error_count));
}
if (this->get_count(SingleKeyingResult::NO_VALID_STRIP) > 0) {
const int error_count = this->get_count(SingleKeyingResult::NO_VALID_STRIP);
errors.append(fmt::format(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"there were no strips that could accept the keys."),
error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"there were no strips that could accept the keys.")),
error_count));
}
if (this->get_count(SingleKeyingResult::NO_VALID_SLOT) > 0) {
const int error_count = this->get_count(SingleKeyingResult::NO_VALID_SLOT);
errors.append(fmt::format(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"of missing action slots."),
error_count));
errors.append(fmt::format(
fmt::runtime(RPT_("Inserting keys on {:d} data-block(s) has been skipped because "
"of missing action slots.")),
error_count));
}
if (errors.is_empty()) {

View File

@@ -455,7 +455,7 @@ std::string AttributeFieldInput::socket_inspection_name() const
if (socket_inspection_name_) {
return *socket_inspection_name_;
}
return fmt::format(TIP_("\"{}\" attribute from geometry"), name_);
return fmt::format(fmt::runtime(TIP_("\"{}\" attribute from geometry")), name_);
}
uint64_t AttributeFieldInput::hash() const

View File

@@ -104,7 +104,7 @@ struct VolumeToMeshOp {
grid, this->verts, this->tris, this->quads, this->threshold, this->adaptivity);
}
catch (const std::exception &e) {
this->error = fmt::format(TIP_("OpenVDB error: {}"), e.what());
this->error = fmt::format(fmt::runtime(TIP_("OpenVDB error: {}")), e.what());
this->verts.clear();
this->tris.clear();
this->quads.clear();

View File

@@ -1791,7 +1791,7 @@ static const char *get_alloc_name(FileData *fd,
keyT key{block_alloc_name + struct_name, bh->nr};
if (!storage.contains(key)) {
const std::string alloc_string = fmt::format(
(is_id_data ? "{}{} (for ID type '{}')" : "{}{} (for block '{}')"),
fmt::runtime((is_id_data ? "{}{} (for ID type '{}')" : "{}{} (for block '{}')")),
struct_name,
bh->nr > 1 ? fmt::format("[{}]", bh->nr) : "",
block_alloc_name);

View File

@@ -231,7 +231,7 @@ class Instance {
/* Append a new line to the info string. */
template<typename... Args> void info_append(const char *msg, Args &&...args)
{
info_ += fmt::format(msg, args...);
info_ += fmt::format(fmt::runtime(msg), args...);
info_ += "\n";
}
@@ -239,7 +239,7 @@ class Instance {
* NOTE: When calling this function, `msg` should be a string literal. */
template<typename... Args> void info_append_i18n(const char *msg, Args &&...args)
{
std::string fmt_msg = fmt::format(RPT_(msg), args...) + "\n";
std::string fmt_msg = fmt::format(fmt::runtime(RPT_(msg)), args...) + "\n";
/* Don't print the same error twice. */
if (info_ != fmt_msg && !BLI_str_endswith(info_.c_str(), fmt_msg.c_str())) {
info_ += fmt_msg;

View File

@@ -618,12 +618,12 @@ static void grease_pencil_primitive_status_indicators(bContext *C,
return WM_modalkeymap_operator_items_to_string(op->type, int(id), true).value_or("");
};
header += fmt::format(IFACE_("{}: confirm, {}: cancel, {}: panning, Shift: align"),
header += fmt::format(fmt::runtime(IFACE_("{}: confirm, {}: cancel, {}: panning, Shift: align")),
get_modal_key_str(ModalKeyMode::Confirm),
get_modal_key_str(ModalKeyMode::Cancel),
get_modal_key_str(ModalKeyMode::Panning));
header += fmt::format(IFACE_(", {}/{}: adjust subdivisions: {}"),
header += fmt::format(fmt::runtime(IFACE_(", {}/{}: adjust subdivisions: {}")),
get_modal_key_str(ModalKeyMode::IncreaseSubdivision),
get_modal_key_str(ModalKeyMode::DecreaseSubdivision),
int(ptd.subdivision));
@@ -638,10 +638,11 @@ static void grease_pencil_primitive_status_indicators(bContext *C,
PrimitiveType::Arc,
PrimitiveType::Curve))
{
header += fmt::format(IFACE_(", {}: extrude"), get_modal_key_str(ModalKeyMode::Extrude));
header += fmt::format(fmt::runtime(IFACE_(", {}: extrude")),
get_modal_key_str(ModalKeyMode::Extrude));
}
header += fmt::format(IFACE_(", {}: grab, {}: rotate, {}: scale"),
header += fmt::format(fmt::runtime(IFACE_(", {}: grab, {}: rotate, {}: scale")),
get_modal_key_str(ModalKeyMode::Grab),
get_modal_key_str(ModalKeyMode::Rotate),
get_modal_key_str(ModalKeyMode::Scale));

View File

@@ -129,20 +129,22 @@ static std::string ui_drop_material_tooltip(bContext *C,
const char *dragged_material_name = WM_drag_get_item_name(drag);
if (prev_mat_in_slot) {
return fmt::format(TIP_("Drop {} on slot {} (replacing {}) of {}"),
return fmt::format(fmt::runtime(TIP_("Drop {} on slot {} (replacing {}) of {}")),
dragged_material_name,
target_slot,
prev_mat_in_slot->id.name + 2,
ob->id.name + 2);
}
if (target_slot == ob->actcol) {
return fmt::format(TIP_("Drop {} on slot {} (active slot) of {}"),
return fmt::format(fmt::runtime(TIP_("Drop {} on slot {} (active slot) of {}")),
dragged_material_name,
target_slot,
ob->id.name + 2);
}
return fmt::format(
TIP_("Drop {} on slot {} of {}"), dragged_material_name, target_slot, ob->id.name + 2);
return fmt::format(fmt::runtime(TIP_("Drop {} on slot {} of {}")),
dragged_material_name,
target_slot,
ob->id.name + 2);
}
/** \} */

View File

@@ -405,7 +405,7 @@ static bool ui_tooltip_data_append_from_keymap(bContext *C, uiTooltipData &data,
/* Shortcut. */
const std::string kmi_str = WM_keymap_item_to_string(kmi, false).value_or("None");
UI_tooltip_text_field_add(data,
fmt::format(TIP_("Shortcut: {}"), kmi_str),
fmt::format(fmt::runtime(TIP_("Shortcut: {}")), kmi_str),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
@@ -413,8 +413,11 @@ static bool ui_tooltip_data_append_from_keymap(bContext *C, uiTooltipData &data,
/* Python. */
if (U.flag & USER_TOOLTIPS_PYTHON) {
std::string str = ui_tooltip_text_python_from_op(C, ot, kmi->ptr);
UI_tooltip_text_field_add(
data, fmt::format(TIP_("Python: {}"), str), {}, UI_TIP_STYLE_MONO, UI_TIP_LC_PYTHON);
UI_tooltip_text_field_add(data,
fmt::format(fmt::runtime(TIP_("Python: {}")), str),
{},
UI_TIP_STYLE_MONO,
UI_TIP_LC_PYTHON);
}
}
@@ -654,7 +657,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_tool(bContext *C,
if (!shortcut.empty()) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Shortcut: {}"), shortcut),
fmt::format(fmt::runtime(TIP_("Shortcut: {}")), shortcut),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE,
@@ -726,7 +729,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_tool(bContext *C,
if (shortcut) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Shortcut Cycle: {}"), *shortcut),
fmt::format(fmt::runtime(TIP_("Shortcut Cycle: {}")), *shortcut),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE,
@@ -739,7 +742,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_tool(bContext *C,
if ((is_label == false) && (U.flag & USER_TOOLTIPS_PYTHON)) {
std::string str = ui_tooltip_text_python_from_op(C, but->optype, but->opptr);
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Python: {}"), str),
fmt::format(fmt::runtime(TIP_("Python: {}")), str),
{},
UI_TIP_STYLE_MONO,
UI_TIP_LC_PYTHON,
@@ -903,7 +906,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
/* Operator shortcut. */
if (!op_keymap.empty()) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Shortcut: {}"), op_keymap),
fmt::format(fmt::runtime(TIP_("Shortcut: {}")), op_keymap),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE,
@@ -913,7 +916,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
/* Property context-toggle shortcut. */
if (!prop_keymap.empty()) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Shortcut: {}"), prop_keymap),
fmt::format(fmt::runtime(TIP_("Shortcut: {}")), prop_keymap),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE,
@@ -927,7 +930,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
ui_but_string_get(but, buf, sizeof(buf));
if (buf[0]) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Value: {}"), buf),
fmt::format(fmt::runtime(TIP_("Value: {}")), buf),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE,
@@ -945,7 +948,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
RNA_property_float_get_index(&but->rnapoin, rnaprop, but->rnaindex) :
RNA_property_float_get(&but->rnapoin, rnaprop);
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Radians: {}"), value),
fmt::format(fmt::runtime(TIP_("Radians: {}")), value),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE);
@@ -955,7 +958,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
if (but->flag & UI_BUT_DRIVEN) {
if (ui_but_anim_expression_get(but, buf, sizeof(buf))) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Expression: {}"), buf),
fmt::format(fmt::runtime(TIP_("Expression: {}")), buf),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
@@ -965,11 +968,12 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
if (but->rnapoin.owner_id) {
const ID *id = but->rnapoin.owner_id;
if (ID_IS_LINKED(id)) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Library: {}"), id->lib->filepath),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
UI_tooltip_text_field_add(
*data,
fmt::format(fmt::runtime(TIP_("Library: {}")), id->lib->filepath),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
}
}
}
@@ -986,7 +990,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
/* Operator info. */
if (U.flag & USER_TOOLTIPS_PYTHON) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Python: {}"), str),
fmt::format(fmt::runtime(TIP_("Python: {}")), str),
{},
UI_TIP_STYLE_MONO,
UI_TIP_LC_PYTHON,
@@ -1019,7 +1023,7 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
if (disabled_msg && disabled_msg[0]) {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Disabled: {}"), disabled_msg),
fmt::format(fmt::runtime(TIP_("Disabled: {}")), disabled_msg),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_ALERT);
@@ -1031,14 +1035,15 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
if ((U.flag & USER_TOOLTIPS_PYTHON) && !optype && !rna_struct.empty()) {
{
UI_tooltip_text_field_add(*data,
rna_prop.empty() ?
fmt::format(TIP_("Python: {}"), rna_struct) :
fmt::format(TIP_("Python: {}.{}"), rna_struct, rna_prop),
{},
UI_TIP_STYLE_MONO,
UI_TIP_LC_PYTHON,
(data->fields.size() > 0));
UI_tooltip_text_field_add(
*data,
rna_prop.empty() ?
fmt::format(fmt::runtime(TIP_("Python: {}")), rna_struct) :
fmt::format(fmt::runtime(TIP_("Python: {}.{}")), rna_struct, rna_prop),
{},
UI_TIP_STYLE_MONO,
UI_TIP_LC_PYTHON,
(data->fields.size() > 0));
}
if (but->rnapoin.owner_id) {
@@ -1184,12 +1189,13 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_gizmo(bContext *C, wm
if (std::optional<std::string> shortcut_str = WM_key_event_operator_string(
C, gzop->type->idname, WM_OP_INVOKE_DEFAULT, prop, true))
{
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Shortcut: {}"), *shortcut_str),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE,
true);
UI_tooltip_text_field_add(
*data,
fmt::format(fmt::runtime(TIP_("Shortcut: {}")), *shortcut_str),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_VALUE,
true);
}
}
}
@@ -1622,8 +1628,11 @@ static void ui_tooltip_from_image(Image &ima, uiTooltipData &data)
UI_tooltip_text_field_add(
data, ima.colorspace_settings.name, {}, UI_TIP_STYLE_NORMAL, UI_TIP_LC_NORMAL);
UI_tooltip_text_field_add(
data, fmt::format(TIP_("Users: {}"), ima.id.us), {}, UI_TIP_STYLE_NORMAL, UI_TIP_LC_NORMAL);
UI_tooltip_text_field_add(data,
fmt::format(fmt::runtime(TIP_("Users: {}")), ima.id.us),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
if (ibuf) {
uiTooltipImage image_data;
@@ -1748,22 +1757,24 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_search_item_tooltip_d
ui_tooltip_from_vfont(*reinterpret_cast<VFont *>(id), *data);
}
else {
UI_tooltip_text_field_add(*data,
fmt::format(TIP_("Choose {} data-block to be assigned to this user"),
BKE_idtype_idcode_to_name(GS(id->name))),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
UI_tooltip_text_field_add(
*data,
fmt::format(fmt::runtime(TIP_("Choose {} data-block to be assigned to this user")),
BKE_idtype_idcode_to_name(GS(id->name))),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
}
/** Additional info about the item (e.g. library name of a linked data-block). */
if (ID_IS_LINKED(id)) {
UI_tooltip_text_field_add(
*data,
fmt::format(TIP_("Source library: {}\n{}"), id->lib->id.name + 2, id->lib->filepath),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
UI_tooltip_text_field_add(*data,
fmt::format(fmt::runtime(TIP_("Source library: {}\n{}")),
id->lib->id.name + 2,
id->lib->filepath),
{},
UI_TIP_STYLE_NORMAL,
UI_TIP_LC_NORMAL);
}
return data->fields.is_empty() ? nullptr : std::move(data);

View File

@@ -141,11 +141,11 @@ class BoneCollectionDropTarget : public TreeViewItemDropTarget {
switch (drag_info.drop_location) {
case DropLocation::Into:
return fmt::format(TIP_("Move {} into {}"), drag_name, drop_name);
return fmt::format(fmt::runtime(TIP_("Move {} into {}")), drag_name, drop_name);
case DropLocation::Before:
return fmt::format(TIP_("Move {} above {}"), drag_name, drop_name);
return fmt::format(fmt::runtime(TIP_("Move {} above {}")), drag_name, drop_name);
case DropLocation::After:
return fmt::format(TIP_("Move {} below {}"), drag_name, drop_name);
return fmt::format(fmt::runtime(TIP_("Move {} below {}")), drag_name, drop_name);
}
return "";

View File

@@ -82,11 +82,14 @@ class LayerNodeDropTarget : public TreeViewItemDropTarget {
switch (drag_info.drop_location) {
case DropLocation::Into:
return fmt::format(TIP_("Move {} {} into {}"), node_type, drag_name, drop_name);
return fmt::format(
fmt::runtime(TIP_("Move {} {} into {}")), node_type, drag_name, drop_name);
case DropLocation::Before:
return fmt::format(TIP_("Move {} {} above {}"), node_type, drag_name, drop_name);
return fmt::format(
fmt::runtime(TIP_("Move {} {} above {}")), node_type, drag_name, drop_name);
case DropLocation::After:
return fmt::format(TIP_("Move {} {} below {}"), node_type, drag_name, drop_name);
return fmt::format(
fmt::runtime(TIP_("Move {} {} below {}")), node_type, drag_name, drop_name);
default:
BLI_assert_unreachable();
break;

View File

@@ -139,9 +139,9 @@ class ReorderCollectionDropTarget : public TreeViewItemDropTarget {
case DropLocation::Into:
return "Add to linking collection";
case DropLocation::Before:
return fmt::format(TIP_("Add to linking collection before {}"), drop_name);
return fmt::format(fmt::runtime(TIP_("Add to linking collection before {}")), drop_name);
case DropLocation::After:
return fmt::format(TIP_("Add to linking collection after {}"), drop_name);
return fmt::format(fmt::runtime(TIP_("Add to linking collection after {}")), drop_name);
}
return "";

View File

@@ -6597,8 +6597,9 @@ static std::string ui_template_status_tooltip(bContext *C, void * /*argN*/, cons
char writer_ver_str[12];
BKE_blender_version_blendfile_string_from_values(
writer_ver_str, sizeof(writer_ver_str), bmain->versionfile, -1);
tooltip_message += fmt::format(RPT_("File saved by newer Blender\n({}), expect loss of data"),
writer_ver_str);
tooltip_message += fmt::format(
fmt::runtime(RPT_("File saved by newer Blender\n({}), expect loss of data")),
writer_ver_str);
}
if (bmain->is_asset_edit_file) {
if (!tooltip_message.empty()) {

View File

@@ -38,7 +38,7 @@ int filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent * /*ev
title = files[0];
}
else {
title = fmt::format(TIP_("Import {} files"), files.size());
title = fmt::format(fmt::runtime(TIP_("Import {} files")), files.size());
}
}
else {

View File

@@ -8113,11 +8113,11 @@ static void point_normals_update_header(bContext *C, wmOperator *op)
};
const std::string header = fmt::format(
IFACE_("{}: confirm, {}: cancel, "
"{}: point to mouse ({}), {}: point to Pivot, "
"{}: point to object origin, {}: reset normals, "
"{}: set & point to 3D cursor, {}: select & point to mesh item, "
"{}: invert normals ({}), {}: spherize ({}), {}: align ({})"),
fmt::runtime(IFACE_("{}: confirm, {}: cancel, "
"{}: point to mouse ({}), {}: point to Pivot, "
"{}: point to object origin, {}: reset normals, "
"{}: set & point to 3D cursor, {}: select & point to mesh item, "
"{}: invert normals ({}), {}: spherize ({}), {}: align ({})")),
get_modal_key_str(EDBM_CLNOR_MODAL_CONFIRM),
get_modal_key_str(EDBM_CLNOR_MODAL_CANCEL),
get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_USE_MOUSE),

View File

@@ -2934,13 +2934,14 @@ std::string drop_named_material_tooltip(bContext *C, const char *name, const int
Material *prev_mat = BKE_object_material_get(ob, mat_slot);
if (prev_mat) {
return fmt::format(TIP_("Drop {} on {} (slot {}, replacing {})"),
return fmt::format(fmt::runtime(TIP_("Drop {} on {} (slot {}, replacing {})")),
name,
ob->id.name + 2,
mat_slot,
prev_mat->id.name + 2);
}
return fmt::format(TIP_("Drop {} on {} (slot {})"), name, ob->id.name + 2, mat_slot);
return fmt::format(
fmt::runtime(TIP_("Drop {} on {} (slot {})")), name, ob->id.name + 2, mat_slot);
}
static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -3004,8 +3005,9 @@ std::string drop_geometry_nodes_tooltip(bContext *C, PointerRNA *properties, con
return {};
}
return fmt::format(
TIP_("Add modifier with node group \"{}\" on object \"{}\""), id->name, ob->id.name);
return fmt::format(fmt::runtime(TIP_("Add modifier with node group \"{}\" on object \"{}\"")),
id->name,
ob->id.name);
}
static bool check_geometry_node_group_sockets(wmOperator *op, const bNodeTree *tree)

View File

@@ -5880,7 +5880,7 @@ static std::string userpref_show_get_description(bContext *C,
int section = RNA_property_enum_get(ptr, prop);
const char *section_name;
if (RNA_property_enum_name_gettexted(C, ptr, prop, section, &section_name)) {
return fmt::format(TIP_("Show {} preferences"), section_name);
return fmt::format(fmt::runtime(TIP_("Show {} preferences")), section_name);
}
}
/* Fallback to default. */

View File

@@ -1052,8 +1052,9 @@ static void grease_pencil_fill_status_indicators(bContext &C,
const bool is_extend = (op_data.extension_mode == GP_FILL_EMODE_EXTEND);
const std::string status_str = fmt::format(
IFACE_("Fill: ESC/RMB cancel, LMB Fill, MMB Adjust Extension, S: "
"Switch Mode, D: Stroke Collision | Mode: {}, Collision {}, Length: {:.3f}"),
fmt::runtime(
IFACE_("Fill: ESC/RMB cancel, LMB Fill, MMB Adjust Extension, S: "
"Switch Mode, D: Stroke Collision | Mode: {}, Collision {}, Length: {:.3f}")),
(is_extend) ? IFACE_("Extend") : IFACE_("Radius"),
(is_extend && op_data.extension_cut) ? IFACE_("ON") : IFACE_("OFF"),
op_data.extension_length);

View File

@@ -406,8 +406,9 @@ std::string AssetCatalogDropTarget::drop_tooltip_asset_catalog(const wmDrag &dra
BLI_assert(drag.type == WM_DRAG_ASSET_CATALOG);
const AssetCatalog *src_catalog = this->get_drag_catalog(drag, get_asset_library());
return fmt::format(
TIP_("Move catalog {} into {}"), src_catalog->path.name(), catalog_item_.get_name());
return fmt::format(fmt::runtime(TIP_("Move catalog {} into {}")),
src_catalog->path.name(),
catalog_item_.get_name());
}
std::string AssetCatalogDropTarget::drop_tooltip_asset_list(const wmDrag &drag) const
@@ -625,7 +626,7 @@ std::string AssetCatalogTreeViewAllItem::DropTarget::drop_tooltip(
const AssetCatalog *drag_catalog = AssetCatalogDropTarget::get_drag_catalog(
drag_info.drag_data, *this->get_view<AssetCatalogTreeView>().asset_library_);
return fmt::format(TIP_("Move catalog {} to the top level of the tree"),
return fmt::format(fmt::runtime(TIP_("Move catalog {} to the top level of the tree")),
drag_catalog->path.name());
}

View File

@@ -267,7 +267,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent * /*even
}
const std::string title = fmt::format(
IFACE_("Unpack - Files: {}, Bakes: {}"), count.individual_files, count.bakes);
fmt::runtime(IFACE_("Unpack - Files: {}, Bakes: {}")), count.individual_files, count.bakes);
pup = UI_popup_menu_begin(C, title.c_str(), ICON_NONE);
layout = UI_popup_menu_layout(pup);

View File

@@ -1552,9 +1552,9 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
fmt::memory_buffer &buf)
{
auto id_to_inspection_string = [&](const ID *id, const short idcode) {
fmt::format_to(fmt::appender(buf), (id ? id->name + 2 : TIP_("None")));
fmt::format_to(fmt::appender(buf), "{}", id ? id->name + 2 : TIP_("None"));
fmt::format_to(fmt::appender(buf), " (");
fmt::format_to(fmt::appender(buf), TIP_(BKE_idtype_idcode_to_name(idcode)));
fmt::format_to(fmt::appender(buf), "{}", TIP_(BKE_idtype_idcode_to_name(idcode)));
fmt::format_to(fmt::appender(buf), ")");
};
@@ -1581,8 +1581,9 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
return;
}
if (value_type.is<std::string>()) {
fmt::format_to(
fmt::appender(buf), TIP_("{} (String)"), *static_cast<const std::string *>(buffer));
fmt::format_to(fmt::appender(buf),
fmt::runtime(TIP_("{} (String)")),
*static_cast<const std::string *>(buffer));
return;
}
@@ -1605,7 +1606,7 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
if (!enum_item) {
return;
}
fmt::format_to(fmt::appender(buf), TIP_("{} (Menu)"), enum_item->name);
fmt::format_to(fmt::appender(buf), fmt::runtime(TIP_("{} (Menu)")), enum_item->name);
return;
}
@@ -1621,7 +1622,8 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
BLI_SCOPED_DEFER([&]() { socket_type.destruct(socket_value); });
if (socket_type.is<int>()) {
fmt::format_to(fmt::appender(buf), TIP_("{} (Integer)"), *static_cast<int *>(socket_value));
fmt::format_to(
fmt::appender(buf), fmt::runtime(TIP_("{} (Integer)")), *static_cast<int *>(socket_value));
}
else if (socket_type.is<float>()) {
const float float_value = *static_cast<float *>(socket_value);
@@ -1629,21 +1631,28 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
if (std::abs(float_value) > (1 << 24)) {
/* Use higher precision to display correct integer value instead of one that is rounded to
* fewer significant digits. */
fmt::format_to(fmt::appender(buf), TIP_("{:.10} (Float)"), float_value);
fmt::format_to(fmt::appender(buf), fmt::runtime(TIP_("{:.10} (Float)")), float_value);
}
else {
fmt::format_to(fmt::appender(buf), TIP_("{} (Float)"), float_value);
fmt::format_to(fmt::appender(buf), fmt::runtime(TIP_("{} (Float)")), float_value);
}
}
else if (socket_type.is<blender::float3>()) {
const blender::float3 &vector = *static_cast<blender::float3 *>(socket_value);
fmt::format_to(
fmt::appender(buf), TIP_("({}, {}, {}) (Vector)"), vector.x, vector.y, vector.z);
fmt::format_to(fmt::appender(buf),
fmt::runtime(TIP_("({}, {}, {}) (Vector)")),
vector.x,
vector.y,
vector.z);
}
else if (socket_type.is<blender::ColorGeometry4f>()) {
const blender::ColorGeometry4f &color = *static_cast<blender::ColorGeometry4f *>(socket_value);
fmt::format_to(
fmt::appender(buf), TIP_("({}, {}, {}, {}) (Color)"), color.r, color.g, color.b, color.a);
fmt::format_to(fmt::appender(buf),
fmt::runtime(TIP_("({}, {}, {}, {}) (Color)")),
color.r,
color.g,
color.b,
color.a);
}
else if (socket_type.is<math::Quaternion>()) {
const math::Quaternion &rotation = *static_cast<math::Quaternion *>(socket_value);
@@ -1654,11 +1663,11 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
euler.x().degree(),
euler.y().degree(),
euler.z().degree());
fmt::format_to(fmt::appender(buf), TIP_("(Rotation)"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("(Rotation)"));
}
else if (socket_type.is<bool>()) {
fmt::format_to(fmt::appender(buf),
TIP_("{} (Boolean)"),
fmt::runtime(TIP_("{} (Boolean)")),
((*static_cast<bool *>(socket_value)) ? TIP_("True") : TIP_("False")));
}
else if (socket_type.is<float4x4>()) {
@@ -1670,7 +1679,7 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
ss << value[2] << ",\n";
ss << value[3] << ",\n";
buf.append(ss.str());
fmt::format_to(fmt::appender(buf), TIP_("(Matrix)"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("(Matrix)"));
}
}
@@ -1684,35 +1693,35 @@ static void create_inspection_string_for_field_info(const bNodeSocket &socket,
if (input_tooltips.is_empty()) {
/* Should have been logged as constant value. */
BLI_assert_unreachable();
fmt::format_to(fmt::appender(buf), TIP_("Value has not been logged"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Value has not been logged"));
}
else {
if (socket_type.is<int>()) {
fmt::format_to(fmt::appender(buf), TIP_("Integer field based on:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Integer field based on:"));
}
else if (socket_type.is<float>()) {
fmt::format_to(fmt::appender(buf), TIP_("Float field based on:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Float field based on:"));
}
else if (socket_type.is<blender::float3>()) {
fmt::format_to(fmt::appender(buf), TIP_("Vector field based on:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Vector field based on:"));
}
else if (socket_type.is<bool>()) {
fmt::format_to(fmt::appender(buf), TIP_("Boolean field based on:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Boolean field based on:"));
}
else if (socket_type.is<std::string>()) {
fmt::format_to(fmt::appender(buf), TIP_("String field based on:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("String field based on:"));
}
else if (socket_type.is<blender::ColorGeometry4f>()) {
fmt::format_to(fmt::appender(buf), TIP_("Color field based on:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Color field based on:"));
}
else if (socket_type.is<math::Quaternion>()) {
fmt::format_to(fmt::appender(buf), TIP_("Rotation field based on:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Rotation field based on:"));
}
fmt::format_to(fmt::appender(buf), "\n");
for (const int i : input_tooltips.index_range()) {
const blender::StringRefNull tooltip = input_tooltips[i];
fmt::format_to(fmt::appender(buf), TIP_("\u2022 {}"), TIP_(tooltip.c_str()));
fmt::format_to(fmt::appender(buf), fmt::runtime(TIP_("\u2022 {}")), TIP_(tooltip.c_str()));
if (i < input_tooltips.size() - 1) {
fmt::format_to(fmt::appender(buf), ".\n");
}
@@ -1731,18 +1740,18 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn
if (value_log.grid_info) {
const geo_log::GeometryInfoLog::GridInfo &grid_info = *value_log.grid_info;
fmt::format_to(fmt::appender(buf),
grid_info.is_empty ? TIP_("Empty Grid") : TIP_("\u2022 Grid"));
fmt::format_to(
fmt::appender(buf), "{}", grid_info.is_empty ? TIP_("Empty Grid") : TIP_("\u2022 Grid"));
return;
}
Span<bke::GeometryComponent::Type> component_types = value_log.component_types;
if (component_types.is_empty()) {
fmt::format_to(fmt::appender(buf), TIP_("Empty Geometry"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Empty Geometry"));
return;
}
fmt::format_to(fmt::appender(buf), TIP_("Geometry:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Geometry:"));
if (!value_log.name.empty()) {
fmt::format_to(fmt::appender(buf), " \"{}\"", value_log.name);
}
@@ -1752,7 +1761,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn
case bke::GeometryComponent::Type::Mesh: {
const geo_log::GeometryInfoLog::MeshInfo &mesh_info = *value_log.mesh_info;
fmt::format_to(fmt::appender(buf),
TIP_("\u2022 Mesh: {} vertices, {} edges, {} faces"),
fmt::runtime(TIP_("\u2022 Mesh: {} vertices, {} edges, {} faces")),
to_string(mesh_info.verts_num),
to_string(mesh_info.edges_num),
to_string(mesh_info.faces_num));
@@ -1762,14 +1771,14 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn
const geo_log::GeometryInfoLog::PointCloudInfo &pointcloud_info =
*value_log.pointcloud_info;
fmt::format_to(fmt::appender(buf),
TIP_("\u2022 Point Cloud: {} points"),
fmt::runtime(TIP_("\u2022 Point Cloud: {} points")),
to_string(pointcloud_info.points_num));
break;
}
case bke::GeometryComponent::Type::Curve: {
const geo_log::GeometryInfoLog::CurveInfo &curve_info = *value_log.curve_info;
fmt::format_to(fmt::appender(buf),
TIP_("\u2022 Curve: {} points, {} splines"),
fmt::runtime(TIP_("\u2022 Curve: {} points, {} splines")),
to_string(curve_info.points_num),
to_string(curve_info.splines_num));
break;
@@ -1777,20 +1786,22 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn
case bke::GeometryComponent::Type::Instance: {
const geo_log::GeometryInfoLog::InstancesInfo &instances_info = *value_log.instances_info;
fmt::format_to(fmt::appender(buf),
TIP_("\u2022 Instances: {}"),
fmt::runtime(TIP_("\u2022 Instances: {}")),
to_string(instances_info.instances_num));
break;
}
case bke::GeometryComponent::Type::Volume: {
const geo_log::GeometryInfoLog::VolumeInfo &volume_info = *value_log.volume_info;
fmt::format_to(fmt::appender(buf), TIP_("\u2022 Volume: {} grids"), volume_info.grids_num);
fmt::format_to(fmt::appender(buf),
fmt::runtime(TIP_("\u2022 Volume: {} grids")),
volume_info.grids_num);
break;
}
case bke::GeometryComponent::Type::Edit: {
if (value_log.edit_data_info.has_value()) {
const geo_log::GeometryInfoLog::EditDataInfo &edit_info = *value_log.edit_data_info;
fmt::format_to(fmt::appender(buf),
TIP_("\u2022 Edit: {}, {}, {}"),
fmt::runtime(TIP_("\u2022 Edit: {}, {}, {}")),
edit_info.has_deformed_positions ? TIP_("positions") :
TIP_("no positions"),
edit_info.has_deform_matrices ? TIP_("matrices") : TIP_("no matrices"),
@@ -1802,7 +1813,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn
const geo_log::GeometryInfoLog::GreasePencilInfo &grease_pencil_info =
*value_log.grease_pencil_info;
fmt::format_to(fmt::appender(buf),
TIP_("\u2022 Grease Pencil: {} layers"),
fmt::runtime(TIP_("\u2022 Grease Pencil: {} layers")),
to_string(grease_pencil_info.layers_num));
break;
}
@@ -1824,38 +1835,38 @@ static void create_inspection_string_for_geometry_socket(fmt::memory_buffer &buf
Span<bke::GeometryComponent::Type> supported_types = socket_decl->supported_types();
if (supported_types.is_empty()) {
fmt::format_to(fmt::appender(buf), TIP_("Supported: All Types"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Supported: All Types"));
return;
}
fmt::format_to(fmt::appender(buf), TIP_("Supported: "));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Supported: "));
for (bke::GeometryComponent::Type type : supported_types) {
switch (type) {
case bke::GeometryComponent::Type::Mesh: {
fmt::format_to(fmt::appender(buf), TIP_("Mesh"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Mesh"));
break;
}
case bke::GeometryComponent::Type::PointCloud: {
fmt::format_to(fmt::appender(buf), TIP_("Point Cloud"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Point Cloud"));
break;
}
case bke::GeometryComponent::Type::Curve: {
fmt::format_to(fmt::appender(buf), TIP_("Curve"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Curve"));
break;
}
case bke::GeometryComponent::Type::Instance: {
fmt::format_to(fmt::appender(buf), TIP_("Instances"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Instances"));
break;
}
case bke::GeometryComponent::Type::Volume: {
fmt::format_to(fmt::appender(buf), CTX_TIP_(BLT_I18NCONTEXT_ID_ID, "Volume"));
fmt::format_to(fmt::appender(buf), "{}", CTX_TIP_(BLT_I18NCONTEXT_ID_ID, "Volume"));
break;
}
case bke::GeometryComponent::Type::Edit: {
break;
}
case bke::GeometryComponent::Type::GreasePencil: {
fmt::format_to(fmt::appender(buf), TIP_("Grease Pencil"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Grease Pencil"));
break;
}
}
@@ -2029,7 +2040,7 @@ static std::optional<std::string> create_multi_input_log_inspection_string(
const Vector<std::string> lines = lines_of_text(info.second);
fmt::format_to(fmt::appender(buf), "{}", info.first);
fmt::format_to(fmt::appender(buf), ". ");
fmt::format_to(fmt::appender(buf), lines.first());
fmt::format_to(fmt::appender(buf), "{}", lines.first());
for (const std::string &line : lines.as_span().drop_front(1)) {
fmt::format_to(fmt::appender(buf), "\n {}", line);
}
@@ -2113,6 +2124,7 @@ static std::optional<std::string> create_dangling_reroute_inspection_string(
}
fmt::format_to(fmt::appender(buf), ".\n\n");
fmt::format_to(fmt::appender(buf),
"{}",
TIP_("Dangling reroute is ignored, default value of target socket is used"));
return str;
}
@@ -3062,7 +3074,7 @@ static std::string named_attribute_tooltip(bContext * /*C*/, void *argN, const c
NamedAttributeTooltipArg &arg = *static_cast<NamedAttributeTooltipArg *>(argN);
fmt::memory_buffer buf;
fmt::format_to(fmt::appender(buf), TIP_("Accessed named attributes:"));
fmt::format_to(fmt::appender(buf), "{}", TIP_("Accessed named attributes:"));
fmt::format_to(fmt::appender(buf), "\n");
struct NameWithUsage {
@@ -3083,7 +3095,7 @@ static std::string named_attribute_tooltip(bContext * /*C*/, void *argN, const c
for (const NameWithUsage &attribute : sorted_used_attribute) {
const StringRefNull name = attribute.name;
const geo_log::NamedAttributeUsage usage = attribute.usage;
fmt::format_to(fmt::appender(buf), TIP_(" \u2022 \"{}\": "), name);
fmt::format_to(fmt::appender(buf), fmt::runtime(TIP_(" \u2022 \"{}\": ")), name);
Vector<std::string> usages;
if ((usage & geo_log::NamedAttributeUsage::Read) != geo_log::NamedAttributeUsage::None) {
usages.append(TIP_("read"));
@@ -3095,7 +3107,7 @@ static std::string named_attribute_tooltip(bContext * /*C*/, void *argN, const c
usages.append(TIP_("remove"));
}
for (const int i : usages.index_range()) {
fmt::format_to(fmt::appender(buf), usages[i]);
fmt::format_to(fmt::appender(buf), "{}", usages[i]);
if (i < usages.size() - 1) {
fmt::format_to(fmt::appender(buf), ", ");
}
@@ -3103,9 +3115,10 @@ static std::string named_attribute_tooltip(bContext * /*C*/, void *argN, const c
fmt::format_to(fmt::appender(buf), "\n");
}
fmt::format_to(fmt::appender(buf), "\n");
fmt::format_to(fmt::appender(buf),
TIP_("Attributes with these names used within the group may conflict with "
"existing attributes"));
fmt::format_to(
fmt::appender(buf),
fmt::runtime(TIP_("Attributes with these names used within the group may conflict with "
"existing attributes")));
return fmt::to_string(buf);
}

View File

@@ -115,7 +115,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
UI_but_func_tooltip_set(
but,
[](bContext * /*C*/, void *argN, const char * /*tip*/) {
return fmt::format(TIP_("{}"), *((int *)argN));
return fmt::format(fmt::runtime(TIP_("{}")), *((int *)argN));
},
MEM_cnew<int>(__func__, value),
MEM_freeN);
@@ -168,7 +168,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
UI_but_func_tooltip_set(
but,
[](bContext * /*C*/, void *argN, const char * /*tip*/) {
return fmt::format(TIP_("{:f}"), *((float *)argN));
return fmt::format(fmt::runtime(TIP_("{:f}")), *((float *)argN));
},
MEM_cnew<float>(__func__, value),
MEM_freeN);
@@ -304,7 +304,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
UI_but_func_tooltip_set(
but,
[](bContext * /*C*/, void *argN, const char * /*tip*/) {
return fmt::format(TIP_("{:f}"), *((float *)argN));
return fmt::format(fmt::runtime(TIP_("{:f}")), *((float *)argN));
},
MEM_cnew<float>(__func__, value),
MEM_freeN);
@@ -339,7 +339,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
UI_but_func_tooltip_set(
but,
[](bContext * /*C*/, void *argN, const char * /*tip*/) {
return fmt::format(TIP_("{}"), *((int *)argN));
return fmt::format(fmt::runtime(TIP_("{}")), *((int *)argN));
},
MEM_cnew<int>(__func__, value),
MEM_freeN);
@@ -382,7 +382,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
[](bContext * /*C*/, void *argN, const char * /*tip*/) {
const uint32_t uint_color = POINTER_AS_UINT(argN);
ColorGeometry4b color = *(ColorGeometry4b *)&uint_color;
return fmt::format(TIP_("Byte Color (sRGB encoded):\n{} {} {} {}"),
return fmt::format(fmt::runtime(TIP_("Byte Color (sRGB encoded):\n{} {} {} {}")),
color.r,
color.g,
color.b,

View File

@@ -106,11 +106,11 @@ static void applyShrinkFatten(TransInfo *t)
t->values_final[0] = distance;
/* Header print for NumInput. */
fmt::format_to(fmt::appender(str), IFACE_("Shrink/Fatten: "));
fmt::format_to(fmt::appender(str), "{}", IFACE_("Shrink/Fatten: "));
if (hasNumInput(&t->num)) {
char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c, unit);
fmt::format_to(fmt::appender(str), c);
fmt::format_to(fmt::appender(str), "{}", c);
}
else {
/* Default header print. */
@@ -118,7 +118,7 @@ static void applyShrinkFatten(TransInfo *t)
char unit_str[64];
BKE_unit_value_as_string(
unit_str, sizeof(unit_str), distance * unit->scale_length, 4, B_UNIT_LENGTH, unit, true);
fmt::format_to(fmt::appender(str), unit_str);
fmt::format_to(fmt::appender(str), "{}", unit_str);
}
else {
fmt::format_to(fmt::appender(str), "{:.4f}", distance);
@@ -136,7 +136,7 @@ static void applyShrinkFatten(TransInfo *t)
}
fmt::format_to(fmt::appender(str),
IFACE_(" or Alt) Even Thickness {}"),
fmt::runtime(IFACE_(" or Alt) Even Thickness {}")),
WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0));
/* Done with header string. */

View File

@@ -5877,7 +5877,7 @@ std::string RNA_pointer_as_string_keywords_ex(bContext *C,
if (as_function && (prop->flag_parameter & PARM_REQUIRED)) {
/* required args don't have useful defaults */
ss << fmt::format(first_iter ? "{}" : ", {}", arg_name);
ss << fmt::format(fmt::runtime(first_iter ? "{}" : ", {}"), arg_name);
first_iter = false;
}
else {
@@ -5906,7 +5906,7 @@ std::string RNA_pointer_as_string_keywords_ex(bContext *C,
buf = RNA_property_as_string(C, ptr, prop, -1, max_prop_length);
}
ss << fmt::format(first_iter ? "{}={}" : ", {}={}", arg_name, buf);
ss << fmt::format(fmt::runtime(first_iter ? "{}={}" : ", {}={}"), arg_name, buf);
first_iter = false;
}
}
@@ -5989,7 +5989,8 @@ static void rna_array_as_string_elem(int type, void **buf_p, int len, std::strin
case PROP_BOOLEAN: {
bool *buf = static_cast<bool *>(*buf_p);
for (int i = 0; i < len; i++, buf++) {
ss << fmt::format((i < end || !end) ? "{}, " : "{}", bool_as_py_string(*buf));
ss << fmt::format(fmt::runtime((i < end || !end) ? "{}, " : "{}"),
bool_as_py_string(*buf));
}
*buf_p = buf;
break;
@@ -5997,7 +5998,7 @@ static void rna_array_as_string_elem(int type, void **buf_p, int len, std::strin
case PROP_INT: {
int *buf = static_cast<int *>(*buf_p);
for (int i = 0; i < len; i++, buf++) {
ss << fmt::format((i < end || !end) ? "{}, " : "{}", *buf);
ss << fmt::format(fmt::runtime((i < end || !end) ? "{}, " : "{}"), *buf);
}
*buf_p = buf;
break;
@@ -6005,7 +6006,7 @@ static void rna_array_as_string_elem(int type, void **buf_p, int len, std::strin
case PROP_FLOAT: {
float *buf = static_cast<float *>(*buf_p);
for (int i = 0; i < len; i++, buf++) {
ss << fmt::format((i < end || !end) ? "{:g}, " : "{:g}", *buf);
ss << fmt::format(fmt::runtime((i < end || !end) ? "{:g}, " : "{:g}"), *buf);
}
*buf_p = buf;
break;
@@ -6135,7 +6136,7 @@ std::string RNA_property_as_string(
bool is_first = true;
for (; item->identifier; item++) {
if (item->identifier[0] && item->value & val) {
ss << fmt::format(is_first ? "'{}'" : ", '{}'", item->identifier);
ss << fmt::format(fmt::runtime(is_first ? "'{}'" : ", '{}'"), item->identifier);
is_first = false;
}
}

View File

@@ -2443,7 +2443,9 @@ static void draw_warnings(const bContext *C,
return;
}
PanelLayout panel = uiLayoutPanelProp(C, layout, md_ptr, "open_warnings_panel");
uiItemL(panel.header, fmt::format(IFACE_("Warnings ({})"), warnings_num).c_str(), ICON_NONE);
uiItemL(panel.header,
fmt::format(fmt::runtime(IFACE_("Warnings ({})")), warnings_num).c_str(),
ICON_NONE);
if (!panel.body) {
return;
}

View File

@@ -661,9 +661,10 @@ bool get_bake_draw_context(const bContext *C, const bNode &node, BakeDrawContext
std::string get_baked_string(const BakeDrawContext &ctx)
{
if (ctx.bake_still && ctx.baked_range->size() == 1) {
return fmt::format(RPT_("Baked Frame {}"), ctx.baked_range->first());
return fmt::format(fmt::runtime(RPT_("Baked Frame {}")), ctx.baked_range->first());
}
return fmt::format(RPT_("Baked {} - {}"), ctx.baked_range->first(), ctx.baked_range->last());
return fmt::format(
fmt::runtime(RPT_("Baked {} - {}")), ctx.baked_range->first(), ctx.baked_range->last());
}
std::optional<std::string> get_bake_state_string(const BakeDrawContext &ctx)
@@ -677,14 +678,14 @@ std::optional<std::string> get_bake_state_string(const BakeDrawContext &ctx)
char size_str[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE];
BLI_str_format_byte_unit(size_str, ctx.bake->bake_size, true);
if (ctx.bake->packed) {
return fmt::format(RPT_("{} ({} packed)"), baked_str, size_str);
return fmt::format(fmt::runtime(RPT_("{} ({} packed)")), baked_str, size_str);
}
return fmt::format(RPT_("{} ({} on disk)"), baked_str, size_str);
return fmt::format(fmt::runtime(RPT_("{} ({} on disk)")), baked_str, size_str);
}
if (ctx.frame_range.has_value()) {
if (!ctx.bake_still) {
return fmt::format(
RPT_("Frames {} - {}"), ctx.frame_range->first(), ctx.frame_range->last());
fmt::runtime(RPT_("Frames {} - {}")), ctx.frame_range->first(), ctx.frame_range->last());
}
}
return std::nullopt;

View File

@@ -266,15 +266,15 @@ static void node_geo_exec(GeoNodeExecParams params)
if (!mesh_attributes_eval.contains(uv_map_name)) {
pass_through_input();
const std::string message = fmt::format(TIP_("Evaluated surface missing UV map: \"{}\""),
uv_map_name);
const std::string message = fmt::format(
fmt::runtime(TIP_("Evaluated surface missing UV map: \"{}\"")), uv_map_name);
params.error_message_add(NodeWarningType::Error, message);
return;
}
if (!mesh_attributes_orig.contains(uv_map_name)) {
pass_through_input();
const std::string message = fmt::format(TIP_("Original surface missing UV map: \"{}\""),
uv_map_name);
const std::string message = fmt::format(
fmt::runtime(TIP_("Original surface missing UV map: \"{}\"")), uv_map_name);
params.error_message_add(NodeWarningType::Error, message);
return;
}
@@ -383,7 +383,7 @@ static void node_geo_exec(GeoNodeExecParams params)
curves.tag_positions_changed();
if (invalid_uv_count) {
const std::string message = fmt::format(TIP_("Invalid surface UVs on {} curves"),
const std::string message = fmt::format(fmt::runtime(TIP_("Invalid surface UVs on {} curves")),
invalid_uv_count.load());
params.error_message_add(NodeWarningType::Warning, message);
}

View File

@@ -128,12 +128,14 @@ static void node_geo_exec(GeoNodeExecParams params)
for (const StringRef attribute_name : failed_attributes) {
quoted_attribute_names.append(fmt::format("\"{}\"", attribute_name));
}
const std::string message = fmt::format(TIP_("Cannot remove built-in attributes: {}"),
fmt::join(quoted_attribute_names, ", "));
const std::string message = fmt::format(
fmt::runtime(TIP_("Cannot remove built-in attributes: {}")),
fmt::join(quoted_attribute_names, ", "));
params.error_message_add(NodeWarningType::Warning, message);
}
else if (removed_attributes.is_empty() && pattern_mode == PatternMode::Exact) {
const std::string message = fmt::format(TIP_("Attribute does not exist: \"{}\""), pattern);
const std::string message = fmt::format(fmt::runtime(TIP_("Attribute does not exist: \"{}\"")),
pattern);
params.error_message_add(NodeWarningType::Warning, message);
}

View File

@@ -170,7 +170,8 @@ static void node_geo_exec(GeoNodeExecParams params)
const char *type_name = nullptr;
RNA_enum_name_from_value(rna_enum_attribute_type_items, data_type, &type_name);
const std::string message = fmt::format(
TIP_("Failed to write to attribute \"{}\" with domain \"{}\" and type \"{}\""),
fmt::runtime(
TIP_("Failed to write to attribute \"{}\" with domain \"{}\" and type \"{}\"")),
name,
TIP_(domain_name),
TIP_(type_name));

View File

@@ -454,7 +454,7 @@ std::string make_anonymous_attribute_socket_inspection_string(const bNodeSocket
std::string make_anonymous_attribute_socket_inspection_string(StringRef node_name,
StringRef socket_name)
{
return fmt::format(TIP_("\"{}\" from {}"), socket_name, node_name);
return fmt::format(fmt::runtime(TIP_("\"{}\" from {}")), socket_name, node_name);
}
static void execute_multi_function_on_value_variant__single(
@@ -1172,7 +1172,8 @@ class LazyFunctionForGroupNode : public LazyFunction {
std::string name() const override
{
return fmt::format(TIP_("Group '{}' ({})"), group_node_.id->name + 2, group_node_.name);
return fmt::format(
fmt::runtime(TIP_("Group '{}' ({})")), group_node_.id->name + 2, group_node_.name);
}
std::string input_name(const int i) const override

View File

@@ -856,7 +856,7 @@ wmDragPath *WM_drag_create_path_data(blender::Span<const char *> paths)
if (path_data->paths.size() > 1) {
std::string path_count = std::to_string(path_data->paths.size());
path_data->tooltip = fmt::format(TIP_("Dragging {} files"), path_count);
path_data->tooltip = fmt::format(fmt::runtime(TIP_("Dragging {} files")), path_count);
}
return path_data;

View File

@@ -2548,7 +2548,8 @@ static int wm_homefile_write_invoke(bContext *C, wmOperator *op, const wmEvent *
char display_name[FILE_MAX];
BLI_path_to_display_name(display_name, sizeof(display_name), IFACE_(U.app_template));
std::string message = fmt::format(
IFACE_("Make the current file the default \"{}\" startup file."), IFACE_(display_name));
fmt::runtime(IFACE_("Make the current file the default \"{}\" startup file.")),
IFACE_(display_name));
return WM_operator_confirm_ex(C,
op,
IFACE_("Overwrite Template Startup File"),
@@ -2734,7 +2735,8 @@ static int wm_userpref_read_invoke(bContext *C, wmOperator *op, const wmEvent *
if (template_only) {
char display_name[FILE_MAX];
BLI_path_to_display_name(display_name, sizeof(display_name), IFACE_(U.app_template));
title = fmt::format(IFACE_("Load Factory \"{}\" Preferences."), IFACE_(display_name));
title = fmt::format(fmt::runtime(IFACE_("Load Factory \"{}\" Preferences.")),
IFACE_(display_name));
}
else {
title = IFACE_("Load Factory Blender Preferences");
@@ -2993,7 +2995,7 @@ static int wm_read_factory_settings_invoke(bContext *C, wmOperator *op, const wm
if (template_only) {
char display_name[FILE_MAX];
BLI_path_to_display_name(display_name, sizeof(display_name), IFACE_(U.app_template));
title = fmt::format(IFACE_("Load Factory \"{}\" Startup File and Preferences"),
title = fmt::format(fmt::runtime(IFACE_("Load Factory \"{}\" Startup File and Preferences")),
IFACE_(display_name));
}
else {