1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-12-07 00:56:34 +01:00

Add localization system (gettext)

This commit is contained in:
Ansa89
2015-05-25 16:38:52 +02:00
committed by cnhenry
parent a455c80a1f
commit 0a2ad23c15
36 changed files with 5493 additions and 395 deletions

View File

@@ -24,6 +24,12 @@
#include <string.h>
#include <assert.h>
#ifdef NO_GETTEXT
#define gettext(A) (A)
#else
#include <libintl.h>
#endif
#include "toxic.h"
#include "windows.h"
#include "execute.h"
@@ -98,7 +104,7 @@ static int parse_command(WINDOW *w, ToxWindow *self, const char *input, char (*a
char *cmd = strdup(input);
if (cmd == NULL)
exit_toxic_err("failed in parse_command", FATALERR_MEMORY);
exit_toxic_err(gettext("failed in parse_command"), FATALERR_MEMORY);
int num_args = 0;
int i = 0; /* index of last char in an argument */
@@ -112,7 +118,7 @@ static int parse_command(WINDOW *w, ToxWindow *self, const char *input, char (*a
i = char_find(1, cmd, '\"');
if (cmd[i] == '\0') {
const char *errmsg = "Invalid argument. Did you forget a closing \"?";
const char *errmsg = gettext("Invalid argument. Did you forget a closing \"?");
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
free(cmd);
return -1;
@@ -183,5 +189,5 @@ void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode)
if (do_command(w, self, m, num_args, global_commands, args) == 0)
return;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid command.");
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, gettext("Invalid command."));
}