Add translation markers to all messages except for the gds parser's messages

This commit is contained in:
Mario Hüttel 2019-12-12 21:22:14 +01:00
parent 87bc60bed0
commit de9066f181
9 changed files with 68 additions and 60 deletions

View File

@ -551,7 +551,7 @@ static void on_convert_clicked(gpointer button, gpointer user)
g_signal_connect(render_engine, "async-finished", G_CALLBACK(async_rendering_finished_callback),
self);
activity_bar_set_busy(self->activity_status_bar, "Rendering cell...");
activity_bar_set_busy(self->activity_status_bar, _("Rendering cell..."));
g_signal_connect(render_engine, "progress-changed",
G_CALLBACK(async_rendering_status_update_callback), self);

View File

@ -40,6 +40,7 @@
#include <stdbool.h>
#include <math.h>
#include <cairo.h>
#include <glib/gi18n.h>
#include <gds-render/gds-utils/gds-parser.h>

View File

@ -34,7 +34,7 @@
*/
#include <stdio.h>
#include <glib/gi18n.h>
#include <gds-render/gds-utils/gds-tree-checker.h>
int gds_tree_check_cell_references(struct gds_library *lib)
@ -54,7 +54,7 @@ int gds_tree_check_cell_references(struct gds_library *lib)
/* Check if this list element is broken. This should never happen */
if (!cell) {
fprintf(stderr, "Broken cell list item found. Will continue.\n");
fprintf(stderr, _("Broken cell list item found. Will continue.\n"));
continue;
}
@ -68,7 +68,7 @@ int gds_tree_check_cell_references(struct gds_library *lib)
/* Check if broken. This should not happen */
if (!cell_inst) {
fprintf(stderr, "Broken cell list item found in cell %s. Will continue.\n",
fprintf(stderr, _("Broken cell list item found in cell %s. Will continue.\n"),
cell->name);
continue;
}
@ -185,7 +185,7 @@ int gds_tree_check_reference_loops(struct gds_library *lib)
*/
if (res == 0)
fprintf(stderr,
"Visited cell list should be empty. This is a bug. Please report this.\n");
_("Visited cell list should be empty. This is a bug. Please report this.\n"));
g_list_free(visited_cells);
visited_cells = NULL;
}

View File

