2016-08-06 06:59:41 +00:00
|
|
|
/*
|
|
|
|
VitaShell
|
|
|
|
Copyright (C) 2015-2016, TheFloW
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "main.h"
|
2016-08-26 21:57:51 +00:00
|
|
|
#include "config.h"
|
2016-08-06 06:59:41 +00:00
|
|
|
#include "language.h"
|
|
|
|
|
2016-08-26 21:57:51 +00:00
|
|
|
extern unsigned char _binary_resources_english_us_txt_start;
|
|
|
|
extern unsigned char _binary_resources_english_us_txt_size;
|
2016-08-06 06:59:41 +00:00
|
|
|
|
|
|
|
static char *lang[] ={
|
|
|
|
"japanese",
|
|
|
|
"english_us",
|
|
|
|
"french",
|
|
|
|
"spanish",
|
|
|
|
"german",
|
|
|
|
"italian",
|
|
|
|
"dutch",
|
|
|
|
"portuguese",
|
|
|
|
"russian",
|
|
|
|
"korean",
|
|
|
|
"chinese_t",
|
|
|
|
"chinese_s",
|
|
|
|
"finnish",
|
|
|
|
"swedish",
|
|
|
|
"danish",
|
|
|
|
"norwegian",
|
|
|
|
"polish",
|
|
|
|
"portuguese_br",
|
|
|
|
"english_gb"
|
|
|
|
};
|
|
|
|
|
|
|
|
char *language_container[LANGUAGE_CONTRAINER_SIZE];
|
|
|
|
|
|
|
|
void freeLanguageContainer() {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < LANGUAGE_CONTRAINER_SIZE; i++) {
|
|
|
|
if (language_container[i]) {
|
|
|
|
free(language_container[i]);
|
|
|
|
language_container[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 21:57:51 +00:00
|
|
|
void loadLanguage(int id) {
|
2016-08-06 06:59:41 +00:00
|
|
|
freeLanguageContainer();
|
|
|
|
|
2016-08-27 10:49:03 +00:00
|
|
|
#define LANGUAGE_ENTRY(name) { #name, CONFIG_TYPE_STRING, (void *)&language_container[name] }
|
2016-08-26 21:57:51 +00:00
|
|
|
ConfigEntry language_entries[] = {
|
|
|
|
LANGUAGE_ENTRY(ERROR),
|
|
|
|
LANGUAGE_ENTRY(OK),
|
|
|
|
LANGUAGE_ENTRY(YES),
|
|
|
|
LANGUAGE_ENTRY(NO),
|
|
|
|
LANGUAGE_ENTRY(CANCEL),
|
|
|
|
LANGUAGE_ENTRY(OFFSET),
|
|
|
|
LANGUAGE_ENTRY(MARK_ALL),
|
|
|
|
LANGUAGE_ENTRY(UNMARK_ALL),
|
|
|
|
LANGUAGE_ENTRY(MOVE),
|
|
|
|
LANGUAGE_ENTRY(COPY),
|
|
|
|
LANGUAGE_ENTRY(PASTE),
|
|
|
|
LANGUAGE_ENTRY(DELETE),
|
|
|
|
LANGUAGE_ENTRY(RENAME),
|
|
|
|
LANGUAGE_ENTRY(NEW_FOLDER),
|
|
|
|
LANGUAGE_ENTRY(FOLDER),
|
|
|
|
LANGUAGE_ENTRY(COPIED_FILE),
|
|
|
|
LANGUAGE_ENTRY(COPIED_FOLDER),
|
|
|
|
LANGUAGE_ENTRY(COPIED_FILES_FOLDERS),
|
|
|
|
LANGUAGE_ENTRY(MOVING),
|
|
|
|
LANGUAGE_ENTRY(COPYING),
|
|
|
|
LANGUAGE_ENTRY(DELETING),
|
|
|
|
LANGUAGE_ENTRY(INSTALLING),
|
|
|
|
LANGUAGE_ENTRY(DELETE_FILE_QUESTION),
|
|
|
|
LANGUAGE_ENTRY(DELETE_FOLDER_QUESTION),
|
|
|
|
LANGUAGE_ENTRY(DELETE_FILES_FOLDERS_QUESTION),
|
|
|
|
LANGUAGE_ENTRY(INSTALL_QUESTION),
|
2016-08-27 17:16:39 +00:00
|
|
|
LANGUAGE_ENTRY(INSTALL_WARNING),
|
2016-08-27 17:26:00 +00:00
|
|
|
LANGUAGE_ENTRY(SAVE_MODIFICATIONS),
|
2016-08-26 21:57:51 +00:00
|
|
|
LANGUAGE_ENTRY(WIFI_ERROR),
|
|
|
|
LANGUAGE_ENTRY(FTP_SERVER),
|
|
|
|
};
|
|
|
|
|
2016-08-27 17:16:39 +00:00
|
|
|
// Load default config file
|
|
|
|
readConfigBuffer(&_binary_resources_english_us_txt_start, (int)&_binary_resources_english_us_txt_size, language_entries, sizeof(language_entries) / sizeof(ConfigEntry));
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2016-08-27 17:16:39 +00:00
|
|
|
// Load custom config file
|
2016-08-27 10:49:03 +00:00
|
|
|
if (use_custom_config) {
|
|
|
|
if (id >= 0 && id < (sizeof(lang) / sizeof(char *))) {
|
|
|
|
char path[128];
|
|
|
|
sprintf(path, "ux0:VitaShell/language/%s.txt", lang[id]);
|
2016-08-27 17:16:39 +00:00
|
|
|
readConfig(path, language_entries, sizeof(language_entries) / sizeof(ConfigEntry));
|
2016-08-27 10:49:03 +00:00
|
|
|
}
|
2016-08-06 06:59:41 +00:00
|
|
|
}
|
2016-08-26 21:57:51 +00:00
|
|
|
}
|