Make languages json files

This commit is contained in:
Xpl0itU 2022-08-24 18:02:20 +02:00
parent 31cc690610
commit 84870c98cf
15 changed files with 340 additions and 1769 deletions

View File

@ -21,7 +21,7 @@ include $(DEVKITPRO)/wut/share/wut_rules
#-------------------------------------------------------------------------------
TARGET := savemii
BUILD := build
SOURCES := src src/fs src/language src/utils
SOURCES := src
DATA :=
INCLUDES := include
DEFS :=
@ -67,7 +67,6 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
export DEPSDIR := $(CURDIR)/$(BUILD)
LANGUAGES := $(shell bash ./updatelang.sh)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
@ -98,7 +97,7 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
-I$(CURDIR)/$(BUILD) \
-I/opt/devkitpro/portlibs/ppc/include/freetype2/
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) -L$(CURDIR)/libfat/lib
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: $(BUILD) clean all

View File

@ -1,58 +0,0 @@
#pragma once
#include <stdio.h>
#include <string>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <wut_types.h>
class CFile {
public:
enum eOpenTypes {
ReadOnly,
WriteOnly,
ReadWrite,
Append
};
CFile();
CFile(const std::string & filepath, eOpenTypes mode);
CFile(const uint8_t * memory, int32_t memsize);
virtual ~CFile();
int32_t open(const std::string & filepath, eOpenTypes mode);
int32_t open(const uint8_t * memory, int32_t memsize);
BOOL isOpen() const {
if(iFd >= 0)
return true;
if(mem_file)
return true;
return false;
}
void close();
int32_t read(uint8_t * ptr, size_t size);
int32_t write(const uint8_t * ptr, size_t size);
int32_t fwrite(const char *format, ...);
int32_t seek(long int offset, int32_t origin);
uint64_t tell() {
return pos;
};
uint64_t size() {
return filesize;
};
void rewind() {
this->seek(0, SEEK_SET);
};
protected:
int32_t iFd;
const uint8_t * mem_file;
uint64_t filesize;
uint64_t pos;
};

View File

@ -23,18 +23,9 @@ extern "C"
{
#endif
#define tr(s) gettext(s)
#define trNOOP(s) s
BOOL gettextLoadLanguage(const char* langFile);
void gettextCleanUp(void);
/*
* input msg = a text in ASCII
* output = the translated msg in utf-8
*/
const char *gettext(const char *msg) __attribute__((hot));
#define tr(s) gettext(s)
#define trNOOP(s) s
bool gettextLoadLanguage(const char* langFile);
void gettextCleanUp() __attribute__((__cold__));
const char *gettext(const char *msg) __attribute__((__hot__));
#ifdef __cplusplus
}

View File

@ -1,6 +1,6 @@
#pragma once
#include <language/gettext.h>
#include "gettext.h"
#include <romfs-wiiu.h>
#include <coreinit/memdefaultheap.h>

View File

@ -1,79 +0,0 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#pragma once
#include <vector>
#include <string>
#include <wut_types.h>
class StringTools{
public:
static BOOL EndsWith(const std::string& a, const std::string& b);
static const char * byte_to_binary(int32_t x);
static std::string removeCharFromString(std::string& input,char toBeRemoved);
static const char * fmt(const char * format, ...);
static const wchar_t * wfmt(const char * format, ...);
static int32_t strprintf(std::string &str, const char * format, ...);
static std::string strfmt(const char * format, ...);
static BOOL char2wchar_t(const char * src, wchar_t * dest);
static int32_t strtokcmp(const char * string, const char * compare, const char * separator);
static int32_t strextcmp(const char * string, const char * extension, char seperator);
static const char * FullpathToFilename(const char *path){
if(!path) return path;
const char * ptr = path;
const char * Filename = ptr;
while(*ptr != '\0')
{
if(ptr[0] == '/' && ptr[1] != '\0')
Filename = ptr+1;
++ptr;
}
return Filename;
}
static void RemoveDoubleSlashs(std::string &str){
uint32_t length = str.size();
//! clear path of double slashes
for(uint32_t i = 1; i < length; ++i)
{
if(str[i-1] == '/' && str[i] == '/')
{
str.erase(i, 1);
i--;
length--;
}
}
}
static std::vector<std::string> stringSplit(const std::string & value, const std::string & splitter);
};

98
languages/english.json Normal file
View File

@ -0,0 +1,98 @@
{
"Disclaimer:": "",
"There is always the potential for a brick.": "",
"Everything you do with this software is your own responsibility": "",
"Out of memory.": "",
"Loaded %i Wii U titles.": "",
"%s%s (No banner.bin)": "",
"Loaded %i Wii titles.": "",
"None": "",
"Name": "",
"Storage": "",
"Storage+Name": "",
"initFS failed. Please make sure your MochaPayload is up-to-date": "",
" Wii U Save Management (%u Title%s)": "",
" vWii Save Management (%u Title%s)": "",
" Batch Backup": "",
"\ue000: Select Mode": "",
" Backup All (%u Title%s)": "",
" Backup Wii U (%u Title%s)": "",
" Backup vWii (%u Title%s)": "",
"\ue000: Backup \ue001: Back": "",
"%s Sort: %s \ue084": "",
" [Not Init]": "",
"\ue000: Select Game \ue001: Back": "",
" Backup savedata": "",
" Restore savedata": "",
" Wipe savedata": "",
" Import from loadiine": "",
" Export to loadiine": "",
" Copy Savedata to Title in %s": "",
"\ue000: Select Task \ue001: Back": "",
"Destination:": "",
"Select %s:": "",
"version": "",
"Delete from:": "",
"slot": "",
"Empty": "",
"Used": "",
"Select SD user to copy from:": "",
"all users": "",
"Has Save": "",
"Select Wii U user to delete from:": "",
"Select Wii U user%s:": "",
" to copy from": "",
" to copy to": "",
"Date: %s": "",
"Include 'common' save?": "",
"yes": "",
"no ": "",
"No 'common' save found.": "",
"\ue000: Restore \ue001: Back": "",
"\ue000: Wipe \ue001: Back": "",
"\ue000: Import \ue001: Back": "",
"\ue000: Export \ue001: Back": "",
"\ue000: Copy \ue001: Back": "",
"Press \ue044 to exit.": "",
"No Wii U titles found.": "",
"No vWii saves found.": "",
"CBHC save. Could be dangerous to modify. Continue?": "",
"Are you REALLY sure?": "",
"vWii saves are in the vWii section. Continue?": "",
"Recommended to run Game at least one time. Continue?": "",
"No save to Backup.": "",
"No save to Wipe.": "",
"No save to Export.": "",
"No save to Copy.": "",
"Copying file: %s": "",
"From: %s": "",
"To: %s": "",
"\ue000 Yes - \ue001 No": "",
"\ue000 Confirm - \ue001 Cancel": "",
"Filesize: %d bytes": "",
"Deleting folder %s": "",
"From: \n%s": "",
"Failed to delete folder %s\n%s": "",
"Deleting file %s": "",
"Failed to delete file %s\n%s": "",
"Loadiine game folder not found.": "",
"Failed to open Loadiine game save directory.": "",
"Are you sure?": "",
"Backup current savedata first to next empty slot?": "",
"Backup done. Now copying Savedata.": "",
"Common save not found.": "",
"Copy failed.": "",
"Backup failed.": "",
"Backup found on this slot. Overwrite it?": "",
"No save found for this user.": "",
"Backup failed. DO NOT restore from this slot.": "",
"No backup found on selected slot.": "",
"Restore failed.": "",
"Hm, are you REALLY sure?": "",
"Backup current savedata first?": "",
"Failed to delete common folder.\n%s": "",
"Failed to delete savefile.": "",
"Failed to delete user folder.\n%s": "",
"Failed to import savedata from loadiine.": "",
"Failed to export savedata to loadiine.": ""
}

