mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Trying to switch to Qt translation
This compiles and looks about right, but it doesn't appear to work, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2c4ccc04bd
commit
4d3e74a236
24 changed files with 272 additions and 294 deletions
1
Makefile
1
Makefile
|
@ -79,6 +79,7 @@ SOURCES = \
|
|||
uemis.c \
|
||||
uemis-downloader.c \
|
||||
libdivecomputer.c \
|
||||
gettextfromc.cpp \
|
||||
qthelper.cpp \
|
||||
qt-ui/simplewidgets.cpp \
|
||||
qt-ui/tableview.cpp \
|
||||
|
|
29
dive.c
29
dive.c
|
@ -2,10 +2,7 @@
|
|||
/* maintains the internal dive list structure */
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#endif
|
||||
|
||||
#include "gettext.h"
|
||||
#include "dive.h"
|
||||
|
||||
void add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name)
|
||||
|
@ -43,15 +40,15 @@ int get_pressure_units(unsigned int mb, const char **units)
|
|||
switch (units_p->pressure) {
|
||||
case PASCAL:
|
||||
pressure = mb * 100;
|
||||
unit = _("pascal");
|
||||
unit = tr("pascal");
|
||||
break;
|
||||
case BAR:
|
||||
pressure = (mb + 500) / 1000;
|
||||
unit = _("bar");
|
||||
unit = tr("bar");
|
||||
break;
|
||||
case PSI:
|
||||
pressure = mbar_to_PSI(mb);
|
||||
unit = _("psi");
|
||||
unit = tr("psi");
|
||||
break;
|
||||
}
|
||||
if (units)
|
||||
|
@ -87,12 +84,12 @@ double get_volume_units(unsigned int ml, int *frac, const char **units)
|
|||
switch (units_p->volume) {
|
||||
case LITER:
|
||||
vol = ml / 1000.0;
|
||||
unit = _("l");
|
||||
unit = tr("l");
|
||||
decimals = 1;
|
||||
break;
|
||||
case CUFT:
|
||||
vol = ml_to_cuft(ml);
|
||||
unit = _("cuft");
|
||||
unit = tr("cuft");
|
||||
decimals = 2;
|
||||
break;
|
||||
}
|
||||
|
@ -113,12 +110,12 @@ double get_depth_units(unsigned int mm, int *frac, const char **units)
|
|||
switch (units_p->length) {
|
||||
case METERS:
|
||||
d = mm / 1000.0;
|
||||
unit = _("m");
|
||||
unit = tr("m");
|
||||
decimals = d < 20;
|
||||
break;
|
||||
case FEET:
|
||||
d = mm_to_feet(mm);
|
||||
unit = _("ft");
|
||||
unit = tr("ft");
|
||||
decimals = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -139,11 +136,11 @@ double get_vertical_speed_units(unsigned int mms, int *frac, const char **units)
|
|||
switch (units_p->length) {
|
||||
case METERS:
|
||||
d = mms / 1000.0 * time_factor;
|
||||
unit = _((units_p->vertical_speed_time == MINUTES) ? "m/min" : "m/s");
|
||||
unit = tr((units_p->vertical_speed_time == MINUTES) ? "m/min" : "m/s");
|
||||
break;
|
||||
case FEET:
|
||||
d = mm_to_feet(mms) * time_factor;
|
||||
unit = _((units_p->vertical_speed_time == MINUTES) ? "ft/min" : "ft/s");
|
||||
unit = tr((units_p->vertical_speed_time == MINUTES) ? "ft/min" : "ft/s");
|
||||
break;
|
||||
}
|
||||
if (frac)
|
||||
|
@ -162,11 +159,11 @@ double get_weight_units(unsigned int grams, int *frac, const char **units)
|
|||
|
||||
if (units_p->weight == LBS) {
|
||||
value = grams_to_lbs(grams);
|
||||
unit = _("lbs");
|
||||
unit = tr("lbs");
|
||||
decimals = 0;
|
||||
} else {
|
||||
value = grams / 1000.0;
|
||||
unit = _("kg");
|
||||
unit = tr("kg");
|
||||
decimals = 1;
|
||||
}
|
||||
if (frac)
|
||||
|
@ -962,7 +959,7 @@ static char *merge_text(const char *a, const char *b)
|
|||
res = malloc(strlen(a) + strlen(b) + 32);
|
||||
if (!res)
|
||||
return (char *)a;
|
||||
sprintf(res, _("(%s) or (%s)"), a, b);
|
||||
sprintf(res, tr("(%s) or (%s)"), a, b);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
8
dive.h
8
dive.h
|
@ -7,12 +7,6 @@
|
|||
#include <math.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#if 0
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#else /* this is stupid - this doesn't deal with translations anymore */
|
||||
#define _(arg) arg
|
||||
#endif
|
||||
#include <libxml/tree.h>
|
||||
#include <libxslt/transform.h>
|
||||
|
||||
|
@ -744,7 +738,7 @@ void free_dps(struct divedatapoint *dp);
|
|||
void get_gas_string(int o2, int he, char *buf, int len);
|
||||
struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2);
|
||||
void dump_plan(struct diveplan *diveplan);
|
||||
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, char **error_string_p);
|
||||
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, const char **error_string_p);
|
||||
void delete_single_dive(int idx);
|
||||
|
||||
struct event *get_next_event(struct event *event, char *name);
|
||||
|
|
16
divelist.c
16
divelist.c
|
@ -38,11 +38,7 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else /* stupid */
|
||||
#define _(arg) arg
|
||||
#endif
|
||||
#include "gettext.h"
|
||||
#include <assert.h>
|
||||
#include <zip.h>
|
||||
#include <libxslt/transform.h>
|
||||
|
@ -580,7 +576,7 @@ char *get_dive_date_string(timestamp_t when)
|
|||
utc_mkdate(when, &tm);
|
||||
snprintf(buffer, MAX_DATE_STRING,
|
||||
/*++GETTEXT 60 char buffer weekday, monthname, day of month, year, hour:min */
|
||||
_("%1$s, %2$s %3$d, %4$d %5$02d:%6$02d"),
|
||||
tr("%1$s, %2$s %3$d, %4$d %5$02d:%6$02d"),
|
||||
weekday(tm.tm_wday),
|
||||
monthname(tm.tm_mon),
|
||||
tm.tm_mday, tm.tm_year + 1900,
|
||||
|
@ -597,7 +593,7 @@ char *get_short_dive_date_string(timestamp_t when)
|
|||
utc_mkdate(when, &tm);
|
||||
snprintf(buffer, MAX_DATE_STRING,
|
||||
/*++GETTEXT 40 char buffer monthname, day of month, year, hour:min */
|
||||
_("%1$s %2$d, %3$d\n%4$02d:%5$02d"),
|
||||
tr("%1$s %2$d, %3$d\n%4$02d:%5$02d"),
|
||||
monthname(tm.tm_mon),
|
||||
tm.tm_mday, tm.tm_year +1900,
|
||||
tm.tm_hour, tm.tm_min);
|
||||
|
@ -619,14 +615,14 @@ char *get_trip_date_string(timestamp_t when, int nr)
|
|||
ngettext("%1$s %2$d (%3$d dive)",
|
||||
"%1$s %2$d (%3$d dives)", nr),
|
||||
#else
|
||||
_("%1$s %2$d (%3$d dives)"),
|
||||
tr("%1$s %2$d (%3$d dives)"),
|
||||
#endif
|
||||
monthname(tm.tm_mon),
|
||||
tm.tm_year + 1900,
|
||||
nr);
|
||||
} else {
|
||||
snprintf(buffer, MAX_DATE_STRING,
|
||||
_("%1$s %2$d (1 dive)"),
|
||||
tr("%1$s %2$d (1 dive)"),
|
||||
monthname(tm.tm_mon),
|
||||
tm.tm_year + 1900);
|
||||
}
|
||||
|
@ -657,7 +653,7 @@ char *get_nitrox_string(struct dive *dive)
|
|||
else
|
||||
snprintf(buffer, MAX_NITROX_STRING, "%d" UTF8_ELLIPSIS "%d", o2low, o2);
|
||||
else
|
||||
strcpy(buffer, _("air"));
|
||||
strcpy(buffer, tr("air"));
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
|
18
equipment.c
18
equipment.c
|
@ -12,12 +12,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else /* stupid */
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
#include "gettext.h"
|
||||
#define QT_TR_NOOP(arg) arg
|
||||
#include "dive.h"
|
||||
#include "display.h"
|
||||
#if USE_GTK_UI
|
||||
|
@ -933,11 +929,11 @@ bad_tank_info:
|
|||
* This is a bit odd as the weight system types don't usually encode weight
|
||||
*/
|
||||
struct ws_info_t ws_info[100] = {
|
||||
{ N_("integrated"), 0 },
|
||||
{ N_("belt"), 0 },
|
||||
{ N_("ankle"), 0 },
|
||||
{ N_("backplate weight"), 0 },
|
||||
{ N_("clip-on"), 0 },
|
||||
{ QT_TR_NOOP("integrated"), 0 },
|
||||
{ QT_TR_NOOP("belt"), 0 },
|
||||
{ QT_TR_NOOP("ankle"), 0 },
|
||||
{ QT_TR_NOOP("backplate weight"), 0 },
|
||||
{ QT_TR_NOOP("clip-on"), 0 },
|
||||
};
|
||||
|
||||
#if USE_GTK_UI
|
||||
|
|
15
file.c
15
file.c
|
@ -4,12 +4,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else /* stupid */
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
#include "gettext.h"
|
||||
#include <zip.h>
|
||||
|
||||
#include "dive.h"
|
||||
|
@ -108,9 +103,9 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, char
|
|||
|
||||
if (readfile(filename, mem) < 0) {
|
||||
if (error) {
|
||||
int len = strlen(_("Failed to read '%s'")) + strlen(filename);
|
||||
int len = strlen(tr("Failed to read '%s'")) + strlen(filename);
|
||||
*error = malloc(len);
|
||||
snprintf(*error, len, _("Failed to read '%s'"), filename);
|
||||
snprintf(*error, len, tr("Failed to read '%s'"), filename);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -305,9 +300,9 @@ void parse_file(const char *filename, char **error)
|
|||
return;
|
||||
|
||||
if (error) {
|
||||
int len = strlen(_("Failed to read '%s'")) + strlen(filename);
|
||||
int len = strlen(tr("Failed to read '%s'")) + strlen(filename);
|
||||
*error = malloc(len);
|
||||
snprintf(*error, len, _("Failed to read '%s'"), filename);
|
||||
snprintf(*error, len, tr("Failed to read '%s'"), filename);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
9
gettext.h
Normal file
9
gettext.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef MYGETTEXT_H
|
||||
#define MYGETTEXT_H
|
||||
|
||||
/* this is for the Qt based translations */
|
||||
extern const char *gettext(const char *);
|
||||
#define tr(arg) gettext(arg)
|
||||
#define QT_TR_NOOP(arg) arg
|
||||
|
||||
#endif // MYGETTEXT_H
|
19
gettextfromc.cpp
Normal file
19
gettextfromc.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
#include <gettextfromc.h>
|
||||
|
||||
char *gettextFromC::gettext(const char *text)
|
||||
{
|
||||
return tr(text).toLocal8Bit().data();
|
||||
}
|
||||
|
||||
gettextFromC* gettextFromC::instance()
|
||||
{
|
||||
static gettextFromC *self = new gettextFromC();
|
||||
return self;
|
||||
}
|
||||
|
||||
extern "C" const char *gettext(const char *text)
|
||||
{
|
||||
return gettextFromC::instance()->gettext(text);
|
||||
}
|
15
gettextfromc.h
Normal file
15
gettextfromc.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef GETTEXT_H
|
||||
#define GETTEXT_H
|
||||
|
||||
|
||||
extern "C" const char *gettext(const char *text);
|
||||
|
||||
class gettextFromC
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(gettextFromC)
|
||||
public:
|
||||
static gettextFromC *instance();
|
||||
char *gettext(const char *text);
|
||||
};
|
||||
|
||||
#endif // GETTEXT_H
|
21
info.c
21
info.c
|
@ -19,13 +19,7 @@
|
|||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/time.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else /* stupid */
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
|
||||
#include "gettext.h"
|
||||
#include "dive.h"
|
||||
#include "display.h"
|
||||
#include "divelist.h"
|
||||
|
@ -92,7 +86,7 @@ int divename(char *buf, size_t size, struct dive *dive, char *trailer)
|
|||
|
||||
utc_mkdate(dive->when, &tm);
|
||||
/*++GETTEXT 80 char buffer: dive nr, weekday, month, day, year, hour, min <trailing text>*/
|
||||
return snprintf(buf, size, _("Dive #%1$d - %2$s %3$02d/%4$02d/%5$04d at %6$d:%7$02d %8$s"),
|
||||
return snprintf(buf, size, tr("Dive #%1$d - %2$s %3$02d/%4$02d/%5$04d at %6$d:%7$02d %8$s"),
|
||||
dive->number,
|
||||
weekday(tm.tm_wday),
|
||||
tm.tm_mon+1, tm.tm_mday,
|
||||
|
@ -134,7 +128,7 @@ const char *get_window_title(struct dive *dive)
|
|||
len1 = g_utf8_strlen(text, -1);
|
||||
sz = (len1 + 32) * sizeof(gunichar);
|
||||
buffer = malloc(sz);
|
||||
snprintf(buffer, sz, _("Dive #%d - "), dive->number);
|
||||
snprintf(buffer, sz, tr("Dive #%d - "), dive->number);
|
||||
g_utf8_strncpy(buffer + strlen(buffer), text, len1);
|
||||
text = buffer;
|
||||
}
|
||||
|
@ -176,7 +170,7 @@ static int string_advance_cardinal(const char *text, const char *look)
|
|||
int len = strlen(look);
|
||||
if (!strncasecmp(text, look, len))
|
||||
return len;
|
||||
trans = _(look);
|
||||
trans = tr(look);
|
||||
len = strlen(trans);
|
||||
if (!strncasecmp(text, trans, len))
|
||||
return len;
|
||||
|
@ -311,14 +305,15 @@ void print_gps_coordinates(char *buffer, int len, int lat, int lon)
|
|||
#if 0
|
||||
double latmin, lonmin;
|
||||
#endif
|
||||
char *lath, *lonh, dbuf_lat[32], dbuf_lon[32];
|
||||
const char *lath, *lonh;
|
||||
char dbuf_lat[32], dbuf_lon[32];
|
||||
|
||||
if (!lat && !lon) {
|
||||
*buffer = 0;
|
||||
return;
|
||||
}
|
||||
lath = lat >= 0 ? _("N") : _("S");
|
||||
lonh = lon >= 0 ? _("E") : _("W");
|
||||
lath = lat >= 0 ? tr("N") : tr("S");
|
||||
lonh = lon >= 0 ? tr("E") : tr("W");
|
||||
lat = abs(lat);
|
||||
lon = abs(lon);
|
||||
latdeg = lat / 1000000;
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
|
||||
#include "gettext.h"
|
||||
#include "dive.h"
|
||||
#include "device.h"
|
||||
#include "divelist.h"
|
||||
|
@ -156,12 +150,12 @@ static void handle_event(struct divecomputer *dc, struct sample *sample, dc_samp
|
|||
/* we mark these for translation here, but we store the untranslated strings
|
||||
* and only translate them when they are displayed on screen */
|
||||
static const char *events[] = {
|
||||
N_("none"), N_("deco stop"), N_("rbt"), N_("ascent"), N_("ceiling"), N_("workload"),
|
||||
N_("transmitter"), N_("violation"), N_("bookmark"), N_("surface"), N_("safety stop"),
|
||||
N_("gaschange"), N_("safety stop (voluntary)"), N_("safety stop (mandatory)"),
|
||||
N_("deepstop"), N_("ceiling (safety stop)"), N_("below floor"), N_("divetime"),
|
||||
N_("maxdepth"), N_("OLF"), N_("PO2"), N_("airtime"), N_("rgbm"), N_("heading"),
|
||||
N_("tissue level warning"), N_("gaschange"), N_("non stop time")
|
||||
QT_TR_NOOP("none"), QT_TR_NOOP("deco stop"), QT_TR_NOOP("rbt"), QT_TR_NOOP("ascent"), QT_TR_NOOP("ceiling"), QT_TR_NOOP("workload"),
|
||||
QT_TR_NOOP("transmitter"), QT_TR_NOOP("violation"), QT_TR_NOOP("bookmark"), QT_TR_NOOP("surface"), QT_TR_NOOP("safety stop"),
|
||||
QT_TR_NOOP("gaschange"), QT_TR_NOOP("safety stop (voluntary)"), QT_TR_NOOP("safety stop (mandatory)"),
|
||||
QT_TR_NOOP("deepstop"), QT_TR_NOOP("ceiling (safety stop)"), QT_TR_NOOP("below floor"), QT_TR_NOOP("divetime"),
|
||||
QT_TR_NOOP("maxdepth"), QT_TR_NOOP("OLF"), QT_TR_NOOP("PO2"), QT_TR_NOOP("airtime"), QT_TR_NOOP("rgbm"), QT_TR_NOOP("heading"),
|
||||
QT_TR_NOOP("tissue level warning"), QT_TR_NOOP("gaschange"), QT_TR_NOOP("non stop time")
|
||||
};
|
||||
const int nr_events = sizeof(events) / sizeof(const char *);
|
||||
const char *name;
|
||||
|
@ -178,7 +172,7 @@ static void handle_event(struct divecomputer *dc, struct sample *sample, dc_samp
|
|||
* Other evens might be more interesting, but for now we just print them out.
|
||||
*/
|
||||
type = value.event.type;
|
||||
name = N_("invalid event number");
|
||||
name = QT_TR_NOOP("invalid event number");
|
||||
if (type < nr_events)
|
||||
name = events[type];
|
||||
|
||||
|
@ -411,13 +405,13 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
|
||||
rc = create_parser(devdata, &parser);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
dev_info(devdata, _("Unable to create parser for %s %s"), devdata->vendor, devdata->product);
|
||||
dev_info(devdata, tr("Unable to create parser for %s %s"), devdata->vendor, devdata->product);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = dc_parser_set_data(parser, data, size);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
dev_info(devdata, _("Error registering the data"));
|
||||
dev_info(devdata, tr("Error registering the data"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -426,7 +420,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
dive = alloc_dive();
|
||||
rc = dc_parser_get_datetime(parser, &dt);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
dev_info(devdata, _("Error parsing the datetime"));
|
||||
dev_info(devdata, tr("Error parsing the datetime"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -443,12 +437,12 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
dive->when = dive->dc.when = utc_mktime(&tm);
|
||||
|
||||
// Parse the divetime.
|
||||
dev_info(devdata, _("Dive %d: %s %d %04d"), import_dive_number,
|
||||
dev_info(devdata, tr("Dive %d: %s %d %04d"), import_dive_number,
|
||||
monthname(tm.tm_mon), tm.tm_mday, year(tm.tm_year));
|
||||
unsigned int divetime = 0;
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_DIVETIME, 0, &divetime);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
dev_info(devdata, _("Error parsing the divetime"));
|
||||
dev_info(devdata, tr("Error parsing the divetime"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -458,7 +452,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
double maxdepth = 0.0;
|
||||
rc = dc_parser_get_field(parser, DC_FIELD_MAXDEPTH, 0, &maxdepth);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
dev_info(devdata, _("Error parsing the maxdepth"));
|
||||
dev_info(devdata, tr("Error parsing the maxdepth"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -468,7 +462,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
unsigned int ngases = 0;
|
||||
rc = dc_parser_get_field(parser, DC_FIELD_GASMIX_COUNT, 0, &ngases);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
dev_info(devdata, _("Error parsing the gas mix count"));
|
||||
dev_info(devdata, tr("Error parsing the gas mix count"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -481,7 +475,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
};
|
||||
rc = dc_parser_get_field(parser, DC_FIELD_SALINITY, 0, &salinity);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
dev_info(devdata, _("Error obtaining water salinity"));
|
||||
dev_info(devdata, tr("Error obtaining water salinity"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -490,7 +484,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
double surface_pressure = 1.0;
|
||||
rc = dc_parser_get_field(parser, DC_FIELD_ATMOSPHERIC, 0, &surface_pressure);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
dev_info(devdata, _("Error obtaining surface pressure"));
|
||||
dev_info(devdata, tr("Error obtaining surface pressure"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -499,7 +493,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
|
||||
rc = parse_gasmixes(devdata, dive, parser, ngases, data);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
dev_info(devdata, _("Error parsing the gas mix"));
|
||||
dev_info(devdata, tr("Error parsing the gas mix"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -507,7 +501,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
// Initialize the sample data.
|
||||
rc = parse_samples(devdata, &dive->dc, parser);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
dev_info(devdata, _("Error parsing the samples"));
|
||||
dev_info(devdata, tr("Error parsing the samples"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
|
@ -634,7 +628,7 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
|
|||
|
||||
switch (event) {
|
||||
case DC_EVENT_WAITING:
|
||||
dev_info(devdata, _("Event: waiting for user action"));
|
||||
dev_info(devdata, tr("Event: waiting for user action"));
|
||||
break;
|
||||
case DC_EVENT_PROGRESS:
|
||||
if (!progress->maximum)
|
||||
|
@ -642,7 +636,7 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
|
|||
progress_bar_fraction = (double) progress->current / (double) progress->maximum;
|
||||
break;
|
||||
case DC_EVENT_DEVINFO:
|
||||
dev_info(devdata, _("model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)"),
|
||||
dev_info(devdata, tr("model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)"),
|
||||
devinfo->model, devinfo->model,
|
||||
devinfo->firmware, devinfo->firmware,
|
||||
devinfo->serial, devinfo->serial);
|
||||
|
@ -657,7 +651,7 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
|
|||
|
||||
break;
|
||||
case DC_EVENT_CLOCK:
|
||||
dev_info(devdata, _("Event: systime=%"PRId64", devtime=%u\n"),
|
||||
dev_info(devdata, tr("Event: systime=%"PRId64", devtime=%u\n"),
|
||||
(uint64_t)clock->systime, clock->devtime);
|
||||
break;
|
||||
default:
|
||||
|
@ -684,16 +678,16 @@ static const char *do_device_import(device_data_t *data)
|
|||
int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK;
|
||||
rc = dc_device_set_events(device, events, event_cb, data);
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
return _("Error registering the event handler.");
|
||||
return tr("Error registering the event handler.");
|
||||
|
||||
// Register the cancellation handler.
|
||||
rc = dc_device_set_cancel(device, cancel_cb, data);
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
return _("Error registering the cancellation handler.");
|
||||
return tr("Error registering the cancellation handler.");
|
||||
|
||||
rc = import_device_data(device, data);
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
return _("Dive data import error");
|
||||
return tr("Dive data import error");
|
||||
|
||||
/* All good */
|
||||
return NULL;
|
||||
|
@ -711,9 +705,9 @@ const char *do_libdivecomputer_import(device_data_t *data)
|
|||
|
||||
rc = dc_context_new(&data->context);
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
return _("Unable to create libdivecomputer context");
|
||||
return tr("Unable to create libdivecomputer context");
|
||||
|
||||
err = _("Unable to open %s %s (%s)");
|
||||
err = tr("Unable to open %s %s (%s)");
|
||||
rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
err = do_device_import(data);
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef struct device_data_t {
|
|||
} device_data_t;
|
||||
|
||||
const char *do_libdivecomputer_import(device_data_t *data);
|
||||
char *do_uemis_import(const char *mountpath, short force_download);
|
||||
const char *do_uemis_import(const char *mountpath, short force_download);
|
||||
|
||||
extern int import_thread_cancelled;
|
||||
extern const char *progress_bar_text;
|
||||
|
|
23
parse-xml.c
23
parse-xml.c
|
@ -11,12 +11,9 @@
|
|||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxslt/transform.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else /* stupid */
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
#include<sqlite3.h>
|
||||
|
||||
#include "dive.h"
|
||||
|
@ -541,7 +538,7 @@ static void percent(char *buffer, void *_fraction)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
printf(_("Strange percentage reading %s\n"), buffer);
|
||||
printf(tr("Strange percentage reading %s\n"), buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1687,8 +1684,8 @@ void parse_xml_buffer(const char *url, const char *buffer, int size,
|
|||
free((char *)res);
|
||||
|
||||
if (!doc) {
|
||||
fprintf(stderr, _("Failed to parse '%s'.\n"), url);
|
||||
parser_error(error, _("Failed to parse '%s'"), url);
|
||||
fprintf(stderr, tr("Failed to parse '%s'.\n"), url);
|
||||
parser_error(error, tr("Failed to parse '%s'"), url);
|
||||
return;
|
||||
}
|
||||
reset_all();
|
||||
|
@ -1886,7 +1883,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
|
|||
snprintf(get_events, sizeof(get_events) - 1, get_events_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_events, &dm4_events, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, _("Database query get_events failed.\n"));
|
||||
fprintf(stderr, tr("Database query get_events failed.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1921,14 +1918,14 @@ int parse_dm4_buffer(const char *url, const char *buffer, int size,
|
|||
retval = sqlite3_open(url,&handle);
|
||||
|
||||
if(retval) {
|
||||
fprintf(stderr, _("Database connection failed '%s'.\n"), url);
|
||||
fprintf(stderr, tr("Database connection failed '%s'.\n"), url);
|
||||
return 1;
|
||||
}
|
||||
|
||||
retval = sqlite3_exec(handle, get_dives, &dm4_dive, handle, &err);
|
||||
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, _("Database query failed '%s'.\n"), url);
|
||||
fprintf(stderr, tr("Database query failed '%s'.\n"), url);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2040,7 +2037,7 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, char **error)
|
|||
xmlSubstituteEntitiesDefault(1);
|
||||
xslt = get_stylesheet(info->file);
|
||||
if (xslt == NULL) {
|
||||
parser_error(error, _("Can't open stylesheet (%s)/%s"), xslt_path, info->file);
|
||||
parser_error(error, tr("Can't open stylesheet (%s)/%s"), xslt_path, info->file);
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
|
51
planner.c
51
planner.c
|
@ -4,18 +4,13 @@
|
|||
*
|
||||
* (c) Dirk Hohndel 2013
|
||||
*/
|
||||
#include <libintl.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else
|
||||
#define _(arg) arg
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "dive.h"
|
||||
#include "divelist.h"
|
||||
#include "planner.h"
|
||||
#include "gettext.h"
|
||||
|
||||
int decostoplevels[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000,
|
||||
30000, 33000, 36000, 39000, 42000, 45000, 48000, 51000, 54000, 57000,
|
||||
|
@ -96,15 +91,15 @@ static int get_gasidx(struct dive *dive, int o2, int he)
|
|||
void get_gas_string(int o2, int he, char *text, int len)
|
||||
{
|
||||
if (is_air(o2, he))
|
||||
snprintf(text, len, _("air"));
|
||||
snprintf(text, len, tr("air"));
|
||||
else if (he == 0)
|
||||
snprintf(text, len, _("EAN%d"), (o2 + 5) / 10);
|
||||
snprintf(text, len, tr("EAN%d"), (o2 + 5) / 10);
|
||||
else
|
||||
snprintf(text, len, "(%d/%d)", (o2 + 5) / 10, (he + 5) / 10);
|
||||
}
|
||||
|
||||
/* returns the tissue tolerance at the end of this (partial) dive */
|
||||
double tissue_at_end(struct dive *dive, char **cached_datap, char **error_string_p)
|
||||
double tissue_at_end(struct dive *dive, char **cached_datap, const char **error_string_p)
|
||||
{
|
||||
struct divecomputer *dc;
|
||||
struct sample *sample, *psample;
|
||||
|
@ -133,7 +128,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap, char **error_string
|
|||
t1 = sample->time.seconds;
|
||||
get_gas_from_events(&dive->dc, t0, &o2, &he);
|
||||
if ((gasidx = get_gasidx(dive, o2, he)) == -1) {
|
||||
snprintf(buf, sizeof(buf),_("Can't find gas %d/%d"), (o2 + 5) / 10, (he + 5) / 10);
|
||||
snprintf(buf, sizeof(buf),tr("Can't find gas %d/%d"), (o2 + 5) / 10, (he + 5) / 10);
|
||||
*error_string_p = buf;
|
||||
gasidx = 0;
|
||||
}
|
||||
|
@ -151,7 +146,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap, char **error_string
|
|||
}
|
||||
|
||||
/* how many seconds until we can ascend to the next stop? */
|
||||
int time_at_last_depth(struct dive *dive, int o2, int he, int next_stop, char **cached_data_p, char **error_string_p)
|
||||
int time_at_last_depth(struct dive *dive, int o2, int he, int next_stop, char **cached_data_p, const char **error_string_p)
|
||||
{
|
||||
int depth, gasidx;
|
||||
double surface_pressure, tissue_tolerance;
|
||||
|
@ -194,11 +189,11 @@ int add_gas(struct dive *dive, int o2, int he)
|
|||
mix->he.permille = he;
|
||||
/* since air is stored as 0/0 we need to set a name or an air cylinder
|
||||
* would be seen as unset (by cylinder_nodata()) */
|
||||
cyl->type.description = strdup(_("Cylinder for planning"));
|
||||
cyl->type.description = strdup(tr("Cylinder for planning"));
|
||||
return i;
|
||||
}
|
||||
|
||||
struct dive *create_dive_from_plan(struct diveplan *diveplan, char **error_string)
|
||||
struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error_string)
|
||||
{
|
||||
struct dive *dive;
|
||||
struct divedatapoint *dp;
|
||||
|
@ -219,7 +214,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, char **error_strin
|
|||
dive->when = diveplan->when;
|
||||
dive->dc.surface_pressure.mbar = diveplan->surface_pressure;
|
||||
dc = &dive->dc;
|
||||
dc->model = strdup(_("Simulated Dive"));
|
||||
dc->model = strdup(tr("Simulated Dive"));
|
||||
dp = diveplan->dp;
|
||||
|
||||
/* let's start with the gas given on the first segment */
|
||||
|
@ -296,7 +291,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, char **error_strin
|
|||
|
||||
gas_error_exit:
|
||||
free(dive);
|
||||
*error_string = _("Too many gas mixes");
|
||||
*error_string = tr("Too many gas mixes");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -513,7 +508,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
if (!dp)
|
||||
return;
|
||||
|
||||
snprintf(buffer, sizeof(buffer), _("%s\nSubsurface dive plan\nbased on GFlow = %.0f and GFhigh = %.0f\n\n"),
|
||||
snprintf(buffer, sizeof(buffer), tr("%s\nSubsurface dive plan\nbased on GFlow = %.0f and GFhigh = %.0f\n\n"),
|
||||
disclaimer, plangflow * 100, plangfhigh * 100);
|
||||
/* we start with gas 0, then check if that was changed */
|
||||
o2 = dive->cylinder[0].gasmix.o2.permille;
|
||||
|
@ -554,7 +549,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
if (dp->depth != lastdepth) {
|
||||
used = diveplan->bottomsac / 1000.0 * depth_to_mbar((dp->depth + lastdepth) / 2, dive) *
|
||||
(dp->time - lasttime) / 60;
|
||||
snprintf(buffer + len, sizeof(buffer) - len, _("Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s\n"),
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s\n"),
|
||||
decimals, depthvalue, depth_unit,
|
||||
FRACTION(dp->time - lasttime, 60),
|
||||
FRACTION(dp->time, 60),
|
||||
|
@ -563,7 +558,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
/* we use deco SAC rate during the calculated deco stops, bottom SAC rate everywhere else */
|
||||
int sac = dp->entered ? diveplan->bottomsac : diveplan->decosac;
|
||||
used = sac / 1000.0 * depth_to_mbar(dp->depth, dive) * (dp->time - lasttime) / 60;
|
||||
snprintf(buffer + len, sizeof(buffer) - len, _("Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s\n"),
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s\n"),
|
||||
decimals, depthvalue, depth_unit,
|
||||
FRACTION(dp->time - lasttime, 60),
|
||||
FRACTION(dp->time, 60),
|
||||
|
@ -574,7 +569,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
get_gas_string(newo2, newhe, gas, sizeof(gas));
|
||||
if (o2 != newo2 || he != newhe) {
|
||||
len = strlen(buffer);
|
||||
snprintf(buffer + len, sizeof(buffer) - len, _("Switch gas to %s\n"), gas);
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("Switch gas to %s\n"), gas);
|
||||
}
|
||||
o2 = newo2;
|
||||
he = newhe;
|
||||
|
@ -582,7 +577,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
lastdepth = dp->depth;
|
||||
} while ((dp = dp->next) != NULL);
|
||||
len = strlen(buffer);
|
||||
snprintf(buffer + len, sizeof(buffer) - len, _("Gas consumption:\n"));
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("Gas consumption:\n"));
|
||||
for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {
|
||||
double volume;
|
||||
const char *unit;
|
||||
|
@ -593,13 +588,13 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
|
|||
volume = get_volume_units(consumption[gasidx], NULL, &unit);
|
||||
get_gas_string(dive->cylinder[gasidx].gasmix.o2.permille,
|
||||
dive->cylinder[gasidx].gasmix.he.permille, gas, sizeof(gas));
|
||||
snprintf(buffer + len, sizeof(buffer) - len, _("%.0f%s of %s\n"), volume, unit, gas);
|
||||
snprintf(buffer + len, sizeof(buffer) - len, tr("%.0f%s of %s\n"), volume, unit, gas);
|
||||
}
|
||||
dive->notes = strdup(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, char **error_string_p)
|
||||
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, const char **error_string_p)
|
||||
{
|
||||
struct dive *dive;
|
||||
struct sample *sample;
|
||||
|
@ -814,9 +809,9 @@ int validate_gas(const char *text, int *o2_p, int *he_p)
|
|||
if (!*text)
|
||||
return 0;
|
||||
|
||||
if (!strcasecmp(text, _("air"))) {
|
||||
o2 = O2_IN_AIR; he = 0; text += strlen(_("air"));
|
||||
} else if (!strncasecmp(text, _("ean"), 3)) {
|
||||
if (!strcasecmp(text, tr("air"))) {
|
||||
o2 = O2_IN_AIR; he = 0; text += strlen(tr("air"));
|
||||
} else if (!strncasecmp(text, tr("ean"), 3)) {
|
||||
o2 = get_permille(text+3, &text); he = 0;
|
||||
} else {
|
||||
o2 = get_permille(text, &text); he = 0;
|
||||
|
@ -925,7 +920,7 @@ int validate_depth(const char *text, int *mm_p)
|
|||
if (*text == 'm') {
|
||||
imperial = 0;
|
||||
text++;
|
||||
} else if (!strcasecmp(text, _("ft"))) {
|
||||
} else if (!strcasecmp(text, tr("ft"))) {
|
||||
imperial = 1;
|
||||
text += 2;
|
||||
}
|
||||
|
@ -987,13 +982,13 @@ int validate_volume(const char *text, int *sac)
|
|||
if (*text == 'l') {
|
||||
imperial = 0;
|
||||
text++;
|
||||
} else if (!strncasecmp(text, _("cuft"), 4)) {
|
||||
} else if (!strncasecmp(text, tr("cuft"), 4)) {
|
||||
imperial = 1;
|
||||
text += 4;
|
||||
}
|
||||
while (isspace(*text) || *text == '/')
|
||||
text++;
|
||||
if (!strncasecmp(text, _("min"), 3))
|
||||
if (!strncasecmp(text, tr("min"), 3))
|
||||
text += 3;
|
||||
while (isspace(*text))
|
||||
text++;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void plan(struct diveplan *diveplan, char **cache_datap, struct dive **divep, bool add_plan, char **error_string_p);
|
||||
extern int validate_gas(const char *text, int *o2_p, int *he_p);
|
||||
extern int validate_time(const char *text, int *sec_p, int *rel_p);
|
||||
extern int validate_depth(const char *text, int *mm_p);
|
||||
|
|
69
profile.c
69
profile.c
|
@ -2,12 +2,7 @@
|
|||
/* creates all the necessary data for drawing the dive profile
|
||||
* uses cairo to draw it
|
||||
*/
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
#include "gettext.h"
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -135,7 +130,7 @@ int evn_foreach(void (*callback)(const char *, int *, void *), void *data)
|
|||
|
||||
for (i = 0; i < evn_used; i++) {
|
||||
/* here we display an event name on screen - so translate */
|
||||
callback(_(ev_namelist[i].ev_name), &ev_namelist[i].plot_ev, data);
|
||||
callback(tr(ev_namelist[i].ev_name), &ev_namelist[i].plot_ev, data);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -1224,22 +1219,22 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
|
|||
double depthvalue, tempvalue, speedvalue;
|
||||
|
||||
depthvalue = get_depth_units(depth, NULL, &depth_unit);
|
||||
snprintf(buf, bufsize, _("D:%.1f %s"), depthvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("D:%.1f %s"), depthvalue, depth_unit);
|
||||
|
||||
if (prefs.show_time) {
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nT:%d:%02d"), buf2, FRACTION(entry->sec, 60));
|
||||
snprintf(buf, bufsize, tr("%s\nT:%d:%02d"), buf2, FRACTION(entry->sec, 60));
|
||||
}
|
||||
|
||||
if (pressure) {
|
||||
pressurevalue = get_pressure_units(pressure, &pressure_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nP:%d %s"), buf2, pressurevalue, pressure_unit);
|
||||
snprintf(buf, bufsize, tr("%s\nP:%d %s"), buf2, pressurevalue, pressure_unit);
|
||||
}
|
||||
if (temp) {
|
||||
tempvalue = get_temp_units(temp, &temp_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nT:%.1f %s"), buf2, tempvalue, temp_unit);
|
||||
snprintf(buf, bufsize, tr("%s\nT:%.1f %s"), buf2, tempvalue, temp_unit);
|
||||
}
|
||||
|
||||
speedvalue = get_vertical_speed_units(abs(entry->speed), NULL, &vertical_speed_unit);
|
||||
|
@ -1247,19 +1242,19 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
|
|||
/* Ascending speeds are positive, descending are negative */
|
||||
if (entry->speed > 0)
|
||||
speedvalue *= -1;
|
||||
snprintf(buf, bufsize, _("%s\nV:%.2f %s"), buf2, speedvalue, vertical_speed_unit);
|
||||
snprintf(buf, bufsize, tr("%s\nV:%.2f %s"), buf2, speedvalue, vertical_speed_unit);
|
||||
|
||||
if (entry->ceiling) {
|
||||
depthvalue = get_depth_units(entry->ceiling, NULL, &depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nCalculated ceiling %.0f %s"), buf2, depthvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s\nCalculated ceiling %.0f %s"), buf2, depthvalue, depth_unit);
|
||||
if (prefs.calc_all_tissues){
|
||||
int k;
|
||||
for (k=0; k<16; k++){
|
||||
if (entry->ceilings[k]){
|
||||
depthvalue = get_depth_units(entry->ceilings[k], NULL, &depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nTissue %.0fmin: %.0f %s"), buf2, buehlmann_N2_t_halflife[k], depthvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s\nTissue %.0fmin: %.0f %s"), buf2, buehlmann_N2_t_halflife[k], depthvalue, depth_unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1270,62 +1265,62 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
|
|||
if (entry->ndl) {
|
||||
/* this is a safety stop as we still have ndl */
|
||||
if (entry->stoptime)
|
||||
snprintf(buf, bufsize, _("%s\nSafetystop:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
|
||||
snprintf(buf, bufsize, tr("%s\nSafetystop:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
|
||||
depthvalue, depth_unit);
|
||||
else
|
||||
snprintf(buf, bufsize, _("%s\nSafetystop:unkn time @ %.0f %s"), buf2,
|
||||
snprintf(buf, bufsize, tr("%s\nSafetystop:unkn time @ %.0f %s"), buf2,
|
||||
depthvalue, depth_unit);
|
||||
} else {
|
||||
/* actual deco stop */
|
||||
if (entry->stoptime)
|
||||
snprintf(buf, bufsize, _("%s\nDeco:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
|
||||
snprintf(buf, bufsize, tr("%s\nDeco:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
|
||||
depthvalue, depth_unit);
|
||||
else
|
||||
snprintf(buf, bufsize, _("%s\nDeco:unkn time @ %.0f %s"), buf2,
|
||||
snprintf(buf, bufsize, tr("%s\nDeco:unkn time @ %.0f %s"), buf2,
|
||||
depthvalue, depth_unit);
|
||||
}
|
||||
} else if (entry->in_deco) {
|
||||
/* this means we had in_deco set but don't have a stop depth */
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nIn deco"), buf2);
|
||||
snprintf(buf, bufsize, tr("%s\nIn deco"), buf2);
|
||||
} else if (has_ndl) {
|
||||
memcpy(buf2, buf, bufsize);
|
||||
if (entry->ndl == -1)
|
||||
snprintf(buf, bufsize, _("%s\nNDL:-"), buf2);
|
||||
snprintf(buf, bufsize, tr("%s\nNDL:-"), buf2);
|
||||
else
|
||||
snprintf(buf, bufsize, _("%s\nNDL:%umin"), buf2, DIV_UP(entry->ndl, 60));
|
||||
snprintf(buf, bufsize, tr("%s\nNDL:%umin"), buf2, DIV_UP(entry->ndl, 60));
|
||||
}
|
||||
if (entry->tts) {
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nTTS:%umin"), buf2, DIV_UP(entry->tts, 60));
|
||||
snprintf(buf, bufsize, tr("%s\nTTS:%umin"), buf2, DIV_UP(entry->tts, 60));
|
||||
}
|
||||
if (entry->cns) {
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nCNS:%u%%"), buf2, entry->cns);
|
||||
snprintf(buf, bufsize, tr("%s\nCNS:%u%%"), buf2, entry->cns);
|
||||
}
|
||||
if (prefs.pp_graphs.po2) {
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\npO%s:%.2fbar"), buf2, UTF8_SUBSCRIPT_2, entry->po2);
|
||||
snprintf(buf, bufsize, tr("%s\npO%s:%.2fbar"), buf2, UTF8_SUBSCRIPT_2, entry->po2);
|
||||
}
|
||||
if (prefs.pp_graphs.pn2) {
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\npN%s:%.2fbar"), buf2, UTF8_SUBSCRIPT_2, entry->pn2);
|
||||
snprintf(buf, bufsize, tr("%s\npN%s:%.2fbar"), buf2, UTF8_SUBSCRIPT_2, entry->pn2);
|
||||
}
|
||||
if (prefs.pp_graphs.phe) {
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\npHe:%.2fbar"), buf2, entry->phe);
|
||||
snprintf(buf, bufsize, tr("%s\npHe:%.2fbar"), buf2, entry->phe);
|
||||
}
|
||||
if (prefs.mod) {
|
||||
mod = (int)get_depth_units(entry->mod, NULL, &depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nMOD:%d%s"), buf2, mod, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s\nMOD:%d%s"), buf2, mod, depth_unit);
|
||||
}
|
||||
if (prefs.ead) {
|
||||
ead = (int)get_depth_units(entry->ead, NULL, &depth_unit);
|
||||
end = (int)get_depth_units(entry->end, NULL, &depth_unit);
|
||||
eadd = (int)get_depth_units(entry->eadd, NULL, &depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s\nEAD:%d%s\nEND:%d%s\nEADD:%d%s"), buf2, ead, depth_unit, end, depth_unit, eadd, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s\nEAD:%d%s\nEND:%d%s\nEADD:%d%s"), buf2, ead, depth_unit, end, depth_unit, eadd, depth_unit);
|
||||
}
|
||||
free(buf2);
|
||||
}
|
||||
|
@ -1424,42 +1419,42 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
|
|||
avg_depth /= stop->sec-start->sec;
|
||||
avg_speed /= stop->sec-start->sec;
|
||||
|
||||
snprintf(buf, bufsize, _("%sT: %d:%02d min"), UTF8_DELTA, delta_time/60, delta_time%60);
|
||||
snprintf(buf, bufsize, tr("%sT: %d:%02d min"), UTF8_DELTA, delta_time/60, delta_time%60);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
|
||||
depthvalue = get_depth_units(delta_depth, NULL, &depth_unit);
|
||||
snprintf(buf, bufsize, _("%s %sD:%.1f%s"), buf2, UTF8_DELTA, depthvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s %sD:%.1f%s"), buf2, UTF8_DELTA, depthvalue, depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
|
||||
depthvalue = get_depth_units(min_depth, NULL, &depth_unit);
|
||||
snprintf(buf, bufsize, _("%s %sD:%.1f%s"), buf2, UTF8_DOWNWARDS_ARROW, depthvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s %sD:%.1f%s"), buf2, UTF8_DOWNWARDS_ARROW, depthvalue, depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
|
||||
depthvalue = get_depth_units(max_depth, NULL, &depth_unit);
|
||||
snprintf(buf, bufsize, _("%s %sD:%.1f %s"), buf2, UTF8_UPWARDS_ARROW, depthvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s %sD:%.1f %s"), buf2, UTF8_UPWARDS_ARROW, depthvalue, depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
|
||||
depthvalue = get_depth_units(avg_depth, NULL, &depth_unit);
|
||||
snprintf(buf, bufsize, _("%s %sD:%.1f%s\n"), buf2, UTF8_AVERAGE, depthvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s %sD:%.1f%s\n"), buf2, UTF8_AVERAGE, depthvalue, depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
|
||||
speedvalue = get_depth_units(min_speed, NULL, &depth_unit);
|
||||
snprintf(buf, bufsize, _("%s%sV:%.2f%s/s"), buf2, UTF8_DOWNWARDS_ARROW, speedvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s%sV:%.2f%s/s"), buf2, UTF8_DOWNWARDS_ARROW, speedvalue, depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
|
||||
speedvalue = get_depth_units(max_speed, NULL, &depth_unit);
|
||||
snprintf(buf, bufsize, _("%s %sV:%.2f%s/s"), buf2, UTF8_UPWARDS_ARROW, speedvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s %sV:%.2f%s/s"), buf2, UTF8_UPWARDS_ARROW, speedvalue, depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
|
||||
speedvalue = get_depth_units(avg_speed, NULL, &depth_unit);
|
||||
snprintf(buf, bufsize, _("%s %sV:%.2f%s/s"), buf2, UTF8_AVERAGE, speedvalue, depth_unit);
|
||||
snprintf(buf, bufsize, tr("%s %sV:%.2f%s/s"), buf2, UTF8_AVERAGE, speedvalue, depth_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
|
||||
/* Only print if gas has been used */
|
||||
if (bar_used) {
|
||||
pressurevalue = get_pressure_units(bar_used, &pressure_unit);
|
||||
memcpy(buf2, buf, bufsize);
|
||||
snprintf(buf, bufsize, _("%s %sP:%d %s"), buf2, UTF8_DELTA, pressurevalue, pressure_unit);
|
||||
snprintf(buf, bufsize, tr("%s %sP:%d %s"), buf2, UTF8_DELTA, pressurevalue, pressure_unit);
|
||||
}
|
||||
|
||||
free(buf2);
|
||||
|
|
30
qt-gui.cpp
30
qt-gui.cpp
|
@ -1,9 +1,5 @@
|
|||
/* qt-gui.cpp */
|
||||
/* Qt UI implementation */
|
||||
#include <libintl.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -41,11 +37,15 @@
|
|||
#include <QDateTime>
|
||||
#include <QRegExp>
|
||||
|
||||
#include <gettextfromc.h>
|
||||
#define tr(arg) gettextFromC::instance()->tr(arg)
|
||||
|
||||
const char *default_dive_computer_vendor;
|
||||
const char *default_dive_computer_product;
|
||||
const char *default_dive_computer_device;
|
||||
DiveComputerList dcList;
|
||||
|
||||
#if 0
|
||||
class Translator: public QTranslator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -71,6 +71,7 @@ QString Translator::translate(const char *context, const char *sourceText,
|
|||
return gettext(sourceText);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static QApplication *application = NULL;
|
||||
static MainWindow *window = NULL;
|
||||
|
@ -120,7 +121,6 @@ void init_ui(int *argcp, char ***argvp)
|
|||
default_dive_computer_device = getSetting(s, "dive_computer_device");
|
||||
s.endGroup();
|
||||
|
||||
application->installTranslator(new Translator(application));
|
||||
window = new MainWindow();
|
||||
window->show();
|
||||
if (existing_filename && existing_filename[0] != '\0')
|
||||
|
@ -200,10 +200,10 @@ QString get_depth_string(int mm, bool showunit, bool showdecimal)
|
|||
{
|
||||
if (prefs.units.length == units::METERS) {
|
||||
double meters = mm / 1000.0;
|
||||
return QString("%1%2").arg(meters, 0, 'f', (showdecimal && meters < 20.0) ? 1 : 0 ).arg(showunit ? _("m") : "");
|
||||
return QString("%1%2").arg(meters, 0, 'f', (showdecimal && meters < 20.0) ? 1 : 0 ).arg(showunit ? tr("m") : "");
|
||||
} else {
|
||||
double feet = mm_to_feet(mm);
|
||||
return QString("%1%2").arg(feet, 0, 'f', showdecimal ? 1 : 0). arg(showunit ? _("ft") : "");
|
||||
return QString("%1%2").arg(feet, 0, 'f', showdecimal ? 1 : 0). arg(showunit ? tr("ft") : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,9 +224,9 @@ QString get_weight_string(weight_t weight, bool showunit)
|
|||
{
|
||||
QString str = weight_string (weight.grams);
|
||||
if (get_units()->weight == units::KG) {
|
||||
str = QString ("%1%2").arg(str).arg(showunit ? _("kg") : "");
|
||||
str = QString ("%1%2").arg(str).arg(showunit ? tr("kg") : "");
|
||||
} else {
|
||||
str = QString ("%1%2").arg(str).arg(showunit ? _("lbs") : "");
|
||||
str = QString ("%1%2").arg(str).arg(showunit ? tr("lbs") : "");
|
||||
}
|
||||
return (str);
|
||||
}
|
||||
|
@ -275,11 +275,11 @@ QString get_temperature_string(temperature_t temp, bool showunit)
|
|||
if (prefs.units.temperature == units::CELSIUS) {
|
||||
double celsius = mkelvin_to_C(temp.mkelvin);
|
||||
return QString("%1%2%3").arg(celsius, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE): "")
|
||||
.arg(showunit ? _("C") : "");
|
||||
.arg(showunit ? tr("C") : "");
|
||||
} else {
|
||||
double fahrenheit = mkelvin_to_F(temp.mkelvin);
|
||||
return QString("%1%2%3").arg(fahrenheit, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE): "")
|
||||
.arg(showunit ? _("F") : "");
|
||||
.arg(showunit ? tr("F") : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,10 +295,10 @@ QString get_volume_string(volume_t volume, bool showunit)
|
|||
{
|
||||
if (prefs.units.volume == units::LITER) {
|
||||
double liter = volume.mliter / 1000.0;
|
||||
return QString("%1%2").arg(liter, 0, 'f', liter >= 40.0 ? 0 : 1 ).arg(showunit ? _("l") : "");
|
||||
return QString("%1%2").arg(liter, 0, 'f', liter >= 40.0 ? 0 : 1 ).arg(showunit ? tr("l") : "");
|
||||
} else {
|
||||
double cuft = ml_to_cuft(volume.mliter);
|
||||
return QString("%1%2").arg(cuft, 0, 'f', cuft >= 20.0 ? 0 : (cuft >= 2.0 ? 1 : 2)).arg(showunit ? _("cuft") : "");
|
||||
return QString("%1%2").arg(cuft, 0, 'f', cuft >= 20.0 ? 0 : (cuft >= 2.0 ? 1 : 2)).arg(showunit ? tr("cuft") : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,10 +314,10 @@ QString get_pressure_string(pressure_t pressure, bool showunit)
|
|||
{
|
||||
if (prefs.units.pressure == units::BAR) {
|
||||
double bar = pressure.mbar / 1000.0;
|
||||
return QString("%1%2").arg(bar, 0, 'f', 1).arg(showunit ? _("bar") : "");
|
||||
return QString("%1%2").arg(bar, 0, 'f', 1).arg(showunit ? tr("bar") : "");
|
||||
} else {
|
||||
double psi = mbar_to_PSI(pressure.mbar);
|
||||
return QString("%1%2").arg(psi, 0, 'f', 0).arg(showunit ? _("psi") : "");
|
||||
return QString("%1%2").arg(psi, 0, 'f', 0).arg(showunit ? tr("psi") : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1184,7 +1184,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
|||
#endif
|
||||
char *cache = NULL;
|
||||
tempDive = NULL;
|
||||
char *errorString = NULL;
|
||||
const char *errorString = NULL;
|
||||
plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString);
|
||||
if (mode == ADD)
|
||||
copy_samples(tempDive, current_dive);
|
||||
|
@ -1216,7 +1216,7 @@ void DivePlannerPointsModel::createPlan()
|
|||
// to not delete it later. mumble. ;p
|
||||
char *cache = NULL;
|
||||
tempDive = NULL;
|
||||
char *errorString = NULL;
|
||||
const char *errorString = NULL;
|
||||
|
||||
createTemporaryPlan();
|
||||
plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString);
|
||||
|
|
|
@ -268,7 +268,7 @@ void MainWindow::on_actionAddDive_triggered()
|
|||
// now cheat - create one dive that we use to store the info tab data in
|
||||
struct dive *dive = alloc_dive();
|
||||
dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L;
|
||||
dive->dc.model = _("manually added dive"); // do not use tr here since it expects a char*.
|
||||
dive->dc.model = tr("manually added dive").toLocal8Bit().constData(); // do not use tr here since it expects a char*.
|
||||
record_dive(dive);
|
||||
select_dive(get_divenr(dive));
|
||||
ui.InfoWidget->updateDiveInfo(selected_dive);
|
||||
|
|
39
statistics.c
39
statistics.c
|
@ -6,12 +6,7 @@
|
|||
* void process_all_dives(struct dive *dive, struct dive **prev_dive);
|
||||
* void get_selected_dives_text(char *buffer, int size);
|
||||
*/
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
#include "gettext.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
@ -23,10 +18,10 @@
|
|||
/* mark for translation but don't translate here as these terms are used
|
||||
* in save-xml.c */
|
||||
char *dtag_names[DTAG_NR] = {
|
||||
N_("invalid"), N_("boat"), N_("shore"), N_("drift"), N_("deep"), N_("cavern"),
|
||||
N_("ice"), N_("wreck"), N_("cave"), N_("altitude"), N_("pool"), N_("lake"),
|
||||
N_("river"), N_("night"), N_("freshwater"), N_("training"), N_("teaching"),
|
||||
N_("photo"), N_("video"), N_("deco")
|
||||
QT_TR_NOOP("invalid"), QT_TR_NOOP("boat"), QT_TR_NOOP("shore"), QT_TR_NOOP("drift"), QT_TR_NOOP("deep"), QT_TR_NOOP("cavern"),
|
||||
QT_TR_NOOP("ice"), QT_TR_NOOP("wreck"), QT_TR_NOOP("cave"), QT_TR_NOOP("altitude"), QT_TR_NOOP("pool"), QT_TR_NOOP("lake"),
|
||||
QT_TR_NOOP("river"), QT_TR_NOOP("night"), QT_TR_NOOP("freshwater"), QT_TR_NOOP("training"), QT_TR_NOOP("teaching"),
|
||||
QT_TR_NOOP("photo"), QT_TR_NOOP("video"), QT_TR_NOOP("deco")
|
||||
};
|
||||
|
||||
static stats_t stats;
|
||||
|
@ -201,15 +196,15 @@ char *get_time_string(int seconds, int maxdays)
|
|||
{
|
||||
static char buf[80];
|
||||
if (maxdays && seconds > 3600 * 24 * maxdays) {
|
||||
snprintf(buf, sizeof(buf), _("more than %d days"), maxdays);
|
||||
snprintf(buf, sizeof(buf), tr("more than %d days"), maxdays);
|
||||
} else {
|
||||
int days = seconds / 3600 / 24;
|
||||
int hours = (seconds - days * 3600 * 24) / 3600;
|
||||
int minutes = (seconds - days * 3600 * 24 - hours * 3600) / 60;
|
||||
if (days > 0)
|
||||
snprintf(buf, sizeof(buf), _("%dd %dh %dmin"), days, hours, minutes);
|
||||
snprintf(buf, sizeof(buf), tr("%dd %dh %dmin"), days, hours, minutes);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), _("%dh %dmin"), hours, minutes);
|
||||
snprintf(buf, sizeof(buf), tr("%dh %dmin"), hours, minutes);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
@ -220,14 +215,14 @@ static void get_ranges(char *buffer, int size)
|
|||
int i, len;
|
||||
int first, last = -1;
|
||||
|
||||
snprintf(buffer, size, _("for dives #"));
|
||||
snprintf(buffer, size, tr("for dives #"));
|
||||
for (i = 0; i < dive_table.nr; i++) {
|
||||
struct dive *dive = get_dive(i);
|
||||
if (! dive->selected)
|
||||
continue;
|
||||
if (dive->number < 1) {
|
||||
/* uhh - weird numbers - bail */
|
||||
snprintf(buffer, size, _("for selected dives"));
|
||||
snprintf(buffer, size, tr("for selected dives"));
|
||||
return;
|
||||
}
|
||||
len = strlen(buffer);
|
||||
|
@ -262,13 +257,13 @@ void get_selected_dives_text(char *buffer, int size)
|
|||
{
|
||||
if (amount_selected == 1) {
|
||||
if (current_dive)
|
||||
snprintf(buffer, size, _("for dive #%d"), current_dive->number);
|
||||
snprintf(buffer, size, tr("for dive #%d"), current_dive->number);
|
||||
else
|
||||
snprintf(buffer, size, _("for selected dive"));
|
||||
snprintf(buffer, size, tr("for selected dive"));
|
||||
} else if (amount_selected == dive_table.nr) {
|
||||
snprintf(buffer, size, _("for all dives"));
|
||||
snprintf(buffer, size, tr("for all dives"));
|
||||
} else if (amount_selected == 0) {
|
||||
snprintf(buffer, size, _("(no dives)"));
|
||||
snprintf(buffer, size, tr("(no dives)"));
|
||||
} else {
|
||||
get_ranges(buffer, size);
|
||||
if (strlen(buffer) == size -1) {
|
||||
|
@ -358,10 +353,10 @@ char *get_gaslist(struct dive *dive)
|
|||
o2 = get_o2(&cyl->gasmix);
|
||||
he = get_he(&cyl->gasmix);
|
||||
if (is_air(o2, he))
|
||||
snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %s" : "%s", _("air"));
|
||||
snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %s" : "%s", tr("air"));
|
||||
else
|
||||
if (he == 0)
|
||||
snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? _(", EAN%d") : _("EAN%d"),
|
||||
snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? tr(", EAN%d") : tr("EAN%d"),
|
||||
(o2 + 5) / 10);
|
||||
else
|
||||
snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %d/%d" : "%d/%d",
|
||||
|
@ -369,6 +364,6 @@ char *get_gaslist(struct dive *dive)
|
|||
offset = strlen(buf);
|
||||
}
|
||||
if (*buf == '\0')
|
||||
strncpy(buf, _("air"), MAXBUF);
|
||||
strncpy(buf, tr("air"), MAXBUF);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
#include "subsurfacestartup.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else /* stupid */
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
#include "gettext.h"
|
||||
struct preferences prefs;
|
||||
struct preferences default_prefs = {
|
||||
.units = SI_UNITS,
|
||||
|
@ -63,19 +58,19 @@ const char *weekday(int wday)
|
|||
{
|
||||
static const char wday_array[7][7] = {
|
||||
/*++GETTEXT: these are three letter days - we allow up to six code bytes */
|
||||
N_("Sun"), N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat")
|
||||
QT_TR_NOOP("Sun"), QT_TR_NOOP("Mon"), QT_TR_NOOP("Tue"), QT_TR_NOOP("Wed"), QT_TR_NOOP("Thu"), QT_TR_NOOP("Fri"), QT_TR_NOOP("Sat")
|
||||
};
|
||||
return _(wday_array[wday]);
|
||||
return tr(wday_array[wday]);
|
||||
}
|
||||
|
||||
const char *monthname(int mon)
|
||||
{
|
||||
static const char month_array[12][7] = {
|
||||
/*++GETTEXT: these are three letter months - we allow up to six code bytes*/
|
||||
N_("Jan"), N_("Feb"), N_("Mar"), N_("Apr"), N_("May"), N_("Jun"),
|
||||
N_("Jul"), N_("Aug"), N_("Sep"), N_("Oct"), N_("Nov"), N_("Dec"),
|
||||
QT_TR_NOOP("Jan"), QT_TR_NOOP("Feb"), QT_TR_NOOP("Mar"), QT_TR_NOOP("Apr"), QT_TR_NOOP("May"), QT_TR_NOOP("Jun"),
|
||||
QT_TR_NOOP("Jul"), QT_TR_NOOP("Aug"), QT_TR_NOOP("Sep"), QT_TR_NOOP("Oct"), QT_TR_NOOP("Nov"), QT_TR_NOOP("Dec"),
|
||||
};
|
||||
return _(month_array[mon]);
|
||||
return tr(month_array[mon]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -131,7 +126,7 @@ void parse_argument(const char *arg)
|
|||
/* fallthrough */
|
||||
case 'p':
|
||||
/* ignore process serial number argument when run as native macosx app */
|
||||
if (strncmp(arg, "-psn_", 5) == 0) {
|
||||
if (strncmp(arg, "-psQT_TR_NOOP(", 5) == 0) {
|
||||
return;
|
||||
}
|
||||
/* fallthrough */
|
||||
|
|
|
@ -18,12 +18,7 @@
|
|||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
#include "gettext.h"
|
||||
|
||||
#include "libdivecomputer.h"
|
||||
#include "uemis.h"
|
||||
|
@ -33,9 +28,9 @@
|
|||
#if USE_GTK_UI
|
||||
#include "display-gtk.h"
|
||||
#endif
|
||||
#define ERR_FS_ALMOST_FULL N_("Uemis Zurich: File System is almost full\nDisconnect/reconnect the dive computer\nand click \'Retry\'")
|
||||
#define ERR_FS_FULL N_("Uemis Zurich: File System is full\nDisconnect/reconnect the dive computer\nand try again")
|
||||
#define ERR_FS_SHORT_WRITE N_("Short write to req.txt file\nIs the Uemis Zurich plugged in correctly?")
|
||||
#define ERR_FS_ALMOST_FULL QT_TR_NOOP("Uemis Zurich: File System is almost full\nDisconnect/reconnect the dive computer\nand click \'Retry\'")
|
||||
#define ERR_FS_FULL QT_TR_NOOP("Uemis Zurich: File System is full\nDisconnect/reconnect the dive computer\nand try again")
|
||||
#define ERR_FS_SHORT_WRITE QT_TR_NOOP("Short write to req.txt file\nIs the Uemis Zurich plugged in correctly?")
|
||||
#define BUFLEN 2048
|
||||
#define NUM_PARAM_BUFS 10
|
||||
|
||||
|
@ -119,7 +114,7 @@ static void uemis_get_index(char *buffer, int *idx)
|
|||
}
|
||||
|
||||
/* space separated */
|
||||
static void uemis_add_string(char *buffer, char **text)
|
||||
static void uemis_add_string(const char *buffer, char **text)
|
||||
{
|
||||
/* do nothing if this is an empty buffer (Uemis sometimes returns a single
|
||||
* space for empty buffers) */
|
||||
|
@ -142,7 +137,7 @@ static void uemis_get_weight(char *buffer, weightsystem_t *weight, int diveid)
|
|||
{
|
||||
weight->weight.grams = uemis_get_weight_unit(diveid) ?
|
||||
lbs_to_grams(ascii_strtod(buffer, NULL)) : ascii_strtod(buffer, NULL) * 1000;
|
||||
weight->description = strdup(_("unknown"));
|
||||
weight->description = strdup(tr("unknown"));
|
||||
}
|
||||
|
||||
static struct dive *uemis_start_dive(uint32_t deviceid)
|
||||
|
@ -383,7 +378,7 @@ static char *first_object_id_val(char* buf)
|
|||
/* ultra-simplistic; it doesn't deal with the case when the object_id is
|
||||
* split across two chunks. It also doesn't deal with the discrepancy between
|
||||
* object_id and dive number as understood by the dive computer */
|
||||
static void show_progress(char *buf, char *what)
|
||||
static void show_progress(char *buf, const char *what)
|
||||
{
|
||||
char *val = first_object_id_val(buf);
|
||||
if (val) {
|
||||
|
@ -391,7 +386,7 @@ static void show_progress(char *buf, char *what)
|
|||
#if UEMIS_DEBUG & 2
|
||||
fprintf(debugfile,"reading %s %s\n", what, val);
|
||||
#endif
|
||||
uemis_info(_("Reading %s %s"), what, val);
|
||||
uemis_info(tr("Reading %s %s"), what, val);
|
||||
free(val);
|
||||
}
|
||||
}
|
||||
|
@ -405,13 +400,13 @@ static void uemis_increased_timeout(int *timeout)
|
|||
|
||||
/* send a request to the dive computer and collect the answer */
|
||||
static bool uemis_get_answer(const char *path, char *request, int n_param_in,
|
||||
int n_param_out, char **error_text)
|
||||
int n_param_out, const char **error_text)
|
||||
{
|
||||
int i = 0, file_length;
|
||||
char sb[BUFLEN];
|
||||
char fl[13];
|
||||
char tmp[101];
|
||||
char *what = _("data");
|
||||
const char *what = tr("data");
|
||||
bool searching = TRUE;
|
||||
bool assembling_mbuf = FALSE;
|
||||
bool ismulti = FALSE;
|
||||
|
@ -432,11 +427,11 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
|
|||
answer_in_mbuf = TRUE;
|
||||
str_append_with_delim(sb, "");
|
||||
if (! strcmp(request, "getDivelogs"))
|
||||
what = _("divelog entry id");
|
||||
what = tr("divelog entry id");
|
||||
else if (!strcmp(request, "getDivespot"))
|
||||
what = _("divespot data id");
|
||||
what = tr("divespot data id");
|
||||
else if (!strcmp(request, "getDive"))
|
||||
what = _("more data dive id");
|
||||
what = tr("more data dive id");
|
||||
}
|
||||
str_append_with_delim(sb, "");
|
||||
file_length = strlen(sb);
|
||||
|
@ -446,11 +441,11 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
|
|||
fprintf(debugfile,"::w req.txt \"%s\"\n", sb);
|
||||
#endif
|
||||
if (write(reqtxt_file, sb, strlen(sb)) != strlen(sb)) {
|
||||
*error_text = _(ERR_FS_SHORT_WRITE);
|
||||
*error_text = tr(ERR_FS_SHORT_WRITE);
|
||||
return FALSE;
|
||||
}
|
||||
if (! next_file(number_of_files)) {
|
||||
*error_text = _(ERR_FS_FULL);
|
||||
*error_text = tr(ERR_FS_FULL);
|
||||
more_files = FALSE;
|
||||
}
|
||||
trigger_response(reqtxt_file, "n", filenr, file_length);
|
||||
|
@ -488,7 +483,7 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
|
|||
assembling_mbuf = FALSE;
|
||||
if (assembling_mbuf) {
|
||||
if (! next_file(number_of_files)) {
|
||||
*error_text = _(ERR_FS_FULL);
|
||||
*error_text = tr(ERR_FS_FULL);
|
||||
more_files = FALSE;
|
||||
assembling_mbuf = FALSE;
|
||||
}
|
||||
|
@ -497,7 +492,7 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
|
|||
}
|
||||
} else {
|
||||
if (! next_file(number_of_files - 1)) {
|
||||
*error_text = _(ERR_FS_FULL);
|
||||
*error_text = tr(ERR_FS_FULL);
|
||||
more_files = FALSE;
|
||||
assembling_mbuf = FALSE;
|
||||
searching = FALSE;
|
||||
|
@ -616,9 +611,9 @@ static void track_divespot(char *val, int diveid, char **location, degrees_t *la
|
|||
return;
|
||||
}
|
||||
|
||||
static char *suit[] = { "", N_("wetsuit"), N_("semidry"), N_("drysuit") };
|
||||
static char *suit_type[] = { "", N_("shorty"), N_("vest"), N_("long john"), N_("jacket"), N_("full suit"), N_("2 pcs full suit") };
|
||||
static char *suit_thickness[] = { "", "0.5-2mm", "2-3mm", "3-5mm", "5-7mm", "8mm+", N_("membrane") };
|
||||
static char *suit[] = { "", QT_TR_NOOP("wetsuit"), QT_TR_NOOP("semidry"), QT_TR_NOOP("drysuit") };
|
||||
static char *suit_type[] = { "", QT_TR_NOOP("shorty"), QT_TR_NOOP("vest"), QT_TR_NOOP("long john"), QT_TR_NOOP("jacket"), QT_TR_NOOP("full suit"), QT_TR_NOOP("2 pcs full suit") };
|
||||
static char *suit_thickness[] = { "", "0.5-2mm", "2-3mm", "3-5mm", "5-7mm", "8mm+", QT_TR_NOOP("membrane") };
|
||||
|
||||
static void parse_tag(struct dive *dive, char *tag, char *val)
|
||||
{
|
||||
|
@ -640,13 +635,13 @@ static void parse_tag(struct dive *dive, char *tag, char *val)
|
|||
uemis_add_string(val, &dive->notes);
|
||||
} else if (!strcmp(tag, "u8DiveSuit")) {
|
||||
if (*suit[atoi(val)])
|
||||
uemis_add_string(_(suit[atoi(val)]), &dive->suit);
|
||||
uemis_add_string(tr(suit[atoi(val)]), &dive->suit);
|
||||
} else if (!strcmp(tag, "u8DiveSuitType")) {
|
||||
if (*suit_type[atoi(val)])
|
||||
uemis_add_string(_(suit_type[atoi(val)]), &dive->suit);
|
||||
uemis_add_string(tr(suit_type[atoi(val)]), &dive->suit);
|
||||
} else if (!strcmp(tag, "u8SuitThickness")) {
|
||||
if (*suit_thickness[atoi(val)])
|
||||
uemis_add_string(_(suit_thickness[atoi(val)]), &dive->suit);
|
||||
uemis_add_string(tr(suit_thickness[atoi(val)]), &dive->suit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -782,22 +777,22 @@ static char *uemis_get_divenr(char *deviceidstr)
|
|||
return strdup(divenr);
|
||||
}
|
||||
|
||||
char *do_uemis_import(const char *mountpath, short force_download)
|
||||
const char *do_uemis_import(const char *mountpath, short force_download)
|
||||
{
|
||||
char *newmax = NULL;
|
||||
int start, end, i, offset;
|
||||
uint32_t deviceidnr;
|
||||
char objectid[10];
|
||||
char *deviceid = NULL;
|
||||
char *result = NULL;
|
||||
const char *result = NULL;
|
||||
char *endptr;
|
||||
bool success, keep_number = FALSE, once = TRUE;
|
||||
|
||||
if (dive_table.nr == 0)
|
||||
keep_number = TRUE;
|
||||
uemis_info(_("Init Communication"));
|
||||
uemis_info(tr("Init Communication"));
|
||||
if (! uemis_init(mountpath))
|
||||
return _("Uemis init failed");
|
||||
return tr("Uemis init failed");
|
||||
if (! uemis_get_answer(mountpath, "getDeviceId", 0, 1, &result))
|
||||
goto bail;
|
||||
deviceid = strdup(param_buff[0]);
|
||||
|
@ -808,7 +803,7 @@ char *do_uemis_import(const char *mountpath, short force_download)
|
|||
/* param_buff[0] is still valid */
|
||||
if (! uemis_get_answer(mountpath, "initSession", 1, 6, &result))
|
||||
goto bail;
|
||||
uemis_info(_("Start download"));
|
||||
uemis_info(tr("Start download"));
|
||||
if (! uemis_get_answer(mountpath, "processSync", 0, 2, &result))
|
||||
goto bail;
|
||||
/* before starting the long download, check if user pressed cancel */
|
||||
|
@ -844,7 +839,7 @@ char *do_uemis_import(const char *mountpath, short force_download)
|
|||
break;
|
||||
/* finally, if the memory is getting too full, maybe we better stop, too */
|
||||
if (progress_bar_fraction > 0.85) {
|
||||
result = _(ERR_FS_ALMOST_FULL);
|
||||
result = tr(ERR_FS_ALMOST_FULL);
|
||||
break;
|
||||
}
|
||||
/* clean up mbuf */
|
||||
|
@ -902,7 +897,7 @@ bail:
|
|||
(void) uemis_get_answer(mountpath, "terminateSync", 0, 3, &result);
|
||||
if (! strcmp(param_buff[0], "error")) {
|
||||
if (! strcmp(param_buff[2],"Out of Memory"))
|
||||
result = _(ERR_FS_FULL);
|
||||
result = tr(ERR_FS_FULL);
|
||||
else
|
||||
result = param_buff[2];
|
||||
}
|
||||
|
@ -959,7 +954,7 @@ GError *uemis_download(const char *mountpath, progressbar_t *progress,
|
|||
import_thread_cancelled = TRUE;
|
||||
} else {
|
||||
update_progressbar(args.progress, progress_bar_fraction);
|
||||
update_progressbar_text(args.progress, _("Cancelled, exiting cleanly..."));
|
||||
update_progressbar_text(args.progress, tr("Cancelled, exiting cleanly..."));
|
||||
usleep(100000);
|
||||
}
|
||||
}
|
||||
|
|
44
uemis.c
44
uemis.c
|
@ -12,12 +12,8 @@
|
|||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#if 0
|
||||
#include <glib/gi18n.h>
|
||||
#else
|
||||
#define _(arg) arg
|
||||
#define N_(arg) arg
|
||||
#endif
|
||||
|
||||
#include "gettext.h"
|
||||
#define __USE_XOPEN
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
@ -202,45 +198,45 @@ static void uemis_event(struct dive *dive, struct divecomputer *dc, struct sampl
|
|||
static int lastndl;
|
||||
|
||||
if (flags[1] & 0x01)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Safety Stop Violation"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Safety Stop Violation"));
|
||||
if (flags[1] & 0x08)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Speed Alarm"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Speed Alarm"));
|
||||
#if WANT_CRAZY_WARNINGS
|
||||
if (flags[1] & 0x06) /* both bits 1 and 2 are a warning */
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Speed Warning"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Speed Warning"));
|
||||
if (flags[1] & 0x10)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("PO2 Green Warning"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("PO2 Green Warning"));
|
||||
#endif
|
||||
if (flags[1] & 0x20)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("PO2 Ascend Warning"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("PO2 Ascend Warning"));
|
||||
if (flags[1] & 0x40)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("PO2 Ascend Alarm"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("PO2 Ascend Alarm"));
|
||||
/* flags[2] reflects the deco / time bar
|
||||
* flags[3] reflects more display details on deco and pO2 */
|
||||
if (flags[4] & 0x01)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Tank Pressure Info"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Tank Pressure Info"));
|
||||
if (flags[4] & 0x04)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("RGT Warning"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("RGT Warning"));
|
||||
if (flags[4] & 0x08)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("RGT Alert"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("RGT Alert"));
|
||||
if (flags[4] & 0x40)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Tank Change Suggested"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Tank Change Suggested"));
|
||||
if (flags[4] & 0x80)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Depth Limit Exceeded"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Depth Limit Exceeded"));
|
||||
if (flags[5] & 0x01)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Max Deco Time Warning"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Max Deco Time Warning"));
|
||||
if (flags[5] & 0x04)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Dive Time Info"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Dive Time Info"));
|
||||
if (flags[5] & 0x08)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Dive Time Alert"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Dive Time Alert"));
|
||||
if (flags[5] & 0x10)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Marker"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Marker"));
|
||||
if (flags[6] & 0x02)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("No Tank Data"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("No Tank Data"));
|
||||
if (flags[6] & 0x04)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Low Battery Warning"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Low Battery Warning"));
|
||||
if (flags[6] & 0x08)
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, N_("Low Battery Alert"));
|
||||
add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Low Battery Alert"));
|
||||
/* flags[7] reflects the little on screen icons that remind of previous
|
||||
* warnings / alerts - not useful for events */
|
||||
|
||||
|
|
Loading…
Reference in a new issue