We only need to use strtok here.
This commit is contained in:
parent
7633322d1e
commit
5b6dfecebb
|
@ -41,7 +41,6 @@ extern long lookup(const char *name);
|
||||||
extern float mod(float n, float x);
|
extern float mod(float n, float x);
|
||||||
extern void playSound(int snd, int ch);
|
extern void playSound(int snd, int ch);
|
||||||
extern char *readFile(const char *filename);
|
extern char *readFile(const char *filename);
|
||||||
extern void saveScreenshot(char *name);
|
|
||||||
extern void textSize(char *text, int size, int *w, int *h);
|
extern void textSize(char *text, int size, int *w, int *h);
|
||||||
extern char *timeToDate(long millis);
|
extern char *timeToDate(long millis);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ void setLanguage(char *applicationName, char *languageCode)
|
||||||
{
|
{
|
||||||
char language[MAX_LINE_LENGTH], c[MAX_LINE_LENGTH];
|
char language[MAX_LINE_LENGTH], c[MAX_LINE_LENGTH];
|
||||||
char *lang, **key, **value;
|
char *lang, **key, **value;
|
||||||
int i, swap, length;
|
int i, swap;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
MOHeader header;
|
MOHeader header;
|
||||||
MOEntry *original, *translation;
|
MOEntry *original, *translation;
|
||||||
|
@ -75,16 +75,7 @@ void setLanguage(char *applicationName, char *languageCode)
|
||||||
STRNCPY(language, languageCode, MAX_LINE_LENGTH);
|
STRNCPY(language, languageCode, MAX_LINE_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
length = strlen(language);
|
strtok(language, ".");
|
||||||
|
|
||||||
for (i=0 ; i < length ; i++)
|
|
||||||
{
|
|
||||||
if (language[i] == '.')
|
|
||||||
{
|
|
||||||
language[i] = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Locale is %s", language);
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Locale is %s", language);
|
||||||
|
|
||||||
|
@ -107,17 +98,9 @@ void setLanguage(char *applicationName, char *languageCode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = strlen(language);
|
strtok(language, "_");
|
||||||
|
|
||||||
for (i=0;i<length;i++)
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Language is %s", language);
|
||||||
{
|
|
||||||
if (language[i] == '_')
|
|
||||||
{
|
|
||||||
language[i] = '\0';
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(c, "%s/%s/LC_MESSAGES/%s.mo", LOCALE_DIR, language, applicationName);
|
sprintf(c, "%s/%s/LC_MESSAGES/%s.mo", LOCALE_DIR, language, applicationName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue