[Bf-blender-cvs] [c081ebb9a52] filebrowser_redesign: Fix strings not translated
Julian Eisel
noreply at git.blender.org
Tue Aug 27 13:49:35 CEST 2019
Commit: c081ebb9a52e58b794f28eb1d6d33171e0305454
Author: Julian Eisel
Date: Tue Aug 27 13:49:07 2019 +0200
Branches: filebrowser_redesign
https://developer.blender.org/rBc081ebb9a52e58b794f28eb1d6d33171e0305454
Fix strings not translated
===================================================================
M source/blender/blenlib/BLI_fileops.h
M source/blender/blenlib/intern/BLI_filelist.c
M source/blender/editors/space_file/file_draw.c
M source/blender/editors/space_file/filesel.c
===================================================================
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h
index 6f1dd1ff5fc..bc9e646cb3b 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -99,8 +99,13 @@ void BLI_filelist_entry_size_to_string(const struct stat *st,
void BLI_filelist_entry_mode_to_string(
const struct stat *st, const bool compact, char r_mode1[], char r_mode2[], char r_mode3[]);
void BLI_filelist_entry_owner_to_string(const struct stat *st, const bool compact, char r_owner[]);
-void BLI_filelist_entry_datetime_to_string(
- const struct stat *st, const int64_t ts, const bool compact, char r_time[], char r_date[], const bool use_relative_str);
+void BLI_filelist_entry_datetime_to_string(const struct stat *st,
+ const int64_t ts,
+ const bool compact,
+ const bool use_relative_str,
+ char r_time[],
+ char r_date[],
+ bool *r_date_needs_translate);
/* Files */
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index d10cef16b41..0ee9760120e 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -347,23 +347,35 @@ void BLI_filelist_entry_owner_to_string(const struct stat *st,
/**
* Convert given entry's time into human-readable strings.
+ *
+ * \param use_relative_string: Return "Today" and "Yesterday" as date string when applicable.
+ * \param *r_date_needs_translate: optional, \a r_date should be translated if this returns true.
+ * Note that we don't translate in here directly because this
+ * function doesn't know where the string will be displayed (i.e.
+ * IFACE_ vs. TIP_)
*/
void BLI_filelist_entry_datetime_to_string(const struct stat *st,
const int64_t ts,
const bool compact,
+ const bool use_relative_str,
char r_time[FILELIST_DIRENTRY_TIME_LEN],
char r_date[FILELIST_DIRENTRY_DATE_LEN],
- const bool use_relative_str
- )
+ bool *r_date_needs_translate)
{
int today_year = 0;
int today_yday = 0;
int yesterday_year = 0;
int yesterday_yday = 0;
+
+ if (r_date_needs_translate) {
+ *r_date_needs_translate = false;
+ }
+
if (use_relative_str) {
/* Localtime() has only one buffer so need to get data out before called again. */
const time_t ts_now = time(NULL);
struct tm *today = localtime(&ts_now);
+
today_year = today->tm_year;
today_yday = today->tm_yday;
/* Handle a yesterday that spans a year */
@@ -388,10 +400,16 @@ void BLI_filelist_entry_datetime_to_string(const struct stat *st,
if (r_date) {
if (use_relative_str && (tm->tm_year == today_year) && (tm->tm_yday == today_yday)) {
BLI_strncpy(r_date, "Today", sizeof(*r_date) * FILELIST_DIRENTRY_DATE_LEN);
+ if (r_date_needs_translate) {
+ *r_date_needs_translate = true;
+ }
}
else if (use_relative_str && (tm->tm_year == yesterday_year) &&
(tm->tm_yday == yesterday_yday)) {
BLI_strncpy(r_date, "Yesterday", sizeof(*r_date) * FILELIST_DIRENTRY_DATE_LEN);
+ if (r_date_needs_translate) {
+ *r_date_needs_translate = true;
+ }
}
else {
strftime(r_date,
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 91b9f872239..36c04ccacef 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -543,10 +543,15 @@ static const char *filelist_get_details_column_string(FileListColumns column,
if (!(file->typeflag & FILE_TYPE_BLENDERLIB) && !FILENAME_IS_CURRPAR(file->relpath)) {
if ((file->entry->datetime_str[0] == '\0') || update_stat_strings) {
char date[16], time[8];
+ bool date_translate;
+
BLI_filelist_entry_datetime_to_string(
- NULL, file->entry->time, small_size, time, date, true);
- BLI_snprintf(
- file->entry->datetime_str, sizeof(file->entry->datetime_str), "%s %s", date, time);
+ NULL, file->entry->time, small_size, true, time, date, &date_translate);
+ BLI_snprintf(file->entry->datetime_str,
+ sizeof(file->entry->datetime_str),
+ "%s %s",
+ date_translate ? IFACE_(date) : date,
+ time);
}
return file->entry->datetime_str;
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 64626923e99..7ae326eecd0 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -49,6 +49,8 @@
#include "BLI_utildefines.h"
#include "BLI_fnmatch.h"
+#include "BLT_translation.h"
+
#include "BKE_appdir.h"
#include "BKE_context.h"
#include "BKE_main.h"
@@ -647,13 +649,13 @@ static void details_columns_init(const FileSelectParams *params, FileLayout *lay
{
details_columns_widths(params, layout);
- layout->details_columns[COLUMN_NAME].name = "Name";
+ layout->details_columns[COLUMN_NAME].name = IFACE_("Name");
layout->details_columns[COLUMN_NAME].sort_type = FILE_SORT_ALPHA;
layout->details_columns[COLUMN_NAME].text_align = UI_STYLE_TEXT_LEFT;
- layout->details_columns[COLUMN_DATETIME].name = "Date Modified";
+ layout->details_columns[COLUMN_DATETIME].name = IFACE_("Date Modified");
layout->details_columns[COLUMN_DATETIME].sort_type = FILE_SORT_TIME;
layout->details_columns[COLUMN_DATETIME].text_align = UI_STYLE_TEXT_LEFT;
- layout->details_columns[COLUMN_SIZE].name = "Size";
+ layout->details_columns[COLUMN_SIZE].name = IFACE_("Size");
layout->details_columns[COLUMN_SIZE].sort_type = FILE_SORT_SIZE;
layout->details_columns[COLUMN_SIZE].text_align = UI_STYLE_TEXT_RIGHT;
}
More information about the Bf-blender-cvs
mailing list