Start of i18n support.

This commit is contained in:
Steve 2016-02-27 18:13:05 +00:00
parent 660bb57bb0
commit 821e7ac872
5 changed files with 20 additions and 1 deletions

View File

@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DATA_DIR ""
#endif
#define _(string) getTranslatedString(string)
#define PI 3.14159265358979323846
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

View File

@ -156,6 +156,7 @@ static void handleArguments(int argc, char *argv[])
{
int i;
int testingMission = 0;
int languageId = -1;
for (i = 1 ; i < argc ; i++)
{
@ -172,9 +173,23 @@ static void handleArguments(int argc, char *argv[])
{
dev.debug = 1;
}
if (strcmp(argv[i], "-language") == 0)
{
languageId = i + 1;
if (languageId >= argc)
{
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "You must specify a language to use with -language. Using default.\n");
}
}
}
}
setLanguage("tbftss", languageId == -1 ? NULL : argv[languageId]);
printf("Numeric is %s\n", setlocale(LC_NUMERIC, "C"));
printf("atof(2.75) is %f\n", atof("2.75"));
if (!testingMission)
{
if (fileExists(getSaveFilePath("game.save")))

View File

@ -44,6 +44,7 @@ extern void drawModalDialog(void);
extern void loadGame(void);
extern int fileExists(char *filename);
extern char *getSaveFilePath(char *filename);
extern void setLanguage(char *applicationName, char *languageCode);
App app;
Colors colors;

View File

@ -301,7 +301,7 @@ static void loadWidgetSet(char *filename)
switch (w->type)
{
case WT_BUTTON:
STRNCPY(w->text, cJSON_GetObjectItem(node, "text")->valuestring, MAX_NAME_LENGTH);
STRNCPY(w->text, _((cJSON_GetObjectItem(node, "text")->valuestring)), MAX_NAME_LENGTH);
w->rect.w = cJSON_GetObjectItem(node, "w")->valueint;
w->rect.h = cJSON_GetObjectItem(node, "h")->valueint;
w->rect.x -= w->rect.w / 2;

View File

@ -32,6 +32,7 @@ extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int
extern void playSound(int id);
extern char *getFileLocation(char *filename);
extern char **getFileList(char *dir, int *count);
extern char *getTranslatedString(char *string);
extern App app;
extern Colors colors;