View File

@ -1,463 +0,0 @@
msgid "Press \\ue044 to exit."
msgstr ""
msgid "\\ue000: Copy \\ue001: Back"
msgstr ""
msgid "\\ue000: Export \\ue001: Back"
msgstr ""
msgid "\\ue000: Import \\ue001: Back"
msgstr ""
msgid "\\ue000: Wipe \\ue001: Back"
msgstr ""
msgid "\\ue000: Restore \\ue001: Back"
msgstr ""
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"Language-Team: English\n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid "\\ue000: Backup \\ue001: Back"
msgstr ""
msgid "\\ue000: Select Game \\ue001: Back"
msgstr ""
msgid "\\ue000: Select Task \\ue001: Back"
msgstr ""
msgid "\\ue000 Yes - \\ue001 No"
msgstr ""
msgid "\\ue000 Confirm - \\ue001 Cancel"
msgstr ""
#: src/main.cpp:63
msgid "Disclaimer:"
msgstr ""
#: src/main.cpp:64
msgid "There is always the potential for a brick."
msgstr ""
#: src/main.cpp:65
msgid "Everything you do with this software is your own responsibility"
msgstr ""
#: src/main.cpp:90 src/main.cpp:145 src/main.cpp:186 src/main.cpp:297
msgid "Out of memory."
msgstr ""
#: src/main.cpp:245 src/main.cpp:391
#, c-format
msgid "Loaded %i Wii U titles."
msgstr ""
#: src/main.cpp:367
#, c-format
msgid "%s%s (No banner.bin)"
msgstr ""
#: src/main.cpp:392
#, c-format
msgid "Loaded %i Wii titles."
msgstr ""
#: src/main.cpp:430
msgid "Name"
msgstr ""
#: src/main.cpp:430
msgid "None"
msgstr ""
#: src/main.cpp:430
msgid "Storage"
msgstr ""
#: src/main.cpp:430
msgid "Storage+Name"
msgstr ""
#: src/main.cpp:433
msgid "initFS failed. Please make sure your MochaPayload is up-to-date"
msgstr ""
#: src/main.cpp:464
#, c-format
msgid " Wii U Save Management (%u Title%s)"
msgstr ""
#: src/main.cpp:466
#, c-format
msgid " vWii Save Management (%u Title%s)"
msgstr ""
#: src/main.cpp:468
msgid " Batch Backup"
msgstr ""
#: src/main.cpp:470
msgid ": Select Mode"
msgstr ""
#: src/main.cpp:475
#, c-format
msgid " Backup All (%u Title%s)"
msgstr ""
#: src/main.cpp:477
#, c-format
msgid " Backup Wii U (%u Title%s)"
msgstr ""
#: src/main.cpp:479
#, c-format
msgid " Backup vWii (%u Title%s)"
msgstr ""
#: src/main.cpp:482 src/main.cpp:685
msgid ": Backup : Back"
msgstr ""
#: src/main.cpp:484
#, c-format
msgid "%s Sort: %s "
msgstr ""
#: src/main.cpp:499
msgid " [Not Init]"
msgstr ""
#: src/main.cpp:519
msgid ": Select Game : Back"
msgstr ""
#: src/main.cpp:527
msgid " Backup savedata"
msgstr ""
#: src/main.cpp:528
msgid " Restore savedata"
msgstr ""
#: src/main.cpp:529
msgid " Wipe savedata"
msgstr ""
#: src/main.cpp:531
msgid " Import from loadiine"
msgstr ""
#: src/main.cpp:532
msgid " Export to loadiine"
msgstr ""
#: src/main.cpp:534
#, c-format
msgid " Copy Savedata to Title in %s"
msgstr ""
#: src/main.cpp:542
msgid ": Select Task : Back"
msgstr ""
#: src/main.cpp:550
msgid "Destination:"
msgstr ""
#: src/main.cpp:554 src/main.cpp:560
#, c-format
msgid "Select %s:"
msgstr ""
#: src/main.cpp:554
msgid "version"
msgstr ""
#: src/main.cpp:557
msgid "Delete from:"
msgstr ""
#: src/main.cpp:560
msgid "slot"
msgstr ""
#: src/main.cpp:564 src/main.cpp:568 src/main.cpp:584 src/main.cpp:598
#: src/main.cpp:618 src/main.cpp:637
msgid "Empty"
msgstr ""
#: src/main.cpp:565 src/main.cpp:569
msgid "Used"
msgstr ""
#: src/main.cpp:576
msgid "Select SD user to copy from:"
msgstr ""
#: src/main.cpp:578 src/main.cpp:591 src/main.cpp:608 src/main.cpp:630
msgid "all users"
msgstr ""
#: src/main.cpp:583 src/main.cpp:597 src/main.cpp:617 src/main.cpp:636
msgid "Has Save"
msgstr ""
#: src/main.cpp:589
msgid "Select Wii U user to delete from:"
msgstr ""
#: src/main.cpp:605 src/main.cpp:628
#, c-format
msgid "Select Wii U user%s:"
msgstr ""
#: src/main.cpp:606
msgid " to copy from"
msgstr ""
#: src/main.cpp:606 src/main.cpp:628
msgid " to copy to"
msgstr ""
#: src/main.cpp:623 src/main.cpp:679
#, c-format
msgid "Date: %s"
msgstr ""
#: src/main.cpp:647 src/main.cpp:662
msgid "Include 'common' save?"
msgstr ""
#: src/main.cpp:649 src/main.cpp:663
msgid "no "
msgstr ""
#: src/main.cpp:649 src/main.cpp:663
msgid "yes"
msgstr ""
#: src/main.cpp:653 src/main.cpp:666
msgid "No 'common' save found."
msgstr ""
#: src/main.cpp:688
msgid ": Restore : Back"
msgstr ""
#: src/main.cpp:691
msgid ": Wipe : Back"
msgstr ""
#: src/main.cpp:694
msgid ": Import : Back"
msgstr ""
#: src/main.cpp:697
msgid ": Export : Back"
msgstr ""
#: src/main.cpp:700
msgid ": Copy : Back"
msgstr ""
#: src/main.cpp:706
msgid "Press  to exit."
msgstr ""
#: src/main.cpp:906
msgid "No Wii U titles found."
msgstr ""
#: src/main.cpp:910
msgid "No vWii saves found."
msgstr ""
#: src/main.cpp:939
msgid "CBHC save. Could be dangerous to modify. Continue?"
msgstr ""
#: src/main.cpp:940 src/main.cpp:952
msgid "Are you REALLY sure?"
msgstr ""
#: src/main.cpp:948
msgid "vWii saves are in the vWii section. Continue?"
msgstr ""
#: src/main.cpp:951
msgid "Recommended to run Game at least one time. Continue?"
msgstr ""
#: src/main.cpp:964
msgid "No save to Backup."
msgstr ""
#: src/main.cpp:977
msgid "No save to Wipe."
msgstr ""
#: src/main.cpp:994
msgid "No save to Export."
msgstr ""
#: src/main.cpp:1004
msgid "No save to Copy."
msgstr ""
#: src/savemng.cpp:53
#, c-format
msgid "Copying file: %s"
msgstr ""
#: src/savemng.cpp:54
#, c-format
msgid "From: %s"
msgstr ""
#: src/savemng.cpp:55
#, c-format
msgid "To: %s"
msgstr ""
#: src/savemng.cpp:265
msgid " Yes -  No"
msgstr ""
#: src/savemng.cpp:266
msgid " Confirm -  Cancel"
msgstr ""
#: src/savemng.cpp:475
#, c-format
msgid "Filesize: %d bytes"
msgstr ""
#: src/savemng.cpp:549
#, c-format
msgid "Deleting folder %s"
msgstr ""
#: src/savemng.cpp:550 src/savemng.cpp:554
#, c-format
msgid ""
"From: \n"
"%s"
msgstr ""
#: src/savemng.cpp:551
#, c-format
msgid ""
"Failed to delete folder %s\n"
"%s"
msgstr ""
#: src/savemng.cpp:553
#, c-format
msgid "Deleting file %s"
msgstr ""
#: src/savemng.cpp:555
#, c-format
msgid ""
"Failed to delete file %s\n"
"%s"
msgstr ""
#: src/savemng.cpp:593 src/savemng.cpp:602
msgid "Loadiine game folder not found."
msgstr ""
#: src/savemng.cpp:620
msgid "Failed to open Loadiine game save directory."
msgstr ""
#: src/savemng.cpp:748 src/savemng.cpp:850 src/savemng.cpp:884
#: src/savemng.cpp:920 src/savemng.cpp:952
msgid "Are you sure?"
msgstr ""
#: src/savemng.cpp:751 src/savemng.cpp:853
msgid "Backup current savedata first to next empty slot?"
msgstr ""
#: src/savemng.cpp:753
msgid "Backup done. Now copying Savedata."
msgstr ""
#: src/savemng.cpp:765 src/savemng.cpp:828 src/savemng.cpp:873
#: src/savemng.cpp:903 src/savemng.cpp:947 src/savemng.cpp:976
msgid "Common save not found."
msgstr ""
#: src/savemng.cpp:769
msgid "Copy failed."
msgstr ""
#: src/savemng.cpp:801
msgid "Backup failed."
msgstr ""
#: src/savemng.cpp:807
msgid "Backup found on this slot. Overwrite it?"
msgstr ""
#: src/savemng.cpp:833
msgid "No save found for this user."
msgstr ""
#: src/savemng.cpp:838
msgid "Backup failed. DO NOT restore from this slot."
msgstr ""
#: src/savemng.cpp:847
msgid "No backup found on selected slot."
msgstr ""
#: src/savemng.cpp:880
msgid "Restore failed."
msgstr ""
#: src/savemng.cpp:884
msgid "Hm, are you REALLY sure?"
msgstr ""
#: src/savemng.cpp:887 src/savemng.cpp:923
msgid "Backup current savedata first?"
msgstr ""
#: src/savemng.cpp:905
#, c-format
msgid ""
"Failed to delete common folder.\n"
"%s"
msgstr ""
#: src/savemng.cpp:912
msgid "Failed to delete savefile."
msgstr ""
#: src/savemng.cpp:915
#, c-format
msgid ""
"Failed to delete user folder.\n"
"%s"
msgstr ""
#: src/savemng.cpp:942
msgid "Failed to import savedata from loadiine."
msgstr ""
#: src/savemng.cpp:971
msgid "Failed to export savedata to loadiine."
msgstr ""