@ -31,6 +31,7 @@
#include <cairo.h>
#include <cairo-pdf.h>
#include <cairo-svg.h>
#include <glib/gi18n.h>
#include <gds-render/output-renderers/cairo-renderer.h>
#include <sys/wait.h>
@ -267,7 +268,7 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer
//process_id = -1;
if (process_id < 0) {
/* This should not happen */
fprintf(stderr, "Fatal error: Cairo Renderer: Could not spawn child process!");
fprintf(stderr, _("Fatal error: Cairo Renderer: Could not spawn child process!"));
exit(-2);
} else if (process_id > 0) {
/* Woohoo... Successfully dumped the shitty code to an unknowing victim */
@ -317,7 +318,7 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer
linfo = (struct layer_info *)info_list->data;
if (linfo->layer >= MAX_LAYERS) {
printf("Layer outside of Spec.\n");
printf(_("Layer number too high / outside of spec.\n"));
continue;
}
@ -327,7 +328,7 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer
/* Print size */
cairo_recording_surface_ink_extents(layers[linfo->layer].rec, &rec_x0, &rec_y0,
&rec_width, &rec_height);
dprintf(comm_pipe[1], "Size of layer %d%s%s%s: <%lf x %lf> @ (%lf | %lf)\n",
dprintf(comm_pipe[1], _("Size of layer %d%s%s%s: <%lf x %lf> @ (%lf | %lf)\n"),
linfo->layer,
(linfo->name && linfo->name[0] ? " (" : ""),
(linfo->name && linfo->name[0] ? linfo->name : ""),
@ -362,10 +363,10 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer
for (info_list = layer_infos; info_list != NULL; info_list = g_list_next(info_list)) {
linfo = (struct layer_info *)info_list->data;
dprintf(comm_pipe[1], "Exporting layer %d to file\n", linfo->layer);
dprintf(comm_pipe[1], _("Exporting layer %d to file\n"), linfo->layer);
if (linfo->layer >= MAX_LAYERS) {
printf("Layer outside of Spec.\n");
printf(_("Layer outside of spec.\n"));
continue;
}
@ -405,7 +406,7 @@ ret_clear_layers:
}
free(layers);
printf("Cairo export finished. It might still be buggy!\n");
printf(_("Cairo export finished. It might still be buggy!\n"));
/* Suspend child process */
exit(0);
@ -463,7 +464,7 @@ static int cairo_renderer_render_output(GdsOutputRenderer *renderer,
else
pdf_file = output_file;
gds_output_renderer_update_async_progress(renderer, "Rendering Cairo Output...");
gds_output_renderer_update_async_progress(renderer, _("Rendering Cairo Output..."));
ret = cairo_renderer_render_cell_to_vector_file(renderer, cell, layer_infos, pdf_file, svg_file, scale);
if (settings)

View File

@ -31,6 +31,7 @@
#include <dlfcn.h>
#include <stdio.h>
#include <sys/wait.h>
#include <glib/gi18n.h>
#include <gds-render/output-renderers/external-renderer.h>
#include <gds-render/version.h>
@ -74,7 +75,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
int forked_status;
if (!so_path) {
fprintf(stderr, "Path to shared object not set!\n");
fprintf(stderr, _("Path to shared object not set!\n"));
return -3000;
}
@ -85,7 +86,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
/* Load shared object */
so_handle = dlopen(so_path, RTLD_LAZY);
if (!so_handle) {
fprintf(stderr, "Could not load external library '%s'\nDetailed error is:\n%s\n", so_path, dlerror());
fprintf(stderr, _("Could not load external library '%s'\nDetailed error is:\n%s\n"), so_path, dlerror());
return -2000;
}
@ -94,7 +95,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
dlsym(so_handle, xstr(EXTERNAL_LIBRARY_RENDER_FUNCTION));
error_msg = dlerror();
if (error_msg != NULL) {
fprintf(stderr, "Rendering function not found in library:\n%s\n", error_msg);
fprintf(stderr, _("Rendering function not found in library:\n%s\n"), error_msg);
goto ret_close_so_handle;
}
@ -102,7 +103,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
so_init_func = (int (*)(const char *, const char *))dlsym(so_handle, xstr(EXTERNAL_LIBRARY_INIT_FUNCTION));
error_msg = dlerror();
if (error_msg != NULL) {
fprintf(stderr, "Rendering function not found in library:\n%s\n", error_msg);
fprintf(stderr, _("Init function not found in library:\n%s\n"), error_msg);
goto ret_close_so_handle;
}
@ -116,7 +117,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
/* Execute */
g_message("Calling external renderer.");
g_message(_("Calling external renderer."));
if (forking_req)
fork_pid = fork();
@ -138,7 +139,7 @@ end_forked:
ret = WEXITSTATUS(forked_status);
}
g_message("External renderer finished.");
g_message(_("External renderer finished."));
ret_close_so_handle:
dlclose(so_handle);
@ -246,15 +247,15 @@ static void external_renderer_class_init(ExternalRendererClass *klass)
/* Setup properties */
external_renderer_properties[PROP_SO_PATH] =
g_param_spec_string("shared-object-path",
"Shared object file path",
"Path to the shared object to search rendering function in.",
g_param_spec_string(N_("shared-object-path"),
N_("Shared object file path"),
N_("Path to the shared object to search rendering function in."),
NULL,
G_PARAM_READWRITE);
external_renderer_properties[PROP_PARAM_STRING] =
g_param_spec_string("param-string",
"Shared object renderer parameter string",
"Command line arguments passed to the external shared object renderer",
g_param_spec_string(N_("param-string"),
N_("Shared object renderer parameter string"),
N_("Command line arguments passed to the external shared object renderer"),
NULL,
G_PARAM_READWRITE);
g_object_class_install_properties(oclass, N_PROPERTIES, external_renderer_properties);
@ -273,8 +274,8 @@ ExternalRenderer *external_renderer_new()
ExternalRenderer *external_renderer_new_with_so_and_param(const char *so_path, const char *param_string)
{
return g_object_new(GDS_RENDER_TYPE_EXTERNAL_RENDERER, "shared-object-path", so_path,
"param-string", param_string,NULL);
return g_object_new(GDS_RENDER_TYPE_EXTERNAL_RENDERER, N_("shared-object-path"), so_path,
N_("param-string"), param_string, NULL);
}
/** @} */

View File

@ -28,6 +28,7 @@
*/
#include <gds-render/output-renderers/gds-output-renderer.h>
#include <glib/gi18n.h>
struct renderer_params {
struct gds_cell *cell;
@ -70,7 +71,7 @@ static int gds_output_renderer_render_dummy(GdsOutputRenderer *renderer,
(void)cell;
(void)scale;
g_warning("Output renderer does not define a render_output function!");
g_warning(_("Output renderer does not define a render_output function!"));
return 0;
}
@ -168,17 +169,17 @@ static void gds_output_renderer_class_init(GdsOutputRendererClass *klass)
/* Setup properties */
gds_output_renderer_properties[PROP_OUTPUT_FILE] =
g_param_spec_string("output-file", "output file", "Output file for renderer",
g_param_spec_string(N_("output-file"), N_("output file"), N_("Output file for renderer"),
NULL, G_PARAM_READWRITE);
gds_output_renderer_properties[PROP_LAYER_SETTINGS] =
g_param_spec_object("layer-settings", "Layer Settings object",
"Object containing the layer rendering information",
g_param_spec_object(N_("layer-settings"), N_("Layer Settings object"),
N_("Object containing the layer rendering information"),
GDS_RENDER_TYPE_LAYER_SETTINGS, G_PARAM_READWRITE);
g_object_class_install_properties(oclass, N_PROPERTIES, gds_output_renderer_properties);
/* Setup output signals */
gds_output_renderer_signals[ASYNC_FINISHED] =
g_signal_newv("async-finished", GDS_RENDER_TYPE_OUTPUT_RENDERER,
g_signal_newv(N_("async-finished"), GDS_RENDER_TYPE_OUTPUT_RENDERER,
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
NULL,
NULL,
@ -188,7 +189,7 @@ static void gds_output_renderer_class_init(GdsOutputRendererClass *klass)
0,
NULL);
gds_output_renderer_signals[ASYNC_PROGRESS_CHANGED] =
g_signal_newv("progress-changed", GDS_RENDER_TYPE_OUTPUT_RENDERER,
g_signal_newv(N_("progress-changed"), GDS_RENDER_TYPE_OUTPUT_RENDERER,
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
NULL,
NULL,
@ -223,8 +224,8 @@ GdsOutputRenderer *gds_output_renderer_new()
GdsOutputRenderer *gds_output_renderer_new_with_props(const char *output_file, LayerSettings *layer_settings)
{
return GDS_RENDER_OUTPUT_RENDERER(g_object_new(GDS_RENDER_TYPE_OUTPUT_RENDERER,
"layer-settings", layer_settings,
"output-file", output_file,
N_("layer-settings"), layer_settings,
N_("output-file"), output_file,
NULL));
}
@ -235,14 +236,14 @@ void gds_output_renderer_set_output_file(GdsOutputRenderer *renderer, const gcha
/* Check if the filename is actually filled */
if (!file_name || !file_name[0])
return;
g_object_set(renderer, "output-file", file_name, NULL);
g_object_set(renderer, N_("output-file"), file_name, NULL);
}
const char *gds_output_renderer_get_output_file(GdsOutputRenderer *renderer)
{
const char *file = NULL;
g_object_get(renderer, "output-file", &file, NULL);
g_object_get(renderer, N_("output-file"), &file, NULL);
return file;
}
@ -257,7 +258,7 @@ LayerSettings *gds_output_renderer_get_and_ref_layer_settings(GdsOutputRenderer
g_mutex_lock(&priv->settings_lock);
/* This function seems to already reference the LayerSettings object */
g_object_get(renderer, "layer-settings", &ret, NULL);
g_object_get(renderer, N_("layer-settings"), &ret, NULL);
/* It is now safe to clear the lock */
g_mutex_unlock(&priv->settings_lock);
@ -269,7 +270,7 @@ void gds_output_renderer_set_layer_settings(GdsOutputRenderer *renderer, LayerSe
{
g_return_if_fail(GDS_RENDER_IS_LAYER_SETTINGS(settings));
g_object_set(renderer, "layer-settings", settings, NULL);
g_object_set(renderer, N_("layer-settings"), settings, NULL);
}
int gds_output_renderer_render_output(GdsOutputRenderer *renderer, struct gds_cell *cell, double scale)
@ -279,28 +280,28 @@ int gds_output_renderer_render_output(GdsOutputRenderer *renderer, struct gds_ce
GdsOutputRendererPrivate *priv = gds_output_renderer_get_instance_private(renderer);
if (GDS_RENDER_IS_OUTPUT_RENDERER(renderer) == FALSE) {
g_error("Output Renderer not valid.");
g_error(_("Output Renderer not valid."));
return GDS_OUTPUT_RENDERER_GEN_ERR;
}
if (!priv->output_file || !priv->output_file[0]) {
g_error("No/invalid output file set.");
g_error(_("No/invalid output file set."));
return GDS_OUTPUT_RENDERER_GEN_ERR;
}
if (!priv->layer_settings) {
g_error("No layer specification supplied.");
g_error(_("No layer specification supplied."));
return GDS_OUTPUT_RENDERER_GEN_ERR;
}
if (!cell) {
g_error("Output renderer called without cell to render.");
g_error(_("Output renderer called without cell to render."));
return GDS_OUTPUT_RENDERER_PARAM_ERR;
}
klass = GDS_RENDER_OUTPUT_RENDERER_GET_CLASS(renderer);
if (klass->render_output == NULL) {
g_critical("Output Renderer: Rendering function broken. This is a bug.");
g_critical(_("Output Renderer: Rendering function broken. This is a bug."));
return GDS_OUTPUT_RENDERER_GEN_ERR;
}
@ -361,7 +362,7 @@ int gds_output_renderer_render_output_async(GdsOutputRenderer *renderer, struct
priv = gds_output_renderer_get_instance_private(renderer);
if (priv->task) {
g_warning("renderer already started asynchronously");
g_warning(_("Renderer already started asynchronously"));
return -2000;
}

View File

@ -27,6 +27,8 @@
#include <stdio.h>
#include <gds-render/output-renderers/latex-renderer.h>
#include <gdk/gdk.h>
#include <glib/gi18n.h>
/**
* @addtogroup LaTeX-Renderer
* @{
@ -248,7 +250,7 @@ static void render_cell(struct gds_cell *cell, GList *layer_infos, FILE *tex_fil
struct gds_cell_instance *inst;
status = g_string_new(NULL);
g_string_printf(status, "Generating cell %s", cell->name);
g_string_printf(status, _("Generating cell %s"), cell->name);
gds_output_renderer_update_async_progress(renderer, status->str);
g_string_free(status, TRUE);
@ -368,7 +370,7 @@ static int latex_renderer_render_output(GdsOutputRenderer *renderer,
l_renderer->pdf_layers, l_renderer->tex_standalone, renderer);
fclose(tex_file);
} else {
g_error("Could not open LaTeX output file");
g_error(_("Could not open LaTeX output file"));
}
if (settings)
@ -433,14 +435,14 @@ static void latex_renderer_class_init(LatexRendererClass *klass)
latex_renderer_properties[PROP_STANDALONE] =
g_param_spec_boolean("standalone",
"Standalone TeX file",
"Generate a standalone LaTeX file.",
N_("Standalone TeX file"),
N_("Generate a standalone LaTeX file."),
FALSE,
G_PARAM_READWRITE);
latex_renderer_properties[PROP_PDF_LAYERS] =
g_param_spec_boolean("pdf-layers",
"PDF OCR layers",
"Generate OCR layers",
N_("PDF OCR layers"),
N_("Generate OCR layers"),
FALSE,
G_PARAM_READWRITE);

View File

@ -30,6 +30,7 @@
*/
#include <gds-render/widgets/conv-settings-dialog.h>
#include <glib/gi18n.h>
struct _RendererSettingsDialog {
GtkDialog parent;
@ -102,9 +103,9 @@ static void renderer_settings_dialog_class_init(RendererSettingsDialogClass *kla
oclass->set_property = renderer_settings_dialog_set_property;
oclass->get_property = renderer_settings_dialog_get_property;
properties[PROP_CELL_NAME] = g_param_spec_string("cell-name",
"cell-name",
"Cell name to be displayed in header bar",
properties[PROP_CELL_NAME] = g_param_spec_string(N_("cell-name"),
N_("cell-name"),
N_("Cell name to be displayed in header bar"),
"",
G_PARAM_READWRITE);
g_object_class_install_properties(oclass, PROP_COUNT, properties);
@ -240,18 +241,18 @@ static void renderer_settings_dialog_update_labels(RendererSettingsDialog *self)
width_engineering = convert_number_to_engineering(width_meters, &width_prefix);
height_engineering = convert_number_to_engineering(height_meters, &height_prefix);
snprintf(default_buff, sizeof(default_buff), "Width: %.3lf %sm", width_engineering, width_prefix);
snprintf(default_buff, sizeof(default_buff), _("Width: %.3lf %sm"), width_engineering, width_prefix);
gtk_label_set_text(self->x_label, default_buff);
snprintf(default_buff, sizeof(default_buff), "Height: %.3lf %sm", height_engineering, height_prefix);
snprintf(default_buff, sizeof(default_buff), _("Height: %.3lf %sm"), height_engineering, height_prefix);
gtk_label_set_text(self->y_label, default_buff);
scale = gtk_range_get_value(GTK_RANGE(self->scale));
/* Set the pixel sizes */
snprintf(default_buff, sizeof(default_buff), "Output Width: %u px",
snprintf(default_buff, sizeof(default_buff), _("Output Width: %u px"),
(unsigned int)((double)self->cell_width / scale));
gtk_label_set_text(self->x_output_label, default_buff);
snprintf(default_buff, sizeof(default_buff), "Output Height: %u px",
snprintf(default_buff, sizeof(default_buff), _("Output Height: %u px"),
(unsigned int)((double)self->cell_height / scale));
gtk_label_set_text(self->y_output_label, default_buff);
}
@ -287,9 +288,9 @@ static void renderer_settings_dialog_init(RendererSettingsDialog *self)
self->x_output_label = GTK_LABEL(gtk_builder_get_object(builder, "x-output-label"));
self->y_output_label = GTK_LABEL(gtk_builder_get_object(builder, "y-output-label"));
gtk_dialog_add_buttons(dialog, "Cancel", GTK_RESPONSE_CANCEL, "OK", GTK_RESPONSE_OK, NULL);
gtk_dialog_add_buttons(dialog, _("Cancel"), GTK_RESPONSE_CANCEL, _("OK"), GTK_RESPONSE_OK, NULL);
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(dialog)), box);
gtk_window_set_title(GTK_WINDOW(self), "Renderer Settings");
gtk_window_set_title(GTK_WINDOW(self), _("Renderer Settings"));
g_signal_connect(self->radio_latex, "toggled", G_CALLBACK(latex_render_callback), (gpointer)self);
g_signal_connect(G_OBJECT(self->shape_drawing),

View File

@ -37,6 +37,7 @@
*/
#include <gds-render/widgets/layer-element.h>
#include <glib/gi18n.h>
G_DEFINE_TYPE(LayerElement, layer_element, GTK_TYPE_LIST_BOX_ROW)
@ -98,7 +99,7 @@ void layer_element_set_layer(LayerElement *elem, int layer)
GString *string;
string = g_string_new_len(NULL, 100);
g_string_printf(string, "Layer: %d", layer);
g_string_printf(string, _("Layer: %d"), layer);
gtk_label_set_text(elem->priv.layer, (const gchar *)string->str);
elem->priv.layer_num = layer;
g_string_free(string, TRUE);