VitaShell/language.c

166 lines
4.3 KiB
C
Raw Normal View History

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"
#include "config.h"
2016-08-06 06:59:41 +00:00
#include "language.h"
INCLUDE_EXTERN_RESOURCE(english_us_txt);
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",
"turkish"
2016-08-06 06:59:41 +00:00
};
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;
}
}
}
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-09-08 18:37:03 +00:00
ConfigEntry language_entries[] = {
// General strings
LANGUAGE_ENTRY(ERROR),
LANGUAGE_ENTRY(OK),
LANGUAGE_ENTRY(YES),
LANGUAGE_ENTRY(NO),
LANGUAGE_ENTRY(CANCEL),
2016-09-07 19:56:40 +00:00
LANGUAGE_ENTRY(FOLDER),
LANGUAGE_ENTRY(OFFSET),
2016-09-08 18:37:03 +00:00
// Progress strings
LANGUAGE_ENTRY(MOVING),
LANGUAGE_ENTRY(COPYING),
LANGUAGE_ENTRY(DELETING),
2016-09-14 09:33:52 +00:00
LANGUAGE_ENTRY(EXPORTING),
2016-09-08 18:37:03 +00:00
LANGUAGE_ENTRY(INSTALLING),
LANGUAGE_ENTRY(DOWNLOADING),
LANGUAGE_ENTRY(EXTRACTING),
2016-10-15 13:03:26 +00:00
LANGUAGE_ENTRY(COMPRESSING),
2016-09-08 18:37:03 +00:00
LANGUAGE_ENTRY(HASHING),
// Audio player strings
LANGUAGE_ENTRY(TITLE),
LANGUAGE_ENTRY(ALBUM),
LANGUAGE_ENTRY(ARTIST),
LANGUAGE_ENTRY(GENRE),
LANGUAGE_ENTRY(YEAR),
2016-09-08 18:37:03 +00:00
// Hex editor strings
LANGUAGE_ENTRY(CUT),
LANGUAGE_ENTRY(OPEN_HEX_EDITOR),
// Text editor strings
2016-09-07 19:56:40 +00:00
LANGUAGE_ENTRY(EDIT_LINE),
2016-09-08 18:49:26 +00:00
LANGUAGE_ENTRY(ENTER_SEARCH_TERM),
2016-09-08 18:37:03 +00:00
LANGUAGE_ENTRY(CUT),
2016-09-10 11:01:07 +00:00
LANGUAGE_ENTRY(INSERT_EMPTY_LINE),
2016-09-08 18:37:03 +00:00
// File browser context menu strings
LANGUAGE_ENTRY(MORE),
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),
2016-10-15 13:03:26 +00:00
LANGUAGE_ENTRY(COMPRESS),
2016-09-07 19:56:40 +00:00
LANGUAGE_ENTRY(INSTALL_ALL),
LANGUAGE_ENTRY(INSTALL_FOLDER),
2016-09-07 19:56:40 +00:00
LANGUAGE_ENTRY(CALCULATE_SHA1),
2016-09-14 09:33:52 +00:00
LANGUAGE_ENTRY(EXPORT_MEDIA),
2016-09-08 18:49:26 +00:00
LANGUAGE_ENTRY(SEARCH),
2016-09-08 18:37:03 +00:00
// File browser strings
LANGUAGE_ENTRY(COPIED_FILE),
LANGUAGE_ENTRY(COPIED_FOLDER),
LANGUAGE_ENTRY(COPIED_FILES_FOLDERS),
2016-09-08 18:37:03 +00:00
// Dialog questions
LANGUAGE_ENTRY(DELETE_FILE_QUESTION),
LANGUAGE_ENTRY(DELETE_FOLDER_QUESTION),
LANGUAGE_ENTRY(DELETE_FILES_FOLDERS_QUESTION),
2016-09-14 09:33:52 +00:00
LANGUAGE_ENTRY(EXPORT_FILE_QUESTION),
LANGUAGE_ENTRY(EXPORT_FOLDER_QUESTION),
LANGUAGE_ENTRY(EXPORT_FILES_FOLDERS_QUESTION),
2016-09-14 09:45:46 +00:00
LANGUAGE_ENTRY(EXPORT_NO_MEDIA),
LANGUAGE_ENTRY(EXPORT_SONGS_INFO),
LANGUAGE_ENTRY(EXPORT_PICTURES_INFO),
LANGUAGE_ENTRY(EXPORT_SONGS_PICTURES_INFO),
2016-09-04 13:12:31 +00:00
LANGUAGE_ENTRY(INSTALL_ALL_QUESTION),
LANGUAGE_ENTRY(INSTALL_FOLDER_QUESTION),
LANGUAGE_ENTRY(INSTALL_QUESTION),
2016-08-27 17:16:39 +00:00
LANGUAGE_ENTRY(INSTALL_WARNING),
2016-09-07 19:56:40 +00:00
LANGUAGE_ENTRY(HASH_FILE_QUESTION),
2016-09-08 18:37:03 +00:00
// Others
LANGUAGE_ENTRY(TOOLBOX),
LANGUAGE_ENTRY(SYSINFO_TITLE),
2016-09-13 21:09:47 +00:00
LANGUAGE_ENTRY(PLEASE_WAIT),
2016-08-27 17:26:00 +00:00
LANGUAGE_ENTRY(SAVE_MODIFICATIONS),
2016-09-12 20:34:03 +00:00
LANGUAGE_ENTRY(NO_SPACE_ERROR),
LANGUAGE_ENTRY(WIFI_ERROR),
LANGUAGE_ENTRY(FTP_SERVER),
LANGUAGE_ENTRY(SYS_INFO),
2016-09-04 09:19:11 +00:00
LANGUAGE_ENTRY(UPDATE_QUESTION),
2016-10-27 16:38:21 +00:00
LANGUAGE_ENTRY(ARCHIVE_NAME),
LANGUAGE_ENTRY(COMPRESSION_LEVEL),
};
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-09-04 12:29:21 +00:00
}