98
languages/spanish.json Normal file
View File

@ -0,0 +1,98 @@
{
"Disclaimer:": "Atención:",
"There is always the potential for a brick.": "Siempre existe la posibilidad de un brick.",
"Everything you do with this software is your own responsibility": "Todo lo que hagas con este software es tu responsabilidad",
"Out of memory.": "Sin memoria.",
"Loaded %i Wii U titles.": "Cargados %i títulos de Wii U.",
"%s%s (No banner.bin)": "%s%s (Sin banner.bin)",
"Loaded %i Wii titles.": "Cargados %i títulos de Wii.",
"None": "Ninguno",
"Name": "Nombre",
"Storage": "Dispositivo",
"Storage+Name": "Dispositivo+Nombre",
"initFS failed. Please make sure your MochaPayload is up-to-date": "Error en initFS. Verifica que MochaPayload está actualizado",
" Wii U Save Management (%u Title%s)": " Gestión de saves de Wii U (%u Título%s)",
" vWii Save Management (%u Title%s)": " Gestión de saves de vWii (%u Título%s)",
" Batch Backup": " Copia de seguridad en masa",
"\ue000: Select Mode": "\ue000: Seleccionar",
" Backup All (%u Title%s)": " Copiar Todo (%u Título%s)",
" Backup Wii U (%u Title%s)": " Copiar Wii U (%u Título%s)",
" Backup vWii (%u Title%s)": " Copiar vWii (%u Título%s)",
"\ue000: Backup \ue001: Back": "\ue000: Copiar \ue001: Atrás",
"%s Sort: %s \ue084": "%s Orden: %s \ue084",
" [Not Init]": " [No Inic.]",
"\ue000: Select Game \ue001: Back": "\ue000: Seleccionar Juego \ue001: Atrás",
" Backup savedata": " Copiar savedata",
" Restore savedata": " Restaurar savedata",
" Wipe savedata": " Borrar savedata",
" Import from loadiine": " Importar desde loadiine",
" Export to loadiine": " Exportar a loadiine",
" Copy Savedata to Title in %s": " Copiar Savedata al Título en %s",
"\ue000: Select Task \ue001: Back": "\ue000: Seleccionar Tarea \ue001: Atrás",
"Destination:": "Destino:",
"Select %s:": "Seleccionar %s:",
"version": "versión",
"Delete from:": "Borrar de:",
"slot": "slot",
"Empty": "Libre",
"Used": "Usado",
"Select SD user to copy from:": "Selecciona el usuario de SD del que copiar:",
"all users": "todos los usuarios",
"Has Save": "Existe Save",
"Select Wii U user to delete from:": "Selecciona el usuario de Wii U del que copiar:",
"Select Wii U user%s:": "Selecciona el usuario de Wii U%s:",
" to copy from": " del que copiar",
" to copy to": " al que copiar",
"Date: %s": "Fecha: %s",
"Include 'common' save?": "¿Incluír 'common' save?",
"yes": "sí",
"no ": "no ",
"No 'common' save found.": "No se ha encontrado 'common' save.",
"\ue000: Restore \ue001: Back": "\ue000: Restaurar \ue001: Atrás",
"\ue000: Wipe \ue001: Back": "\ue000: Eliminar \ue001: Atrás",
"\ue000: Import \ue001: Back": "\ue000: Importar \ue001: Atrás",
"\ue000: Export \ue001: Back": "\ue000: Exportar \ue001: Atrás",
"\ue000: Copy \ue001: Back": "\ue000: Copiar \ue001: Atrás",
"Press \ue044 to exit.": "Presiona \ue044 para salir.",
"No Wii U titles found.": "No se han encontrado títulos de Wii U.",
"No vWii saves found.": "No se han encontrado saves de vWii.",
"CBHC save. Could be dangerous to modify. Continue?": "Save de CBHC. Puede ser peligroso modificarlo. ¿Continuar?",
"Are you REALLY sure?": "¿Estás COMPLETAMENTE seguro?",
"vWii saves are in the vWii section. Continue?": "Los saves de vWii están en su propia sección. ¿Continuar?",
"Recommended to run Game at least one time. Continue?": "Se recomienda correr el juego al menos una vez. ¿Continuar?",
"No save to Backup.": "No hay save que copiar.",
"No save to Wipe.": "No hay save que eliminar.",
"No save to Export.": "No hay save que exportar.",
"No save to Copy.": "No hay save que copiar.",
"Copying file: %s": "Copiando archivo: %s",
"From: %s": "Desde: %s",
"To: %s": "A: %s",
"\ue000 Yes - \ue001 No": "\ue000 Sí - \ue001 No",
"\ue000 Confirm - \ue001 Cancel": "\ue000 Confirmar - \ue001 Cancelar",
"Filesize: %d bytes": "Tamaño: %d bytes",
"Deleting folder %s": "Eliminando carpeta %s",
"From: \n%s": "Desde:\n%s",
"Failed to delete folder %s\n%s": "Error al eliminar la carpeta %s\n%s",
"Deleting file %s": "Eliminando archivo %s",
"Failed to delete file %s\n%s": "Error al eliminar el archivo %s\n%s",
"Loadiine game folder not found.": "Carpeta del juego de Loadiine no encontrada.",
"Failed to open Loadiine game save directory.": "Error al abrir la carpeta de saves del juego de Loadiine.",
"Are you sure?": "¿Estás seguro?",
"Backup current savedata first to next empty slot?": "¿Copiar el save actual al siguiente slot libre?",
"Backup done. Now copying Savedata.": "Copia hecha. Haciendo copia del save.",
"Common save not found.": "No se ha podido encontrar el common save.",
"Copy failed.": "Error al realizar la copia.",
"Backup failed.": "Error al realizar la copia.",
"Backup found on this slot. Overwrite it?": "Se ha encontrado una copia en este slot. ¿Sobreescribirlo?",
"No save found for this user.": "No se han encontrado saves de este usuario.",
"Backup failed. DO NOT restore from this slot.": "Error al realizar la copia. NO restaures este slot.",
"No backup found on selected slot.": "No se ha encontrado una copia en el slot seleccionado.",
"Restore failed.": "Error al restaurar.",
"Hm, are you REALLY sure?": "¿Hm, estás COMPLETAMENTE seguro?",
"Backup current savedata first?": "¿Hacer copia antes del save?",
"Failed to delete common folder.\n%s": "Error al eliminar la carpeta common.\n%s",
"Failed to delete savefile.": "Error al eliminar el save.",
"Failed to delete user folder.\n%s": "Error al eliminar la carpeta user.\n%s",
"Failed to import savedata from loadiine.": "Error al importar el save de loadiine.",
"Failed to export savedata to loadiine.": "Error al exportar el save a loadiine."
}

View File

@ -1,484 +0,0 @@
msgid "Press \\ue044 to exit."
msgstr "Presiona \\ue044 para salir."
msgid "\\ue000: Copy \\ue001: Back"
msgstr "\\ue000: Copiar \\ue001: Atrás"
msgid "\\ue000: Export \\ue001: Back"
msgstr "\\ue000: Exportar \\ue001: Atrás"
msgid "\\ue000: Import \\ue001: Back"
msgstr "\\ue000: Importar \\ue001: Atrás"
msgid "\\ue000: Wipe \\ue001: Back"
msgstr "\\ue000: Borrar \\ue001: Atrás"
msgid "\\ue000: Restore \\ue001: Back"
msgstr "\\ue000: Restaurar \\ue001: Atrás"
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"Language-Team: Spanish\n"
"Language: sp\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid "\\ue000: Backup \\ue001: Back"
msgstr "\\ue000: Copiar \\ue001: Atrás"
msgid "\\ue000: Select Game \\ue001: Back"
msgstr "\\ue000: Seleccionar Juego \\ue001: Atrás"
msgid "\\ue000: Select Task \\ue001: Back"
msgstr "\\ue000: Seleccionar Tarea \\ue001: Atrás"
msgid "\\ue000 Yes - \\ue001 No"
msgstr "\\ue000 Sí - \\ue001 No"
msgid "\\ue000 Confirm - \\ue001 Cancel"
msgstr "\\ue000 Confirmar - \\ue001 Cancelar"
#: src/main.cpp:63
msgid "Disclaimer:"
msgstr "Atención:"
#: src/main.cpp:64
msgid "There is always the potential for a brick."
msgstr "Siempre existe la posibilidad de un brick."
#: src/main.cpp:65
msgid "Everything you do with this software is your own responsibility"
msgstr "Todo lo que hagas con este software es tu responsabilidad"
#: src/main.cpp:90 src/main.cpp:145 src/main.cpp:186 src/main.cpp:297
msgid "Out of memory."
msgstr "Sin memoria."
#: src/main.cpp:245 src/main.cpp:391
#, c-format
msgid "Loaded %i Wii U titles."
msgstr "Cargados %i títulos de Wii U."
#: src/main.cpp:367
#, c-format
msgid "%s%s (No banner.bin)"
msgstr "%s%s (Sin banner.bin)"
#: src/main.cpp:392
#, c-format
msgid "Loaded %i Wii titles."
msgstr "Cargados %i títulos de Wii."
#: src/main.cpp:430
msgid "Name"
msgstr "Nombre"
#: src/main.cpp:430
msgid "None"
msgstr "Ninguno"
#: src/main.cpp:430
msgid "Storage"
msgstr "Dispositivo"
#: src/main.cpp:430
msgid "Storage+Name"
msgstr "Dispositivo+Nombre"
#: src/main.cpp:433
msgid "initFS failed. Please make sure your MochaPayload is up-to-date"
msgstr "Error en initFS. Verifica que MochaPayload está actualizado"
#: src/main.cpp:464
#, c-format
msgid " Wii U Save Management (%u Title%s)"
msgstr " Gestión de saves de Wii U (%u Título%s)"
#: src/main.cpp:466
#, c-format
msgid " vWii Save Management (%u Title%s)"
msgstr " Gestión de saves de vWii (%u Título%s)"
#: src/main.cpp:468
msgid " Batch Backup"
msgstr " Copia de seguridad en masa"
#: src/main.cpp:470
#, fuzzy
msgid ": Select Mode"
msgstr ": Seleccionar"
#: src/main.cpp:475
#, c-format
msgid " Backup All (%u Title%s)"
msgstr " Copiar Todo (%u Título%s)"
#: src/main.cpp:477
#, c-format
msgid " Backup Wii U (%u Title%s)"
msgstr " Copiar Wii U (%u Título%s)"
#: src/main.cpp:479
#, c-format
msgid " Backup vWii (%u Title%s)"
msgstr " Copiar vWii (%u Título%s)"
#: src/main.cpp:482 src/main.cpp:685
#, fuzzy
msgid ": Backup : Back"
msgstr ": Copiar : Atrás"
#: src/main.cpp:484
#, c-format
msgid "%s Sort: %s "
msgstr "%s Orden: %s "
#: src/main.cpp:499
msgid " [Not Init]"
msgstr " [No Inic.]"
#: src/main.cpp:519
#, fuzzy
msgid ": Select Game : Back"
msgstr ": Seleccionar Juego : Atrás"
#: src/main.cpp:527
msgid " Backup savedata"
msgstr " Copiar savedata"
#: src/main.cpp:528
msgid " Restore savedata"
msgstr " Restaurar savedata"
#: src/main.cpp:529
msgid " Wipe savedata"
msgstr " Borrar savedata"
#: src/main.cpp:531
msgid " Import from loadiine"
msgstr " Importar desde loadiine"
#: src/main.cpp:532
msgid " Export to loadiine"
msgstr " Exportar a loadiine"
#: src/main.cpp:534
#, c-format
msgid " Copy Savedata to Title in %s"
msgstr " Copiar Savedata al Título en %s"
#: src/main.cpp:542
#, fuzzy
msgid ": Select Task : Back"
msgstr ": Seleccionar Juego : Atrás"
#: src/main.cpp:550
msgid "Destination:"
msgstr "Destino:"
#: src/main.cpp:554 src/main.cpp:560
#, c-format
msgid "Select %s:"
msgstr "Seleccionar %s:"
#: src/main.cpp:554
msgid "version"
msgstr "versión"
#: src/main.cpp:557
msgid "Delete from:"
msgstr "Borrar de:"
#: src/main.cpp:560
msgid "slot"
msgstr "slot"
#: src/main.cpp:564 src/main.cpp:568 src/main.cpp:584 src/main.cpp:598
#: src/main.cpp:618 src/main.cpp:637
msgid "Empty"
msgstr "Libre"
#: src/main.cpp:565 src/main.cpp:569
msgid "Used"
msgstr "Usado"
#: src/main.cpp:576
msgid "Select SD user to copy from:"
msgstr "Selecciona el usuario de SD del que copiar:"
#: src/main.cpp:578 src/main.cpp:591 src/main.cpp:608 src/main.cpp:630
msgid "all users"
msgstr "todos los usuarios"
#: src/main.cpp:583 src/main.cpp:597 src/main.cpp:617 src/main.cpp:636
msgid "Has Save"
msgstr "Existe Save"
#: src/main.cpp:589
msgid "Select Wii U user to delete from:"
msgstr "Selecciona el usuario de Wii U del que copiar:"
#: src/main.cpp:605 src/main.cpp:628
#, c-format
msgid "Select Wii U user%s:"
msgstr "Selecciona el usuario de Wii U%s:"
#: src/main.cpp:606
msgid " to copy from"
msgstr " del que copiar"
#: src/main.cpp:606 src/main.cpp:628
msgid " to copy to"
msgstr " al que copiar"
#: src/main.cpp:623 src/main.cpp:679
#, c-format
msgid "Date: %s"
msgstr "Fecha: %s"
#: src/main.cpp:647 src/main.cpp:662
msgid "Include 'common' save?"
msgstr "¿Incluír 'common' save?"
#: src/main.cpp:649 src/main.cpp:663
msgid "no "
msgstr "no "
#: src/main.cpp:649 src/main.cpp:663
msgid "yes"
msgstr "sí"
#: src/main.cpp:653 src/main.cpp:666
msgid "No 'common' save found."
msgstr "No se ha encontrado 'common' save."
#: src/main.cpp:688
#, fuzzy
msgid ": Restore : Back"
msgstr ": Seleccionar Juego : Atrás"
#: src/main.cpp:691
#, fuzzy
msgid ": Wipe : Back"
msgstr ": Copiar : Atrás"
#: src/main.cpp:694
#, fuzzy
msgid ": Import : Back"
msgstr ": Seleccionar Juego : Atrás"
#: src/main.cpp:697
#, fuzzy
msgid ": Export : Back"
msgstr ": Seleccionar Juego : Atrás"
#: src/main.cpp:700
#, fuzzy
msgid ": Copy : Back"
msgstr ": Copiar : Atrás"
#: src/main.cpp:706
#, fuzzy
msgid "Press  to exit."
msgstr "Presiona  para salir."
#: src/main.cpp:906
msgid "No Wii U titles found."
msgstr "No se han encontrado títulos de Wii U."
#: src/main.cpp:910
msgid "No vWii saves found."
msgstr "No se han encontrado títulos de vWii."
#: src/main.cpp:939
msgid "CBHC save. Could be dangerous to modify. Continue?"
msgstr "save de CBHC. Puede ser peligroso modificarlo. ¿Continuar?"
#: src/main.cpp:940 src/main.cpp:952
msgid "Are you REALLY sure?"
msgstr "¿Estás COMPLETAMENTE seguro?"
#: src/main.cpp:948
msgid "vWii saves are in the vWii section. Continue?"
msgstr "Los saves de vWii están en su propia sección. ¿Continuar?"
#: src/main.cpp:951
msgid "Recommended to run Game at least one time. Continue?"
msgstr "Se recomienda correr el juego al menos una vez. ¿Continuar?"
#: src/main.cpp:964
msgid "No save to Backup."
msgstr "No hay save que copiar."
#: src/main.cpp:977
msgid "No save to Wipe."
msgstr "No hay save que eliminar."
#: src/main.cpp:994
msgid "No save to Export."
msgstr "No hay save que exportar."
#: src/main.cpp:1004
msgid "No save to Copy."
msgstr "No hay save que copiar."
#: src/savemng.cpp:53
#, c-format
msgid "Copying file: %s"
msgstr "Copiando archivo: %s"
#: src/savemng.cpp:54
#, c-format
msgid "From: %s"
msgstr "Desde: %s"
#: src/savemng.cpp:55
#, c-format
msgid "To: %s"
msgstr "A: %s"
#: src/savemng.cpp:265
msgid " Yes -  No"
msgstr " Sí -  No"
#: src/savemng.cpp:266
#, fuzzy
msgid " Confirm -  Cancel"
msgstr " Confirmar -  Cancelar"
#: src/savemng.cpp:475
#, c-format
msgid "Filesize: %d bytes"
msgstr "Tamaño: %d bytes"
#: src/savemng.cpp:549
#, c-format
msgid "Deleting folder %s"
msgstr "Eliminando carpeta %s"
#: src/savemng.cpp:550 src/savemng.cpp:554
#, fuzzy, c-format
msgid ""
"From: \n"
"%s"
msgstr ""
"Desde: \n"
"%s"
#: src/savemng.cpp:551
#, c-format
msgid ""
"Failed to delete folder %s\n"
"%s"
msgstr ""
"Error al eliminar la carpeta %s\n"
"%s"
#: src/savemng.cpp:553
#, c-format
msgid "Deleting file %s"
msgstr "Eliminando archivo %s"
#: src/savemng.cpp:555
#, c-format
msgid ""
"Failed to delete file %s\n"
"%s"
msgstr ""
"Error al eliminar el archivo %s\n"
"%s"
#: src/savemng.cpp:593 src/savemng.cpp:602
msgid "Loadiine game folder not found."
msgstr "Carpeta del juego de Loadiine no encontrada."
#: src/savemng.cpp:620
msgid "Failed to open Loadiine game save directory."
msgstr "Error al abrir la carpeta de saves del juego de Loadiine."
#: src/savemng.cpp:748 src/savemng.cpp:850 src/savemng.cpp:884
#: src/savemng.cpp:920 src/savemng.cpp:952
msgid "Are you sure?"
msgstr "¿Estás seguro?"
#: src/savemng.cpp:751 src/savemng.cpp:853
msgid "Backup current savedata first to next empty slot?"
msgstr "¿Copiar el save actual al siguiente slot libre?"
#: src/savemng.cpp:753
msgid "Backup done. Now copying Savedata."
msgstr "Copia hecha. Haciendo copia del save."
#: src/savemng.cpp:765 src/savemng.cpp:828 src/savemng.cpp:873
#: src/savemng.cpp:903 src/savemng.cpp:947 src/savemng.cpp:976
msgid "Common save not found."
msgstr "No se ha podido encontrar el common save."
#: src/savemng.cpp:769
msgid "Copy failed."
msgstr "Error al realizar la copia."
#: src/savemng.cpp:801
msgid "Backup failed."
msgstr "Error al realizar la copia."
#: src/savemng.cpp:807
msgid "Backup found on this slot. Overwrite it?"
msgstr "Se ha encontrado una copia en este slot. ¿Sobreescribirlo?"
#: src/savemng.cpp:833
msgid "No save found for this user."
msgstr "No se han encontrado saves de este usuario."
#: src/savemng.cpp:838
msgid "Backup failed. DO NOT restore from this slot."
msgstr "Error al realizar la copia. NO restaures este slot."
#: src/savemng.cpp:847
msgid "No backup found on selected slot."
msgstr "No se ha encontrado una copia en el slot seleccionado."
#: src/savemng.cpp:880
msgid "Restore failed."
msgstr "Error al restaurar."
#: src/savemng.cpp:884
msgid "Hm, are you REALLY sure?"
msgstr "¿Hm, estás COMPLETAMENTE seguro?"
#: src/savemng.cpp:887 src/savemng.cpp:923
msgid "Backup current savedata first?"
msgstr "¿Hacer copia antes del save?"
#: src/savemng.cpp:905
#, c-format
msgid ""
"Failed to delete common folder.\n"
"%s"
msgstr ""
"Error al eliminar la carpeta common.\n"
"%s"
#: src/savemng.cpp:912
msgid "Failed to delete savefile."
msgstr "Error al eliminar save."
#: src/savemng.cpp:915
#, c-format
msgid ""
"Failed to delete user folder.\n"
"%s"
msgstr ""
"Error al eliminar la carpeta user.\n"
"%s"
#: src/savemng.cpp:942
msgid "Failed to import savedata from loadiine."
msgstr "Error al importar el save de loadiine."
#: src/savemng.cpp:971
msgid "Failed to export savedata to loadiine."
msgstr "Error al exportar el save a loadiine."

