From b105b61017274eec171269b0d0f9cc617f01d423 Mon Sep 17 00:00:00 2001 From: Daniel Brahneborg Date: Sat, 9 Mar 2002 21:07:08 +0000 Subject: I18N-ify sis classes --- lib/siscomponentrecord.cpp | 9 +++++---- lib/sisfile.cpp | 13 ++++++------ lib/sisfileheader.cpp | 49 +++++++++++++++++++++++----------------------- lib/sisfilerecord.cpp | 25 +++++++++++------------ lib/sislangrecord.cpp | 5 +++-- lib/sisreqrecord.cpp | 7 ++++--- po/POTFILES.in | 8 ++++++++ sisinstall/sismain.cpp | 16 ++++++++++----- 8 files changed, 76 insertions(+), 56 deletions(-) diff --git a/lib/siscomponentrecord.cpp b/lib/siscomponentrecord.cpp index 091f2b2..83781d1 100644 --- a/lib/siscomponentrecord.cpp +++ b/lib/siscomponentrecord.cpp @@ -22,6 +22,7 @@ #include "siscomponentrecord.h" #include "sisfile.h" +#include "plpintl.h" #include #include @@ -52,7 +53,7 @@ SISComponentNameRecord::fillFrom(uint8_t* buf, int base, off_t len, m_nameLengths[i] = read32(p + size); if (m_nameLengths[i] > len) { - printf("Length too large for name record %d.\n", i); + printf(_("Length too large for name record %d.\n"), i); return SIS_TRUNCATED; } size += 4; @@ -66,12 +67,12 @@ SISComponentNameRecord::fillFrom(uint8_t* buf, int base, off_t len, m_namePtrs[i] = read32(p + size); if (m_namePtrs[i] + m_nameLengths[i] > len) { - printf("Position/length too large for name record %d.\n", i); + printf(_("Position/length too large for name record %d.\n"), i); return SIS_TRUNCATED; } size += 4; if (logLevel >= 2) - printf("Name %d (for %s) is %.*s\n", + printf(_("Name %d (for %s) is %.*s\n"), i, sisFile->getLanguage(i)->m_name, m_nameLengths[i], @@ -82,7 +83,7 @@ SISComponentNameRecord::fillFrom(uint8_t* buf, int base, off_t len, m_names[i][len] = 0; } if (logLevel >= 1) - printf("%d .. %d (%d bytes): Name records\n", base, base + size, size); + printf(_("%d .. %d (%d bytes): Name records\n"), base, base + size, size); return SIS_OK; } diff --git a/lib/sisfile.cpp b/lib/sisfile.cpp index 634266f..c5d7139 100644 --- a/lib/sisfile.cpp +++ b/lib/sisfile.cpp @@ -24,6 +24,7 @@ #include "sislangrecord.h" #include "sisfilerecord.h" #include "sisreqrecord.h" +#include "plpintl.h" #include @@ -40,11 +41,11 @@ SISFile::fillFrom(uint8_t* buf, off_t len) SisRC rc = m_header.fillFrom(buf, &ix, len); if (rc != SIS_OK) { - printf("Could not read header, rc = %d\n", rc); + printf(_("Could not read header, rc = %d\n"), rc); return rc; } if (logLevel >= 2) - printf("Ate header, got ix = %d\n", ix); + printf(_("Ate header, got ix = %d\n"), ix); int n; // Read languages. @@ -59,7 +60,7 @@ SISFile::fillFrom(uint8_t* buf, off_t len) rc = m_langRecords[i].fillFrom(buf, &ix, len); if (rc != SIS_OK) { - printf("Problem reading language record %d, rc = %d.\n", i, rc); + printf(_("Problem reading language record %d, rc = %d.\n"), i, rc); return rc; } } @@ -76,7 +77,7 @@ SISFile::fillFrom(uint8_t* buf, off_t len) rc = m_reqRecords[i].fillFrom(buf, &ix, len, this); if (rc != SIS_OK) { - printf("Problem reading requisite record %d, rc = %d.\n", i, rc); + printf(_("Problem reading requisite record %d, rc = %d.\n"), i, rc); return rc; } } @@ -87,7 +88,7 @@ SISFile::fillFrom(uint8_t* buf, off_t len) rc = m_componentRecord.fillFrom(buf, ix, len, this); if (rc != SIS_OK) { - printf("Problem reading the name record, rc = %d.\n", rc); + printf(_("Problem reading the name record, rc = %d.\n"), rc); return rc; } @@ -103,7 +104,7 @@ SISFile::fillFrom(uint8_t* buf, off_t len) rc = m_fileRecords[i].fillFrom(buf, &ix, len, this); if (rc != SIS_OK) { - printf("Problem reading file record %d, rc = %d.\n", i, rc); + printf(_("Problem reading file record %d, rc = %d.\n"), i, rc); return rc; } } diff --git a/lib/sisfileheader.cpp b/lib/sisfileheader.cpp index 97e0687..a6535c8 100644 --- a/lib/sisfileheader.cpp +++ b/lib/sisfileheader.cpp @@ -21,6 +21,7 @@ */ #include "sisfileheader.h" +#include "plpintl.h" #include #include @@ -53,25 +54,25 @@ SISFileHeader::fillFrom(uint8_t* buf, int* base, off_t len) m_buf = buf; m_uid1 = read32(start); if (logLevel >= 1) - printf("Got uid1 = %08x\n", m_uid1); + printf(_("Got uid1 = %08x\n"), m_uid1); m_uid2 = read32(start + 4); if (m_uid2 != 0x1000006d) { - printf("Got bad uid2.\n"); + printf(_("Got bad uid2.\n")); return SIS_CORRUPTED; } if (logLevel >= 2) - printf("Got uid2 = %08x\n", m_uid2); + printf(_("Got uid2 = %08x\n"), m_uid2); m_uid3 = read32(start + 8); if (m_uid3 != 0x10000419) { - printf("Got bad uid3.\n"); + printf(_("Got bad uid3.\n")); return SIS_CORRUPTED; } if (logLevel >= 2) - printf("Got uid3 = %08x\n", m_uid3); + printf(_("Got uid3 = %08x\n"), m_uid3); m_uid4 = read32(start + 12); -// printf("Got uid4 = %08x\n", m_uid4); +// printf(_("Got uid4 = %08x\n"), m_uid4); uint16_t crc1 = 0; for (int i = 0; i < 12; i += 2) crc1 = updateCrc(crc1, buf[*base + i]); @@ -79,69 +80,69 @@ SISFileHeader::fillFrom(uint8_t* buf, int* base, off_t len) for (int i = 0; i < 12; i += 2) crc2 = updateCrc(crc2, buf[*base + i + 1]); if (logLevel >= 2) - printf("Got first crc = %08x, wanted %08x\n", + printf(_("Got first crc = %08x, wanted %08x\n"), crc2 << 16 | crc1, m_uid4); if ((crc2 << 16 | crc1) != m_uid4) { - printf("Got bad crc.\n"); + printf(_("Got bad crc.\n")); return SIS_CORRUPTED; } m_crc = read16(start + 16); m_nlangs = read16(start + 18); if (logLevel >= 2) - printf("Got %d languages\n", m_nlangs); + printf(_("Got %d languages\n"), m_nlangs); m_nfiles = read16(start + 20); if (logLevel >= 2) - printf("Got %d files\n", m_nfiles); + printf(_("Got %d files\n"), m_nfiles); m_nreqs = read16(start + 22); if (logLevel >= 2) - printf("Got %d reqs\n", m_nreqs); + printf(_("Got %d reqs\n"), m_nreqs); m_installationLanguage = read16(start + 24); if (logLevel >= 2) - printf("Selected language is %d\n", m_installationLanguage); + printf(_("Selected language is %d\n"), m_installationLanguage); m_installationFiles = read16(start + OFF_NUMBER_OF_FILES); if (logLevel >= 2) - printf("Installed files: %d / %d\n", m_installationFiles, m_nfiles); + printf(_("Installed files: %d / %d\n"), m_installationFiles, m_nfiles); m_installationDrive = read32(start + OFF_INSTALLATION_DRIVE); if (logLevel >= 2) - printf("Installed on drive %c\n", m_installationDrive); + printf(_("Installed on drive %c\n"), m_installationDrive); m_installerVersion = read32(start + 32); if (logLevel >= 2) - printf("Got installer version: %08x\n", m_installerVersion); + printf(_("Got installer version: %08x\n"), m_installerVersion); m_options = read16(start + 36); if (logLevel >= 2) - printf("Got options: %04x\n", m_options); + printf(_("Got options: %04x\n"), m_options); m_type = read16(start + 38); if (logLevel >= 2) - printf("Got type: %0x\n", m_type); + printf(_("Got type: %0x\n"), m_type); m_major = read16(start + 40); if (logLevel >= 2) - printf("Got major: %d\n", m_major); + printf(_("Got major: %d\n"), m_major); m_minor = read16(start + 42); if (logLevel >= 2) - printf("Got minor: %d\n", m_minor); + printf(_("Got minor: %d\n"), m_minor); m_variant = read32(start + 44); if (logLevel >= 2) - printf("Got variant: %d\n", m_variant); + printf(_("Got variant: %d\n"), m_variant); m_languagePtr = read32(start + 48); if (logLevel >= 2) - printf("Languages begin at %d\n", m_languagePtr); + printf(_("Languages begin at %d\n"), m_languagePtr); if (m_languagePtr >= len) return SIS_TRUNCATED; m_filesPtr = read32(start + 52); if (logLevel >= 2) - printf("Files begin at %d\n", m_filesPtr); + printf(_("Files begin at %d\n"), m_filesPtr); if (m_filesPtr >= len) return SIS_TRUNCATED; m_reqPtr = read32(start + 56); if (logLevel >= 2) - printf("Requisites begin at %d\n", m_reqPtr); + printf(_("Requisites begin at %d\n"), m_reqPtr); if (m_reqPtr >= len) return SIS_TRUNCATED; m_unknown = read32(start + 60); m_componentPtr = read32(start + 64); if (logLevel >= 2) - printf("Components begin at %d\n", m_componentPtr); + printf(_("Components begin at %d\n"), m_componentPtr); if (m_componentPtr >= len) return SIS_TRUNCATED; *base += 68; diff --git a/lib/sisfilerecord.cpp b/lib/sisfilerecord.cpp index e7dd007..24650da 100644 --- a/lib/sisfilerecord.cpp +++ b/lib/sisfilerecord.cpp @@ -22,6 +22,7 @@ #include "sisfilerecord.h" #include "sisfile.h" +#include "plpintl.h" #include @@ -35,26 +36,26 @@ SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) int size = 0; m_flags = read32(p); if (logLevel >= 2) - printf("Got flags %d\n", m_flags); + printf(_("Got flags %d\n"), m_flags); m_fileType = read32(p + 4); if (logLevel >= 2) - printf("Got file type %d\n", m_fileType); + printf(_("Got file type %d\n"), m_fileType); m_fileDetails = read32(p + 8); if (logLevel >= 2) - printf("Got file details %d\n", m_fileDetails); + printf(_("Got file details %d\n"), m_fileDetails); m_sourceLength = read32(p + 12); m_sourcePtr = read32(p + 16); -// printf("Got source length = %d, source name ptr = %d\n", +// printf(_("Got source length = %d, source name ptr = %d\n"), // m_sourceLength, m_sourcePtr); if (logLevel >= 2) if (m_sourceLength > 0) - printf("Got source name %.*s\n", m_sourceLength, buf + m_sourcePtr); + printf(_("Got source name %.*s\n"), m_sourceLength, buf + m_sourcePtr); m_destLength = read32(p + 20); m_destPtr = read32(p + 24); -// printf("Got dest length = %d, dest name ptr = %d\n", +// printf(_("Got dest length = %d, dest name ptr = %d\n"), // m_destLength, m_destPtr); if (logLevel >= 2) - printf("Got destination name %.*s\n", m_destLength, buf + m_destPtr); + printf(_("Got destination name %.*s\n"), m_destLength, buf + m_destPtr); size = 28; switch (m_flags) { @@ -65,11 +66,11 @@ SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) m_filePtrs[0] = read32(p + size + 4); size += 8; if (logLevel >= 2) - printf("File is %d bytes long (at %d) (to %d)\n", + printf(_("File is %d bytes long (at %d) (to %d)\n"), m_fileLengths[0], m_filePtrs[0], m_fileLengths[0] + m_filePtrs[0]); if (logLevel >= 1) - printf("%d .. %d (%d bytes): Single file record type %d, %.*s\n", + printf(_("%d .. %d (%d bytes): Single file record type %d, %.*s\n"), m_filePtrs[0], m_filePtrs[0] + m_fileLengths[0], m_fileLengths[0], @@ -99,13 +100,13 @@ SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) return SIS_TRUNCATED; size += 4; if (logLevel >= 2) - printf("File %d (for %s) is %d bytes long (at %d)\n", + printf(_("File %d (for %s) is %d bytes long (at %d)\n"), i, sisFile->getLanguage(i)->m_name, fileLen, m_filePtrs[i]); if (logLevel >= 1) - printf("%d .. %d (%d bytes): File record (%s) for %.*s\n", + printf(_("%d .. %d (%d bytes): File record (%s) for %.*s\n"), m_filePtrs[i], m_filePtrs[i] + fileLen, fileLen, @@ -117,7 +118,7 @@ SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) default: if (logLevel >= 2) - printf("Unknown file flags %d\n", m_flags); + printf(_("Unknown file flags %d\n"), m_flags); } *base += size; return SIS_OK; diff --git a/lib/sislangrecord.cpp b/lib/sislangrecord.cpp index 1a55784..415e655 100644 --- a/lib/sislangrecord.cpp +++ b/lib/sislangrecord.cpp @@ -21,6 +21,7 @@ */ #include "sislangrecord.h" +#include "plpintl.h" #include @@ -33,9 +34,9 @@ SISLangRecord::fillFrom(uint8_t* buf, int* base, off_t len) if (m_lang > 33) // Thai, last language return SIS_CORRUPTED; if (logLevel >= 2) - printf("Got language %d (%s)\n", m_lang, langTable[m_lang].m_name); + printf(_("Got language %d (%s)\n"), m_lang, langTable[m_lang].m_name); if (logLevel >= 1) - printf("%d .. %d (%d bytes): Language record for %s\n", + printf(_("%d .. %d (%d bytes): Language record for %s\n"), *base, *base + 2, 2, langTable[m_lang].m_name); *base += 2; return SIS_OK; diff --git a/lib/sisreqrecord.cpp b/lib/sisreqrecord.cpp index 9d32a88..654e8de 100644 --- a/lib/sisreqrecord.cpp +++ b/lib/sisreqrecord.cpp @@ -22,6 +22,7 @@ #include "sisreqrecord.h" #include "sisfile.h" +#include "plpintl.h" #include @@ -58,19 +59,19 @@ SISReqRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) m_namePtrs[i] = read32(p + size); if (m_namePtrs[i] + m_nameLengths[i] > len) { - printf("Position/length too large for req record %d.\n", i); + printf(_("Position/length too large for req record %d.\n"), i); return SIS_CORRUPTED; } size += 4; if (logLevel >= 2) - printf("Name %d (for %s) is %.*s\n", + printf(_("Name %d (for %s) is %.*s\n"), i, sisFile->getLanguage(i)->m_name, m_nameLengths[i], buf + m_namePtrs[i]); } if (logLevel >= 1) - printf("%d .. %d (%d bytes): Req record\n", + printf(_("%d .. %d (%d bytes): Req record\n"), *base, *base + size, size); *base += size; return SIS_OK; diff --git a/po/POTFILES.in b/po/POTFILES.in index d7672ba..0cce2bd 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,7 +4,15 @@ lib/psitime.h lib/rpcsfactory.cc lib/plpdirent.cc lib/rfsvfactory.cc +lib/siscomponentrecord.cpp +lib/sisfile.cpp +lib/sisfileheader.cpp +lib/sisfilerecord.cpp +lib/sislangrecord.cpp +lib/sisreqrecord.cpp plpftp/main.cc plpftp/ftp.cc plpbackup/plpbackup.cc +sisinstall/sismain.cpp + diff --git a/sisinstall/sismain.cpp b/sisinstall/sismain.cpp index 17d4d2f..8420733 100644 --- a/sisinstall/sismain.cpp +++ b/sisinstall/sismain.cpp @@ -24,6 +24,12 @@ void main(int argc, char* argv[]) char* filename = 0; char option; bool dryrun = false; + +#ifdef LC_ALL + setlocale(LC_ALL, ""); +#endif + textdomain(PACKAGE); + while ((option = getopt(argc, argv, "nl:")) != -1) { switch (option) @@ -39,15 +45,15 @@ void main(int argc, char* argv[]) if (optind < argc) { filename = argv[optind]; - printf("Installing sis file %s%s\n", filename, - dryrun ? ", not really" : ""); + printf(_("Installing sis file %s%s\n"), filename, + dryrun ? _(", not really") : ""); } struct stat st; if (-1 == stat(filename, &st)) error(__LINE__); off_t len = st.st_size; if (logLevel >= 2) - printf("File is %d bytes long\n", len); + printf(_("File is %d bytes long\n"), len); uint8_t* buf = new uint8_t[len]; int fd = open(filename, O_RDONLY); if (-1 == fd) @@ -62,7 +68,7 @@ void main(int argc, char* argv[]) psion = new Psion(); if (!psion->connect()) { - printf("Couldn't connect with the Psion\n"); + printf(_("Couldn't connect with the Psion\n")); exit(1); } createCRCTable(); @@ -79,7 +85,7 @@ void main(int argc, char* argv[]) } else { - printf("Could not parse the sis file.\n"); + printf(_("Could not parse the sis file.\n")); } psion->disconnect(); -- cgit v1.2.3