summaryrefslogtreecommitdiffstats
path: root/vncviewer/parameters.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-09-22 12:54:26 +0200
committerPierre Ossman <ossman@cendio.se>2014-09-22 13:14:11 +0200
commit8ca4c1dec5c821c238c55563acc9fb9057329264 (patch)
tree64790ca926172492549d37ab58ca97c0177ed5a7 /vncviewer/parameters.cxx
parentf05f355ba5390f4d686aa3028a292daca7ad0352 (diff)
downloadtigervnc-8ca4c1dec5c821c238c55563acc9fb9057329264.tar.gz
tigervnc-8ca4c1dec5c821c238c55563acc9fb9057329264.zip
Make sure user visible strings are translated
Diffstat (limited to 'vncviewer/parameters.cxx')
-rw-r--r--vncviewer/parameters.cxx126
1 files changed, 70 insertions, 56 deletions
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index b7b33b50..9297a165 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -44,6 +44,8 @@
#include <string.h>
#include <limits.h>
+#include "i18n.h"
+
using namespace rfb;
static LogWriter vlog("Parameters");
@@ -195,8 +197,9 @@ bool encodeValue(const char* val, char* dest, size_t destSize) {
strncpy(dest+pos, "\\\\", 2);
pos++;
if (pos >= destSize) {
- vlog.error("Encoding backslash: The size of the buffer dest is to small, "
- "it needs to be more than %d bytes bigger.", (destSize - 1 - i));
+ vlog.error(_("Encoding backslash: The size of the buffer dest "
+ "is to small, it needs to be more than %d bytes bigger."),
+ (destSize - 1 - i));
return false;
}
@@ -208,8 +211,9 @@ bool encodeValue(const char* val, char* dest, size_t destSize) {
dest[pos] = '\\';
pos++;
if (pos >= destSize) {
- vlog.error("Encoding escape sequence: The size of the buffer dest is to small, "
- "it needs to be more than %d bytes bigger.", (destSize - 1 - i));
+ vlog.error(_("Encoding escape sequence: The size of the buffer "
+ "dest is to small, it needs to be more than %d bytes "
+ "bigger."), (destSize - 1 - i));
return false;
}
@@ -226,8 +230,9 @@ bool encodeValue(const char* val, char* dest, size_t destSize) {
pos++;
if (pos >= destSize) {
- vlog.error("Encoding normal character: The size of the buffer dest is to small, "
- "it needs to be more than %d bytes bigger.", (destSize - 1 - i));
+ vlog.error(_("Encoding normal character: The size of the buffer dest "
+ "is to small, it needs to be more than %d bytes bigger."),
+ (destSize - 1 - i));
return false;
}
@@ -262,7 +267,7 @@ bool decodeValue(const char* val, char* dest, size_t destSize) {
dest[pos] = val[i];
i++;
} else {
- vlog.error("Unknown escape sequence at character %d", i);
+ vlog.error(_("Unknown escape sequence at character %d"), i);
return false;
}
}
@@ -274,8 +279,8 @@ bool decodeValue(const char* val, char* dest, size_t destSize) {
escapedCharacter = false; // Reset for next loop
pos++;
if (pos >= destSize) {
- vlog.error("Decoding: The size of the buffer dest is to small, "
- "it needs to be 1 byte bigger.");
+ vlog.error(_("Decoding: The size of the buffer dest is to small, "
+ "it needs to be 1 byte bigger."));
return false;
}
}
@@ -293,29 +298,31 @@ void setKeyString(const char *_name, const char *_value, HKEY* hKey) {
wchar_t name[buffersize];
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-name %s to wchar_t* when "
- "writing to the Registry, the buffersize is to small.", _name);
+ vlog.error(_("Could not convert the parameter-name %s to wchar_t* when "
+ "writing to the Registry, the buffersize is to small."),
+ _name);
return;
}
char encodingBuffer[buffersize];
if (!encodeValue(_value, encodingBuffer, buffersize)) {
- vlog.error("Could not encode the parameter-value %s when "
- "writing to the Registry.", _value);
+ vlog.error(_("Could not encode the parameter-value %s when "
+ "writing to the Registry."), _value);
return;
}
wchar_t value[buffersize];
size = fl_utf8towc(encodingBuffer, strlen(encodingBuffer)+1, value, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-value %s to wchar_t* when "
- "writing to the Registry, the buffersize is to small.", _value);
+ vlog.error(_("Could not convert the parameter-value %s to wchar_t* when "
+ "writing to the Registry, the buffersize is to small."),
+ _value);
return;
}
LONG res = RegSetValueExW(*hKey, name, 0, REG_SZ, (BYTE*)&value, (wcslen(value)+1)*2);
if (res != ERROR_SUCCESS) {
- vlog.error("Error(%d) writing %s(REG_SZ) to Registry.", res, _value);
+ vlog.error(_("Error(%d) writing %s(REG_SZ) to Registry."), res, _value);
return;
}
}
@@ -329,14 +336,15 @@ void setKeyInt(const char *_name, const int _value, HKEY* hKey) {
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-name %s to wchar_t* when "
- "writing to the Registry, the buffersize is to small.", _name);
+ vlog.error(_("Could not convert the parameter-name %s to wchar_t* when "
+ "writing to the Registry, the buffersize is to small."),
+ _name);
return;
}
LONG res = RegSetValueExW(*hKey, name, 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD));
if (res != ERROR_SUCCESS) {
- vlog.error("Error(%d) writing %d(REG_DWORD) to Registry.", res, _value);
+ vlog.error(_("Error(%d) writing %d(REG_DWORD) to Registry."), res, _value);
return;
}
}
@@ -350,8 +358,9 @@ bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* hKey) {
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-name %s to wchar_t* when "
- "reading from the Registry, the buffersize is to small.", _name);
+ vlog.error(_("Could not convert the parameter-name %s to wchar_t* when "
+ "reading from the Registry, the buffersize is to small."),
+ _name);
return false;
}
@@ -360,7 +369,7 @@ bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* hKey) {
if (res == ERROR_FILE_NOT_FOUND) {
// The value does not exist, defaults will be used.
} else {
- vlog.error("Error(%d) reading %s from Registry.", res, _name);
+ vlog.error(_("Error(%d) reading %s from Registry."), res, _name);
}
return false;
}
@@ -368,9 +377,9 @@ bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* hKey) {
char utf8val[destSize];
size = fl_utf8fromwc(utf8val, sizeof(utf8val), value, wcslen(value)+1);
if (size >= sizeof(utf8val)) {
- vlog.error("Could not convert the parameter-value for %s to utf8 char* "
- "when reading from the Registry, the buffer dest is to small.",
- _name);
+ vlog.error(_("Could not convert the parameter-value for %s to utf8 "
+ "char* when reading from the Registry, the buffer dest is "
+ "to small."), _name);
return false;
}
const char *ret = utf8val;
@@ -391,8 +400,9 @@ bool getKeyInt(const char* _name, int* dest, HKEY* hKey) {
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-name %s to wchar_t* when "
- "reading from the Registry, the buffersize is to small.", _name);
+ vlog.error(_("Could not convert the parameter-name %s to wchar_t* when "
+ "reading from the Registry, the buffersize is to small."),
+ _name);
return false;
}
@@ -401,7 +411,7 @@ bool getKeyInt(const char* _name, int* dest, HKEY* hKey) {
if (res == ERROR_FILE_NOT_FOUND) {
// The value does not exist, defaults will be used.
} else {
- vlog.error("Error(%d) reading %s from Registry.", res, _name);
+ vlog.error(_("Error(%d) reading %s from Registry."), res, _name);
}
return false;
}
@@ -418,7 +428,7 @@ void saveToReg(const char* servername) {
LONG res = RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\TigerVNC\\vncviewer", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL);
if (res != ERROR_SUCCESS) {
- vlog.error("Error(%d) creating key: Software\\TigerVNC\\vncviewer", res);
+ vlog.error(_("Error(%d) creating key: Software\\TigerVNC\\vncviewer"), res);
return;
}
@@ -432,13 +442,14 @@ void saveToReg(const char* servername) {
} else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != NULL) {
setKeyInt(parameterArray[i]->getName(), (int)*(BoolParameter*)parameterArray[i], &hKey);
} else {
- vlog.info("The parameterArray contains a object of a invalid type at line %d.", i);
+ vlog.info(_("The parameterArray contains a object of a invalid type "
+ "at line %d."), i);
}
}
res = RegCloseKey(hKey);
if (res != ERROR_SUCCESS) {
- vlog.error("Error(%d) closing key: Software\\TigerVNC\\vncviewer", res);
+ vlog.error(_("Error(%d) closing key: Software\\TigerVNC\\vncviewer"), res);
}
}
@@ -453,7 +464,7 @@ char* loadFromReg() {
if (res == ERROR_FILE_NOT_FOUND) {
// The key does not exist, defaults will be used.
} else {
- vlog.error("Error(%d) opening key: Software\\TigerVNC\\vncviewer", res);
+ vlog.error(_("Error(%d) opening key: Software\\TigerVNC\\vncviewer"), res);
}
return NULL;
}
@@ -479,13 +490,13 @@ char* loadFromReg() {
if (getKeyInt(parameterArray[i]->getName(), &intValue, &hKey))
((BoolParameter*)parameterArray[i])->setParam(intValue);
} else {
- vlog.info("The parameterArray contains a object of a invalid type at line %d.", i);
+ vlog.info(_("The parameterArray contains a object of a invalid type at line %d."), i);
}
}
res = RegCloseKey(hKey);
if (res != ERROR_SUCCESS){
- vlog.error("Error(%d) closing key: Software\\TigerVNC\\vncviewer", res);
+ vlog.error(_("Error(%d) closing key: Software\\TigerVNC\\vncviewer"), res);
}
return servername;
@@ -510,8 +521,8 @@ void saveViewerParameters(const char *filename, const char *servername) {
char* homeDir = NULL;
if (getvnchomedir(&homeDir) == -1) {
- vlog.error("Failed to write configuration file, "
- "can't obtain home directory path.");
+ vlog.error(_("Failed to write configuration file, can't obtain home "
+ "directory path."));
return;
}
@@ -524,7 +535,7 @@ void saveViewerParameters(const char *filename, const char *servername) {
FILE* f = fopen(filepath, "w+");
if (!f) {
snprintf(write_error, sizeof(write_error),
- "Failed to write configuration file, can't open %s", filepath);
+ _("Failed to write configuration file, can't open %s"), filepath);
throw Exception(write_error);
}
@@ -543,7 +554,8 @@ void saveViewerParameters(const char *filename, const char *servername) {
} else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != NULL) {
fprintf(f, "%s=%d\n", ((BoolParameter*)parameterArray[i])->getName(), (int)*(BoolParameter*)parameterArray[i]);
} else {
- vlog.info("The parameterArray contains a object of a invalid type at line %d.", i);
+ vlog.info(_("The parameterArray contains a object of a invalid type "
+ "at line %d."), i);
}
}
fclose(f);
@@ -569,8 +581,8 @@ char* loadViewerParameters(const char *filename) {
char* homeDir = NULL;
if (getvnchomedir(&homeDir) == -1)
- throw Exception("Failed to read configuration file, "
- "can't obtain home directory path.");
+ throw Exception(_("Failed to read configuration file, "
+ "can't obtain home directory path."));
snprintf(filepath, sizeof(filepath), "%sdefault.tigervnc", homeDir);
} else {
@@ -582,8 +594,8 @@ char* loadViewerParameters(const char *filename) {
if (!f) {
if (!filename)
return NULL; // Use defaults.
- snprintf(readError, sizeof(readError), "Failed to read configuration file, "
- "can't open %s", filepath);
+ snprintf(readError, sizeof(readError),
+ _("Failed to read configuration file, can't open %s"), filepath);
throw Exception(readError);
}
@@ -594,15 +606,15 @@ char* loadViewerParameters(const char *filename) {
lineNr++;
if (!fgets(line, sizeof(line), f)) {
if (line[sizeof(line) -1] != '\0') {
- vlog.error("Could not read the line(%d) in the configuration file,"
- "the buffersize is to small.", lineNr);
+ vlog.error(_("Could not read the line(%d) in the configuration file,"
+ "the buffersize is to small."), lineNr);
return NULL;
}
if (feof(f))
break;
- snprintf(readError, sizeof(readError), "Failed to read line %d in file %s",
- lineNr, filepath);
+ snprintf(readError, sizeof(readError),
+ _("Failed to read line %d in file %s"), lineNr, filepath);
throw Exception(readError);
}
@@ -611,9 +623,10 @@ char* loadViewerParameters(const char *filename) {
if(strncmp(line, IDENTIFIER_STRING, strlen(IDENTIFIER_STRING)) == 0) {
continue;
} else {
- snprintf(readError, sizeof(readError), "Line 1 in file %s\n"
- "must contain the TigerVNC configurationfile identifier string:\n"
- "\"%s\"", filepath, IDENTIFIER_STRING);
+ snprintf(readError, sizeof(readError),
+ _("Line 1 in file %s\nmust contain the TigerVNC "
+ "configuration file identifier string:\n"
+ "\"%s\""), filepath, IDENTIFIER_STRING);
throw Exception(readError);
}
}
@@ -631,7 +644,7 @@ char* loadViewerParameters(const char *filename) {
// Find the parameter value
char *value = strchr(line, '=');
if (value == NULL) {
- vlog.info("Bad Name/Value pair on line: %d in file: %s",
+ vlog.info(_("Bad Name/Value pair on line: %d in file: %s"),
lineNr, filepath);
continue;
}
@@ -644,8 +657,8 @@ char* loadViewerParameters(const char *filename) {
if (strcasecmp(line, "ServerName") == 0) {
if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer))) {
- vlog.info("The value of the parameter %s on line %d in file %s is invalid.",
- line, lineNr, filepath);
+ vlog.info(_("The value of the parameter %s on line %d in file %s "
+ "is invalid."), line, lineNr, filepath);
continue;
}
snprintf(servername, sizeof(decodingBuffer), "%s", decodingBuffer);
@@ -660,8 +673,8 @@ char* loadViewerParameters(const char *filename) {
if (strcasecmp(line, ((StringParameter*)parameterArray[i])->getName()) == 0) {
if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer))) {
- vlog.info("The value of the parameter %s on line %d in file %s is invalid.",
- line, lineNr, filepath);
+ vlog.info(_("The value of the parameter %s on line %d in file %s "
+ "is invalid."), line, lineNr, filepath);
continue;
}
((StringParameter*)parameterArray[i])->setParam(decodingBuffer);
@@ -681,13 +694,14 @@ char* loadViewerParameters(const char *filename) {
}
} else {
- vlog.info("The parameterArray contains a object of a invalid type at line %d.", lineNr);
+ vlog.info(_("The parameterArray contains a object of a invalid type "
+ "at line %d."), lineNr);
}
}
}
if (invalidParameterName)
- vlog.info("Invalid parameter name on line: %d in file: %s",
+ vlog.info(_("Invalid parameter name on line: %d in file: %s"),
lineNr, filepath);
}
fclose(f); f=0;