View File

@ -1,172 +0,0 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <fs/CFile.hpp>
CFile::CFile() {
iFd = -1;
mem_file = NULL;
filesize = 0;
pos = 0;
}
CFile::CFile(const std::string & filepath, eOpenTypes mode) {
iFd = -1;
this->open(filepath, mode);
}
CFile::CFile(const uint8_t * mem, int32_t size) {
iFd = -1;
this->open(mem, size);
}
CFile::~CFile() {
this->close();
}
int32_t CFile::open(const std::string & filepath, eOpenTypes mode) {
this->close();
int32_t openMode = 0;
switch(mode) {
default:
case ReadOnly:
openMode = O_RDONLY;
break;
case WriteOnly:
openMode = O_WRONLY;
break;
case ReadWrite:
openMode = O_RDWR;
break;
case Append:
openMode = O_APPEND | O_WRONLY;
break;
}
//! Using fopen works only on the first launch as expected
//! on the second launch it causes issues because we don't overwrite
//! the .data sections which is needed for a normal application to re-init
//! this will be added with launching as RPX
iFd = ::open(filepath.c_str(), openMode);
if(iFd < 0)
return iFd;
filesize = ::lseek(iFd, 0, SEEK_END);
::lseek(iFd, 0, SEEK_SET);
return 0;
}
int32_t CFile::open(const uint8_t * mem, int32_t size) {
this->close();
mem_file = mem;
filesize = size;
return 0;
}
void CFile::close() {
if(iFd >= 0)
::close(iFd);
iFd = -1;
mem_file = NULL;
filesize = 0;
pos = 0;
}
int32_t CFile::read(uint8_t * ptr, size_t size) {
if(iFd >= 0) {
int32_t ret = ::read(iFd, ptr,size);
if(ret > 0)
pos += ret;
return ret;
}
int32_t readsize = size;
if(readsize > (int64_t) (filesize-pos))
readsize = filesize-pos;
if(readsize <= 0)
return readsize;
if(mem_file != NULL) {
memcpy(ptr, mem_file+pos, readsize);
pos += readsize;
return readsize;
}
return -1;
}
int32_t CFile::write(const uint8_t * ptr, size_t size) {
if(iFd >= 0) {
size_t done = 0;
while(done < size) {
int32_t ret = ::write(iFd, ptr, size - done);
if(ret <= 0)
return ret;
ptr += ret;
done += ret;
pos += ret;
}
return done;
}
return -1;
}
int32_t CFile::seek(long int offset, int32_t origin) {
int32_t ret = 0;
int64_t newPos = pos;
if(origin == SEEK_SET) {
newPos = offset;
} else if(origin == SEEK_CUR) {
newPos += offset;
} else if(origin == SEEK_END) {
newPos = filesize+offset;
}
if(newPos < 0) {
pos = 0;
} else {
pos = newPos;
}
if(iFd >= 0)
ret = ::lseek(iFd, pos, SEEK_SET);
if(mem_file != NULL) {
if(pos > filesize) {
pos = filesize;
}
}
return ret;
}
int32_t CFile::fwrite(const char *format, ...) {
char tmp[512];
tmp[0] = 0;
int32_t result = -1;
va_list va;
va_start(va, format);
if((vsprintf(tmp, format, va) >= 0)) {
result = this->write((uint8_t *)tmp, strlen(tmp));
}
va_end(va);
return result;
}

