I18n: translate untitled file names
When saving, the default file name is "untitled" regardless of selected language. This can be translated, like many graphical applications do. This applies to: - blend file - alembic file - collada file - obj file - usd file - rendered image - grease pencil export - subtitles export - other Python exports through ExportHelper Reviewed By: mont29 Differential Revision: https://developer.blender.org/D15868
This commit is contained in:
parent
f70cf451ed
commit
dead26b577
|
@ -21,7 +21,7 @@ from bpy.props import (
|
|||
EnumProperty,
|
||||
StringProperty,
|
||||
)
|
||||
|
||||
from bpy.app.translations import pgettext_data as data_
|
||||
|
||||
def _check_axis_conversion(op):
|
||||
if hasattr(op, "axis_forward") and hasattr(op, "axis_up"):
|
||||
|
@ -56,7 +56,7 @@ class ExportHelper:
|
|||
if not self.filepath:
|
||||
blend_filepath = context.blend_data.filepath
|
||||
if not blend_filepath:
|
||||
blend_filepath = "untitled"
|
||||
blend_filepath = data_("untitled")
|
||||
else:
|
||||
blend_filepath = os.path.splitext(blend_filepath)[0]
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "BLI_string.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_image_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
@ -173,7 +175,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
|
|||
BLI_strncpy(opts->filepath, G.ima, sizeof(opts->filepath));
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(opts->filepath, "//untitled", sizeof(opts->filepath));
|
||||
BLI_snprintf(opts->filepath, sizeof(opts->filepath), "//%s", DATA_("untitled"));
|
||||
BLI_path_abs(opts->filepath, BKE_main_blendfile_path(bmain));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *
|
|||
char filepath[FILE_MAX];
|
||||
|
||||
if (BKE_main_blendfile_path(bmain)[0] == '\0') {
|
||||
BLI_strncpy(filepath, "untitled", sizeof(filepath));
|
||||
BLI_strncpy(filepath, DATA_("untitled"), sizeof(filepath));
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
|
||||
|
|
|
@ -43,7 +43,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *
|
|||
const char *blendfile_path = BKE_main_blendfile_path(bmain);
|
||||
|
||||
if (blendfile_path[0] == '\0') {
|
||||
BLI_strncpy(filepath, "untitled", sizeof(filepath));
|
||||
BLI_strncpy(filepath, DATA_("untitled"), sizeof(filepath));
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(filepath, blendfile_path, sizeof(filepath));
|
||||
|
|
|
@ -79,7 +79,7 @@ static void set_export_filepath(bContext *C, wmOperator *op, const char *extensi
|
|||
char filepath[FILE_MAX];
|
||||
|
||||
if (BKE_main_blendfile_path(bmain)[0] == '\0') {
|
||||
BLI_strncpy(filepath, "untitled", sizeof(filepath));
|
||||
BLI_strncpy(filepath, DATA_("untitled"), sizeof(filepath));
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
|
||||
|
|
|
@ -63,7 +63,7 @@ static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
|
|||
char filepath[FILE_MAX];
|
||||
|
||||
if (BKE_main_blendfile_path(bmain)[0] == '\0') {
|
||||
BLI_strncpy(filepath, "untitled", sizeof(filepath));
|
||||
BLI_strncpy(filepath, DATA_("untitled"), sizeof(filepath));
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
|
||||
|
|
|
@ -90,7 +90,7 @@ static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
|
|||
const char *main_blendfile_path = BKE_main_blendfile_path(bmain);
|
||||
|
||||
if (main_blendfile_path[0] == '\0') {
|
||||
BLI_strncpy(filepath, "untitled", sizeof(filepath));
|
||||
BLI_strncpy(filepath, DATA_("untitled"), sizeof(filepath));
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(filepath, main_blendfile_path, sizeof(filepath));
|
||||
|
|
|
@ -3093,7 +3093,7 @@ static int sequencer_export_subtitles_invoke(bContext *C,
|
|||
char filepath[FILE_MAX];
|
||||
|
||||
if (BKE_main_blendfile_path(bmain)[0] == '\0') {
|
||||
BLI_strncpy(filepath, "untitled", sizeof(filepath));
|
||||
BLI_strncpy(filepath, DATA_("untitled"), sizeof(filepath));
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath));
|
||||
|
|
|
@ -3019,7 +3019,9 @@ void WM_OT_recover_auto_save(wmOperatorType *ot)
|
|||
static void wm_filepath_default(const Main *bmain, char *filepath)
|
||||
{
|
||||
if (bmain->filepath[0] == '\0') {
|
||||
BLI_path_filename_ensure(filepath, FILE_MAX, "untitled.blend");
|
||||
char filename_untitled[FILE_MAXFILE];
|
||||
SNPRINTF(filename_untitled, "%s.blend", DATA_("untitled"));
|
||||
BLI_path_filename_ensure(filepath, FILE_MAX, filename_untitled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3652,7 +3654,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
|
|||
BLI_split_file_part(blendfile_path, filename, sizeof(filename));
|
||||
}
|
||||
else {
|
||||
STRNCPY(filename, "untitled.blend");
|
||||
SNPRINTF(filename, "%s.blend", DATA_("untitled"));
|
||||
}
|
||||
uiItemL(layout, filename, ICON_NONE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue