Hi,
uhoh, this opened a can of worms. I found 52 untranslated error messages. Here is a patch that marks them for translation. |
From b1374dea275790a97362c9b20b629a7d5b697a92 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Sat, 31 Jan 2015 14:58:57 +0100 Subject: [PATCH] Mark error messages for translation
Signed-off-by: Robert C. Helling <[email protected]> --- file.c | 12 ++++++------ libdivecomputer.c | 8 ++++---- load-git.c | 39 ++++++++++++++++++++------------------- qt-ui/mainwindow.cpp | 2 +- qt-ui/modeldelegates.cpp | 3 +-- save-git.c | 39 ++++++++++++++++++++------------------- 6 files changed, 52 insertions(+), 51 deletions(-) diff --git a/file.c b/file.c index eacd875..38491b3 100644 --- a/file.c +++ b/file.c @@ -131,7 +131,7 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons free(starttag); free(endtag); free(buf); - return report_error("Memory allocation failed in %s", __func__); + return report_error(translate("gettextFromC","Memory allocation failed in %s"), __func__); } sprintf(starttag, "<%s>", tag); @@ -147,7 +147,7 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons free(endtag); } else { free(mem->buffer); - return report_error("realloc failed in %s", __func__); + return report_error(translate("gettextFromC","realloc failed in %s"), __func__); } return 0; @@ -409,7 +409,7 @@ static int parse_file_buffer(const char *filename, struct memblock *mem) return ret; if (!mem->size || !mem->buffer) - return report_error("Out of memory parsing file %s\n", filename); + return report_error(translate("gettextFromC","Out of memory parsing file %s\n"), filename); return parse_xml_buffer(filename, mem->buffer, mem->size, &dive_table, NULL); } @@ -872,7 +872,7 @@ int parse_csv_file(const char *filename, int timef, int depthf, int tempf, int p init_csv_file_parsing(params, timebuf, depthbuf, tempbuf, po2buf, cnsbuf,ndlbuf, ttsbuf, stopdepthbuf, pressurebuf, unitbuf, separator_index, &now, timep, curdate, curtime, timef, depthf, tempf, po2f, cnsf, ndlf, ttsf, stopdepthf, pressuref, sepidx, csvtemplate, unitidx); if (filename == NULL) - return report_error("No CSV filename"); + return report_error(translate("gettextFromC","No CSV filename")); mem.size = 0; if (try_to_xslt_open_csv(filename, &mem, csvtemplate)) @@ -919,7 +919,7 @@ int parse_seabear_csv_file(const char *filename, int timef, int depthf, int temp init_csv_file_parsing(params, timebuf, depthbuf, tempbuf, po2buf, cnsbuf,ndlbuf, ttsbuf, stopdepthbuf, pressurebuf, unitbuf, separator_index, &now, timep, curdate, curtime, timef, depthf, tempf, po2f, cnsf, ndlf, ttsf, stopdepthf, pressuref, sepidx, csvtemplate, unitidx); if (filename == NULL) - return report_error("No CSV filename"); + return report_error(translate("gettextFromC","No CSV filename")); if (readfile(filename, &mem) < 0) return report_error(translate("gettextFromC", "Failed to read '%s'"), filename); @@ -1102,7 +1102,7 @@ int parse_manual_file(const char *filename, int sepidx, int units, int dateforma params[pnr++] = NULL; if (filename == NULL) - return report_error("No manual CSV filename"); + return report_error(translate("gettextFromC","No manual CSV filename")); mem.size = 0; if (try_to_xslt_open_csv(filename, &mem, "manualCSV")) diff --git a/libdivecomputer.c b/libdivecomputer.c index 6a16eb1..c6d40ba 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -43,7 +43,7 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t if (rc == DC_STATUS_SUCCESS) { if (ntanks != ngases) { shown_warning = true; - report_error("different number of gases (%d) and tanks (%d)", ngases, ntanks); + report_error(translate("gettextFromC","different number of gases (%d) and tanks (%d)"), ngases, ntanks); } } dc_tank_t tank = { 0 }; @@ -68,14 +68,14 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t if (o2 + he <= O2_IN_AIR || o2 > 1000) { if (!shown_warning) { shown_warning = true; - report_error("unlikely dive gas data from libdivecomputer: o2 = %d he = %d", o2, he); + report_error(translate("gettextFromC","unlikely dive gas data from libdivecomputer: o2 = %d he = %d"), o2, he); } o2 = 0; } if (he < 0 || o2 + he > 1000) { if (!shown_warning) { shown_warning = true; - report_error("unlikely dive gas data from libdivecomputer: o2 = %d he = %d", o2, he); + report_error(translate("gettextFromC","unlikely dive gas data from libdivecomputer: o2 = %d he = %d"), o2, he); } he = 0; } @@ -95,7 +95,7 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t } if (tank.gasmix != i) { // we don't handle this, yet shown_warning = true; - report_error("gasmix %d for tank %d doesn't match", tank.gasmix, i); + report_error(translate("gettextFromC","gasmix %d for tank %d doesn't match"), tank.gasmix, i); } } } diff --git a/load-git.c b/load-git.c index 1cdb44c..9c58eaf 100644 --- a/load-git.c +++ b/load-git.c @@ -8,6 +8,7 @@ #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> +#include "gettext.h" #include <git2.h> #include "dive.h" @@ -268,7 +269,7 @@ static void parse_cylinder_keyvalue(void *_cylinder, const char *key, const char cylinder->cylinder_use = cylinderuse_from_text(value); return; } - report_error("Unknown cylinder key/value pair (%s/%s)", key, value); + report_error(translate("gettextFromC","Unknown cylinder key/value pair (%s/%s)"), key, value); } static void parse_dive_cylinder(char *line, struct membuffer *str, void *_dive) @@ -298,7 +299,7 @@ static void parse_weightsystem_keyvalue(void *_ws, const char *key, const char * /* This is handled by the "get_utf8()" */ if (!strcmp(key, "description")) return; - report_error("Unknown weightsystem key/value pair (%s/%s)", key, value); + report_error(translate("gettextFromC","Unknown weightsystem key/value pair (%s/%s)"), key, value); } static void parse_dive_weightsystem(char *line, struct membuffer *str, void *_dive) @@ -354,7 +355,7 @@ static int match_action(char *line, struct membuffer *str, void *data, else low = mid+1; } -report_error("Unmatched action '%s'", line); +report_error(translate("gettextFromC","Unmatched action '%s'"), line); return -1; } @@ -425,7 +426,7 @@ static void parse_sample_keyvalue(void *_sample, const char *key, const char *va return; } - report_error("Unexpected sample key/value pair (%s/%s)", key, value); + report_error(translate("gettextFromC","Unexpected sample key/value pair (%s/%s)"), key, value); } static char *parse_sample_unit(struct sample *sample, double val, char *unit) @@ -502,7 +503,7 @@ static void sample_parser(char *line, struct divecomputer *dc) const char *end; double val = ascii_strtod(line, &end); if (end == line) { - report_error("Odd sample data: %s", line); + report_error(translate("gettextFromC","Odd sample data: %s"), line); break; } line = (char *)end; @@ -578,7 +579,7 @@ static void parse_event_keyvalue(void *_event, const char *key, const char *valu } else if (!strcmp(key, "he")) { event->gas.mix.he = get_fraction(value); } else - report_error("Unexpected event key/value pair (%s/%s)", key, value); + report_error(translate("gettextFromC","Unexpected event key/value pair (%s/%s)"), key, value); } /* keyvalue "key" "value" @@ -677,7 +678,7 @@ static void parse_settings_version(char *line, struct membuffer *str, void *_unu { int version = atoi(line); if (version > VERSION) - report_error("Git save file version %d is newer than version %d I know about", version, VERSION); + report_error(translate("gettextFromC","Git save file version %d is newer than version %d I know about"), version, VERSION); } /* The string in the membuffer is the version string of subsurface that saved things, just FYI */ @@ -717,7 +718,7 @@ static void parse_divecomputerid_keyvalue(void *_cid, const char *key, const cha cid->nickname = value; return; } - report_error("Unknow divecomputerid key/value pair (%s/%s)", key, value); + report_error(translate("gettextFromC","Unknow divecomputerid key/value pair (%s/%s)"), key, value); } /* @@ -1261,7 +1262,7 @@ static int parse_divecomputer_entry(git_repository *repo, const git_tree_entry * git_blob *blob = git_tree_entry_blob(repo, entry); if (!blob) - return report_error("Unable to read divecomputer file"); + return report_error(translate("gettextFromC","Unable to read divecomputer file")); active_dc = create_new_dc(active_dive); for_each_line(blob, divecomputer_parser, active_dc); @@ -1275,7 +1276,7 @@ static int parse_dive_entry(git_repository *repo, const git_tree_entry *entry, c struct dive *dive = active_dive; git_blob *blob = git_tree_entry_blob(repo, entry); if (!blob) - return report_error("Unable to read dive file"); + return report_error(translate("gettextFromC","Unable to read dive file")); if (*suffix) dive->number = atoi(suffix+1); cylinder_index = weightsystem_index = 0; @@ -1288,7 +1289,7 @@ static int parse_trip_entry(git_repository *repo, const git_tree_entry *entry) { git_blob *blob = git_tree_entry_blob(repo, entry); if (!blob) - return report_error("Unable to read trip file"); + return report_error(translate("gettextFromC","Unable to read trip file")); for_each_line(blob, trip_parser, active_trip); git_blob_free(blob); return 0; @@ -1298,7 +1299,7 @@ static int parse_settings_entry(git_repository *repo, const git_tree_entry *entr { git_blob *blob = git_tree_entry_blob(repo, entry); if (!blob) - return report_error("Unable to read settings file"); + return report_error(translate("gettextFromC","Unable to read settings file")); set_save_userid_local(false); set_userid(""); for_each_line(blob, settings_parser, NULL); @@ -1320,14 +1321,14 @@ static int parse_picture_entry(git_repository *repo, const git_tree_entry *entry * ignore). */ if (sscanf(name, "%c%d:%d:%d", &sign, &hh, &mm, &ss) != 4) - return report_error("Unknown file name %s", name); + return report_error(translate("gettextFromC","Unknown file name %s"), name); offset = ss + 60*(mm + 60*hh); if (sign == '-') offset = -offset; blob = git_tree_entry_blob(repo, entry); if (!blob) - return report_error("Unable to read trip file"); + return report_error(translate("gettextFromC","Unable to read trip file")); pic = alloc_picture(); pic->offset.seconds = offset; @@ -1363,7 +1364,7 @@ static int walk_tree_file(const char *root, const git_tree_entry *entry, git_rep return parse_settings_entry(repo, entry); break; } - report_error("Unknown file %s%s (%p %p)", root, name, dive, trip); + report_error(translate("gettextFromC","Unknown file %s%s (%p %p)"), root, name, dive, trip); return GIT_WALK_SKIP; } @@ -1407,11 +1408,11 @@ static int do_git_load(git_repository *repo, const char *branch) git_tree *tree; if (git_revparse_single(&object, repo, branch)) - return report_error("Unable to look up revision '%s'", branch); + return report_error(translate("gettextFromC","Unable to look up revision '%s'"), branch); if (git_object_peel((git_object **)&commit, object, GIT_OBJ_COMMIT)) - return report_error("Revision '%s' is not a valid commit", branch); + return report_error(translate("gettextFromC","Revision '%s' is not a valid commit"), branch); if (git_commit_tree(&tree, commit)) - return report_error("Could not look up tree of commit in branch '%s'", branch); + return report_error(translate("gettextFromC","Could not look up tree of commit in branch '%s'"), branch); ret = load_dives_from_tree(repo, tree); if (!ret) set_git_id(git_commit_id(commit)); @@ -1432,7 +1433,7 @@ int git_load_dives(struct git_repository *repo, const char *branch) int ret; if (repo == dummy_git_repository) - return report_error("Unable to open git repository at '%s'", branch); + return report_error(translate("gettextFromC","Unable to open git repository at '%s'"), branch); ret = do_git_load(repo, branch); git_repository_free(repo); free((void *)branch); diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 3b73336..60a6a8d 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -1172,7 +1172,7 @@ int MainWindow::file_save_as(void) filename = QFileDialog::getSaveFileName(this, tr("Save file as"), default_filename, tr("Subsurface XML files (*.ssrf *.xml *.XML)")); if (filename.isNull() || filename.isEmpty()) - return report_error("No filename to save into"); + return report_error(tr("No filename to save into").toUtf8().data()); if (ui.InfoWidget->isEditing()) ui.InfoWidget->acceptChanges(); diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index cd195cc..1765659 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -249,8 +249,7 @@ void TankInfoDelegate::reenableReplot(QWidget *widget, QAbstractItemDelegate::En void TankInfoDelegate::revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) { - if (hint == QAbstractItemDelegate::NoHint || - hint == QAbstractItemDelegate::RevertModelCache) { + if (hint == QAbstractItemDelegate::RevertModelCache) { CylindersModel *mymodel = qobject_cast<CylindersModel *>(currCombo.model); mymodel->setData(IDX(CylindersModel::TYPE), currCylinderData.type, Qt::EditRole); mymodel->passInData(IDX(CylindersModel::WORKINGPRESS), currCylinderData.pressure); diff --git a/save-git.c b/save-git.c index 6c2587b..400db51 100644 --- a/save-git.c +++ b/save-git.c @@ -9,6 +9,7 @@ #include <unistd.h> #include <fcntl.h> #include <git2.h> +#include "gettext.h" #include "dive.h" #include "device.h" @@ -573,7 +574,7 @@ static int save_one_divecomputer(git_repository *repo, struct dir *tree, struct save_dc(&buf, dive, dc); ret = blob_insert(repo, tree, &buf, "Divecomputer%c%03u", idx ? '-' : 0, idx); if (ret) - report_error("divecomputer tree insert failed"); + report_error(translate("gettextFromC","divecomputer tree insert failed")); return ret; } @@ -629,7 +630,7 @@ static int save_one_dive(git_repository *repo, struct dir *tree, struct dive *di ret = blob_insert(repo, subdir, &buf, "Dive%c%d", nr ? '-' : 0, nr); if (ret) - return report_error("dive save-file tree insert failed"); + return report_error(translate("gettextFromC","dive save-file tree insert failed")); /* * Save the dive computer data. If there is only one dive @@ -713,10 +714,10 @@ static int save_trip_description(git_repository *repo, struct dir *dir, dive_tri ret = git_blob_create_frombuffer(&blob_id, repo, desc.buffer, desc.len); free_buffer(&desc); if (ret) - return report_error("trip blob creation failed"); + return report_error(translate("gettextFromC","trip blob creation failed")); ret = tree_insert(dir->files, "00-Trip", 0, &blob_id, GIT_FILEMODE_BLOB); if (ret) - return report_error("trip description tree insert failed"); + return report_error(translate("gettextFromC","trip description tree insert failed")); return 0; } @@ -888,7 +889,7 @@ static int notify_cb(git_checkout_notify_t why, const git_diff_file *workdir, void *payload) { - report_error("File '%s' does not match in working tree", path); + report_error(translate("gettextFromC","File '%s' does not match in working tree"), path); return 0; /* Continue with checkout */ } @@ -973,21 +974,21 @@ static int create_new_commit(git_repository *repo, const char *branch, git_oid * ret = git_branch_lookup(&ref, repo, branch, GIT_BRANCH_LOCAL); switch (ret) { default: - return report_error("Bad branch '%s' (%s)", branch, strerror(errno)); + return report_error(translate("gettextFromC","Bad branch '%s' (%s)"), branch, strerror(errno)); case GIT_EINVALIDSPEC: - return report_error("Invalid branch name '%s'", branch); + return report_error(translate("gettextFromC","Invalid branch name '%s'"), branch); case GIT_ENOTFOUND: /* We'll happily create it */ ref = NULL; parent = try_to_find_parent(saved_git_id, repo); break; case 0: if (git_reference_peel(&parent, ref, GIT_OBJ_COMMIT)) - return report_error("Unable to look up parent in branch '%s'", branch); + return report_error(translate("gettextFromC","Unable to look up parent in branch '%s'"), branch); if (saved_git_id) { const git_oid *id = git_commit_id((const git_commit *) parent); if (git_oid_strcmp(id, saved_git_id)) - return report_error("The git branch does not match the git parent of the source"); + return report_error(translate("gettextFromC","The git branch does not match the git parent of the source")); } /* all good */ @@ -995,10 +996,10 @@ static int create_new_commit(git_repository *repo, const char *branch, git_oid * } if (git_tree_lookup(&tree, repo, tree_id)) - return report_error("Could not look up newly created tree"); + return report_error(translate("gettextFromC","Could not look up newly created tree")); if (get_authorship(repo, &author)) - return report_error("No user name configuration in git repo"); + return report_error(translate("gettextFromC","No user name configuration in git repo")); /* If the parent commit has the same tree ID, do not create a new commit */ if (parent && git_oid_equal(tree_id, git_commit_tree_id((const git_commit *) parent))) { @@ -1012,16 +1013,16 @@ static int create_new_commit(git_repository *repo, const char *branch, git_oid * create_commit_message(&commit_msg); if (git_commit_create_v(&commit_id, repo, NULL, author, author, NULL, mb_cstring(&commit_msg), tree, parent != NULL, parent)) - return report_error("Git commit create failed (%s)", strerror(errno)); + return report_error(translate("gettextFromC","Git commit create failed (%s)"), strerror(errno)); free_buffer(&commit_msg); if (git_commit_lookup(&commit, repo, &commit_id)) - return report_error("Could not look up newly created commit"); + return report_error(translate("gettextFromC","Could not look up newly created commit")); } if (!ref) { if (git_branch_create(&ref, repo, branch, commit, 0, author, "Create branch")) - return report_error("Failed to create branch '%s'", branch); + return report_error(translate("gettextFromC","Failed to create branch '%s'"), branch); } /* * If it's a checked-out branch, try to also update the working @@ -1034,13 +1035,13 @@ static int create_new_commit(git_repository *repo, const char *branch, git_oid * if (update_git_checkout(repo, parent, tree)) { const git_error *err = giterr_last(); const char *errstr = err ? err->message : strerror(errno); - report_error("Git branch '%s' is checked out, but worktree is dirty (%s)", + report_error(translate("gettextFromC","Git branch '%s' is checked out, but worktree is dirty (%s)"), branch, errstr); } } if (git_reference_set_target(&ref, ref, &commit_id, author, "Subsurface save event")) - return report_error("Failed to update branch '%s'", branch); + return report_error(translate("gettextFromC","Failed to update branch '%s'"), branch); set_git_id(&commit_id); git_signature_free(author); @@ -1081,14 +1082,14 @@ static int do_git_save(git_repository *repo, const char *branch, bool select_onl tree.name[0] = 0; tree.subdirs = NULL; if (git_treebuilder_new(&tree.files, repo, NULL)) - return report_error("git treebuilder failed"); + return report_error(translate("gettextFromC","git treebuilder failed")); /* Populate our tree data structure */ if (create_git_tree(repo, &tree, select_only)) return -1; if (write_git_tree(repo, &tree, &id)) - return report_error("git tree write failed"); + return report_error(translate("gettextFromC","git tree write failed")); /* And save the tree! */ return create_new_commit(repo, branch, &id); @@ -1166,7 +1167,7 @@ int git_save_dives(struct git_repository *repo, const char *branch, bool select_ int ret; if (repo == dummy_git_repository) - return report_error("Unable to open git repository '%s'", branch); + return report_error(translate("gettextFromC","Unable to open git repository '%s'"), branch); ret = do_git_save(repo, branch, select_only); git_repository_free(repo); free((void *)branch); -- 1.9.3 (Apple Git-50)
Best Robert PS: It’s probably not mission critical if those don’t have translations for the release, in particular since most of them are in the git load/save as that is not transparent to general users anyway. |
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