125
src/gettext.cpp Normal file
View File

@ -0,0 +1,125 @@
/***************************************************************************
* Copyright (C) 2015 Dimok *
* Copyright (c) 2022 V10lator <v10lator@myway.de> *
* Copyright (c) 2022 Xpl0itU <DaThinkingChair@protonmail.com> *
* *
* 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, If not, see <http://www.gnu.org/licenses/>. * *
***************************************************************************/
#include "gettext.h"
#include "savemng.h"
#include <jansson.h>
#include <coreinit/memdefaultheap.h>
#include <coreinit/memory.h>
struct MSG;
typedef struct MSG MSG;
struct MSG
{
uint32_t id;
const char* msgstr;
MSG *next;
};
static MSG *baseMSG = NULL;
#define HASHMULTIPLIER 31 // or 37
// Hashing function from https://stackoverflow.com/a/2351171
static inline uint32_t hash_string(const char *str_param)
{
uint32_t hash = 0;
while(*str_param != '\0')
hash = HASHMULTIPLIER * hash + *str_param++;
return hash;
}
static inline MSG *findMSG(uint32_t id)
{
for(MSG *msg = baseMSG; msg; msg = msg->next)
if(msg->id == id)
return msg;
return NULL;
}
static void setMSG(const char *msgid, const char *msgstr)
{
if(!msgstr)
return;
uint32_t id = hash_string(msgid);
MSG *msg = (MSG *)MEMAllocFromDefaultHeap(sizeof(MSG));
msg->id = id;
msg->msgstr = strdup(msgstr);
msg->next = baseMSG;
baseMSG = msg;
return;
}
void gettextCleanUp()
{
while(baseMSG)
{
MSG *nextMsg = baseMSG->next;
MEMFreeToDefaultHeap((void *)(baseMSG->msgstr));
MEMFreeToDefaultHeap(baseMSG);
baseMSG = nextMsg;
}
}
bool gettextLoadLanguage(const char* langFile)
{
void *buffer;
size_t size = loadFile(langFile, &buffer);
if(buffer == NULL)
return false;
bool ret = true;
json_t *json = json_loadb(buffer, size, 0, NULL);
if(json)
{
size = json_object_size(json);
if(size != 0)
{
const char *key;
json_t *value;
json_object_foreach(json, key, value)
if(json_is_string(value))
setMSG(key, json_string_value(value));
}
else
{
ret = false;
}
json_decref(json);
}
else
{
ret = false;
}
MEMFreeToDefaultHeap(buffer);
return ret;
}
const char *gettext(const char *msgid)
{
MSG *msg = findMSG(hash_string(msgid));
return msg ? msg->msgstr : msgid;
}

View File

@ -5,43 +5,43 @@ Swkbd_LanguageType sysLang;
void loadLanguage(Swkbd_LanguageType language) {
switch(language) {
/*case Swkbd_LanguageType__Japanese:
gettextLoadLanguage("romfs:/japanese.lang");
gettextLoadLanguage("romfs:/japanese.json");
break;*/
case Swkbd_LanguageType__English:
gettextLoadLanguage("romfs:/english.lang");
gettextLoadLanguage("romfs:/english.json");
break;
/*case Swkbd_LanguageType__French:
gettextLoadLanguage("romfs:/french.lang");
gettextLoadLanguage("romfs:/french.json");
break;
case Swkbd_LanguageType__German:
gettextLoadLanguage("romfs:/german.lang");
gettextLoadLanguage("romfs:/german.json");
break;
case Swkbd_LanguageType__Italian:
gettextLoadLanguage("romfs:/italian.lang");
gettextLoadLanguage("romfs:/italian.json");
break;*/
case Swkbd_LanguageType__Spanish:
gettextLoadLanguage("romfs:/spanish.lang");
gettextLoadLanguage("romfs:/spanish.json");
break;
/*case Swkbd_LanguageType__Chinese1:
gettextLoadLanguage("romfs:/chinese1.lang");
gettextLoadLanguage("romfs:/chinese1.json");
break;
case Swkbd_LanguageType__Korean:
gettextLoadLanguage("romfs:/korean.lang");
gettextLoadLanguage("romfs:/korean.json");
break;
case Swkbd_LanguageType__Dutch:
gettextLoadLanguage("romfs:/dutch.lang");
gettextLoadLanguage("romfs:/dutch.json");
break;
case Swkbd_LanguageType__Potuguese:
gettextLoadLanguage("romfs:/portuguese.lang");
gettextLoadLanguage("romfs:/portuguese.json");
break;
case Swkbd_LanguageType__Russian:
gettextLoadLanguage("romfs:/russian.lang");
gettextLoadLanguage("romfs:/russian.json");
break;
case Swkbd_LanguageType__Chinese2:
gettextLoadLanguage("romfs:/chinese2.lang");
gettextLoadLanguage("romfs:/chinese2.json");
break;*/
default:
gettextLoadLanguage("romfs:/english.lang");
gettextLoadLanguage("romfs:/english.json");
break;
}
}

View File

@ -1,260 +0,0 @@
/****************************************************************************
* Copyright (C) 2015 Dimok
*
* 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 <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <language/gettext.h>
#include <fs/CFile.hpp>
#include <utils/StringTools.h>
char* strdup (const char* s)
{
size_t slen = strlen(s) + 1;
char* result = (char *) malloc(slen);
if(result == NULL)
return NULL;
memcpy(result, s, slen);
return result;
}
typedef struct _MSG {
uint32_t id;
char* msgstr;
struct _MSG *next;
} MSG;
static MSG *baseMSG = NULL;
#define HASHMULTIPLIER 31 // or 37
// Hashing function from https://stackoverflow.com/a/2351171
static inline uint32_t hash_string(const char *str) {
unsigned int h;
unsigned char *p;
h = 0;
for (p = (unsigned char*)str; *p != '\0'; p++)
h = HASHMULTIPLIER * h + *p;
return h;
}
/* Expand some escape sequences found in the argument string. */
static char *
expand_escape(const char *str) {
char *retval, *rp;
const char *cp = str;
retval = (char *) malloc(strlen(str) + 1);
if (retval == NULL) return NULL;
rp = retval;
while (*cp != '\0' && *cp != '\\')
*rp++ = *cp++;
if (*cp == '\0') goto terminate;
do {
/* Here cp[0] == '\\'. */
switch (*++cp) {
case '\"': /* " */
*rp++ = '\"';
++cp;
break;
case 'a': /* alert */
*rp++ = '\a';
++cp;
break;
case 'b': /* backspace */
*rp++ = '\b';
++cp;
break;
case 'f': /* form feed */
*rp++ = '\f';
++cp;
break;
case 'n': /* new line */
*rp++ = '\n';
++cp;
break;
case 'r': /* carriage return */
*rp++ = '\r';
++cp;
break;
case 't': /* horizontal tab */
*rp++ = '\t';
++cp;
break;
case 'v': /* vertical tab */
*rp++ = '\v';
++cp;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7': {
int ch = *cp++ - '0';
if (*cp >= '0' && *cp <= '7') {
ch *= 8;
ch += *cp++ - '0';
if (*cp >= '0' && *cp <= '7') {
ch *= 8;
ch += *cp++ - '0';
}
}
*rp = ch;
}
break;
case '\\':
++cp;
default:
*rp = '\\';
break;
}
while (*cp != '\0' && *cp != '\\')
*rp++ = *cp++;
} while (*cp != '\0');
/* Terminate string. */
terminate:
*rp = '\0';
return retval;
}
static inline MSG *findMSG(uint32_t id) {
for (MSG *msg = baseMSG; msg; msg = msg->next)
if (msg->id == id)
return msg;
return NULL;
}
static MSG *setMSG(const char *msgid, const char *msgstr) {
if(!msgstr)
return NULL;
uint32_t id = hash_string(msgid);
MSG *msg = findMSG(id);
if (!msg) {
msg = (MSG *) malloc(sizeof(MSG));
msg->id = id;
msg->msgstr = expand_escape(msgstr);
msg->next = baseMSG;
baseMSG = msg;
return NULL;
}
if (msgstr) {
if (msg->msgstr) free(msg->msgstr);
//msg->msgstr = strdup(msgstr);
msg->msgstr = expand_escape(msgstr);
}
return msg;
}
extern "C" void gettextCleanUp(void) {
while (baseMSG) {
MSG *nextMsg = baseMSG->next;
free(baseMSG->msgstr);
free(baseMSG);
baseMSG = nextMsg;
}
}
extern "C" BOOL gettextLoadLanguage(const char* langFile) {
char *lastID = NULL;
gettextCleanUp();
CFile file(langFile, CFile::ReadOnly);
if (!file.isOpen())
return false;
std::string strBuffer;
strBuffer.resize(file.size());
file.read((uint8_t *) &strBuffer[0], strBuffer.size());
file.close();
//! remove all windows crap signs
size_t position;
while(1) {
position = strBuffer.find('\r');
if(position == std::string::npos)
break;
strBuffer.erase(position, 1);
}
std::vector<std::string> lines = StringTools::stringSplit(strBuffer, "\n");
if(lines.empty())
return false;
for(unsigned int i = 0; i < lines.size(); i++) {
std::string & line = lines[i];
// lines starting with # are comments
if (line[0] == '#')
continue;
else if (strncmp(line.c_str(), "msgid \"", 7) == 0) {
char *msgid, *end;
if (lastID) {
free(lastID);
lastID = NULL;
}
msgid = &line[7];
end = strrchr(msgid, '"');
if (end && end - msgid > 1) {
*end = 0;
lastID = strdup(msgid);
}
} else if (strncmp(line.c_str(), "msgstr \"", 8) == 0) {
char *msgstr, *end;
if (lastID == NULL) continue;
msgstr = &line[8];
end = strrchr(msgstr, '"');
if (end && end - msgstr > 1) {
*end = 0;
setMSG(lastID, msgstr);
}
free(lastID);
lastID = NULL;
}
}
return true;
}
extern "C" const char *gettext(const char *msgid) {
if(!msgid)
return NULL;
MSG *msg = findMSG(hash_string(msgid));
return msg ? msg->msgstr : msgid;
}

View File

@ -1,210 +0,0 @@
/***************************************************************************
* Copyright (C) 2010
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
* for WiiXplorer 2010
***************************************************************************/
#include <vector>
#include <string>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <strings.h>
#include <wut_types.h>
#include <stdio.h>
#include <utils/StringTools.h>
BOOL StringTools::EndsWith(const std::string& a, const std::string& b) {
if (b.size() > a.size()) return false;
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
}
const char * StringTools::byte_to_binary(int32_t x) {
static char b[9];
b[0] = '\0';
int32_t z;
for (z = 128; z > 0; z >>= 1) {
strcat(b, ((x & z) == z) ? "1" : "0");
}
return b;
}
std::string StringTools::removeCharFromString(std::string& input,char toBeRemoved) {
std::string output = input;
size_t position;
while(1) {
position = output.find(toBeRemoved);
if(position == std::string::npos)
break;
output.erase(position, 1);
}
return output;
}
const char * StringTools::fmt(const char * format, ...) {
static char strChar[512];
strChar[0] = 0;
va_list va;
va_start(va, format);
if((vsprintf(strChar, format, va) >= 0)) {
va_end(va);
return (const char *) strChar;
}
va_end(va);
return NULL;
}
const wchar_t * StringTools::wfmt(const char * format, ...) {
static char tmp[512];
static wchar_t strWChar[512];
strWChar[0] = 0;
tmp[0] = 0;
if(!format)
return (const wchar_t *) strWChar;
if(strcmp(format, "") == 0)
return (const wchar_t *) strWChar;
va_list va;
va_start(va, format);
if((vsprintf(tmp, format, va) >= 0)) {
int bt;
int32_t strlength = strlen(tmp);
bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512 );
if(bt > 0) {
strWChar[bt] = 0;
return (const wchar_t *) strWChar;
}
}
va_end(va);
return NULL;
}
int32_t StringTools::strprintf(std::string &str, const char * format, ...) {
static char tmp[512];
tmp[0] = 0;
int32_t result = 0;
va_list va;
va_start(va, format);
if((vsprintf(tmp, format, va) >= 0)) {
str = tmp;
result = str.size();
}
va_end(va);
return result;
}
std::string StringTools::strfmt(const char * format, ...) {
std::string str;
static char tmp[512];
tmp[0] = 0;
va_list va;
va_start(va, format);
if((vsprintf(tmp, format, va) >= 0)) {
str = tmp;
}
va_end(va);
return str;
}
BOOL StringTools::char2wchar_t(const char * strChar, wchar_t * dest) {
if(!strChar || !dest)
return false;
int bt;
bt = mbstowcs(dest, strChar, strlen(strChar));
if (bt > 0) {
dest[bt] = 0;
return true;
}
return false;
}
int32_t StringTools::strtokcmp(const char * string, const char * compare, const char * separator) {
if(!string || !compare)
return -1;
char TokCopy[512];
strncpy(TokCopy, compare, sizeof(TokCopy));
TokCopy[511] = '\0';
char * strTok = strtok(TokCopy, separator);
while (strTok != NULL) {
if (strcasecmp(string, strTok) == 0) {
return 0;
}
strTok = strtok(NULL,separator);
}
return -1;
}
int32_t StringTools::strextcmp(const char * string, const char * extension, char seperator) {
if(!string || !extension)
return -1;
char *ptr = strrchr(string, seperator);
if(!ptr)
return -1;
return strcasecmp(ptr + 1, extension);
}
std::vector<std::string> StringTools::stringSplit(const std::string & inValue, const std::string & splitter) {
std::string value = inValue;
std::vector<std::string> result;
while (true) {
uint32_t index = value.find(splitter);
if (index == std::string::npos) {
result.push_back(value);
break;
}
std::string first = value.substr(0, index);
result.push_back(first);
if (index + splitter.size() == value.length()) {
result.push_back("");
break;
}
if(index + splitter.size() > value.length()) {
break;
}
value = value.substr(index + splitter.size(), value.length());
}
return result;
}

View File

@ -1,14 +0,0 @@
#! /bin/bash
#
find . -iname "*.cpp" -or -iname "*.c" | xargs xgettext --no-wrap -ktr -ktrNOOP -o languages/english.lang -j --no-location --omit-header
echo "Updated lang"
find . -iname "*.cpp" -or -iname "*.c" | xargs xgettext --no-wrap -ktr -ktrNOOP -o languages/english.lang -j --omit-header --sort-by-file
for fn in `find languages/*.lang`; do
if [ "$fn" != "languages/english.lang" ]; then
echo "Updated $fn"
msgmerge --output-file=$fn $fn languages/english.lang --no-wrap
fi
done