VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/Resources.cpp
diff options
context:
space:
mode:
authorT-Bonhagen <75760084+T-Bonhagen@users.noreply.github.com>2020-12-11 18:42:59 +0100
committerGitHub <noreply@github.com>2020-12-11 18:42:59 +0100
commit38ad7650ac4f723fd6109e3f55b3ea1c47ec4af9 (patch)
tree5d70c7e1afc0fe83dae7a55d3dd62af18593aeff /src/Main/Resources.cpp
parentcb7adbfa26a5f47c5ef6dfd5bea46545480656f1 (diff)
downloadVeraCrypt-38ad7650ac4f723fd6109e3f55b3ea1c47ec4af9.tar.gz
VeraCrypt-38ad7650ac4f723fd6109e3f55b3ea1c47ec4af9.zip
new xml Tag for en and de (#708)
* new xml Tag for en and de * add linux support for env LANG * precopiled header into TrueCrypt.fdp to substitute '_()' with 'LangString[]' * more LangString in Code * add Language xml's to Linux Setup location * backup language for linux is en * remove Language.en.xml install * rearange new xml lines to end * yes/no dialogs now translated * All OK/Cancel Button now support international Co-authored-by: tb@tbon.de <tb@tbon.de>
Diffstat (limited to 'src/Main/Resources.cpp')
-rw-r--r--src/Main/Resources.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/Main/Resources.cpp b/src/Main/Resources.cpp
index 52b3cd4f..fe2f2c95 100644
--- a/src/Main/Resources.cpp
+++ b/src/Main/Resources.cpp
@@ -14,6 +14,12 @@
#include "Platform/Platform.h"
#include "Resources.h"
+#ifdef TC_LINUX
+#include "Platform/File.h"
+#include "Platform/StringConverter.h"
+#include <stdio.h>
+#endif
+
#ifdef TC_WINDOWS
#include "Main/resource.h"
#endif
@@ -48,6 +54,79 @@ namespace VeraCrypt
strBuf.Zero();
strBuf.CopyFrom (res);
return string (reinterpret_cast <char *> (strBuf.Ptr()));
+#elif TC_LINUX
+ // get language from env LANG
+ // support: C,POSIX,
+ // support for e.g. german: de_DE.UTF-8, de.UTF8, de_DE, de
+ // not support e.g.: de@Euro
+ string defaultLang("en");
+ string filenamePrefix("/usr/share/veracrypt/languages/Language.");
+ string filenamePost(".xml");
+ string filename = filenamePrefix + defaultLang + filenamePost;
+ if(const char* env_p = std::getenv("LANG")){
+ string lang(env_p);
+ std::cout << lang << std::endl;
+ if ( lang.size() > 1 ){
+ int found = lang.find(".");
+ if ( found > 1 ){
+ string langTag = lang.substr (0,found);
+ string lowerLangTag(StringConverter::ToLower (langTag) );
+ int foundUnderscore = lowerLangTag.find("_");
+ if ( foundUnderscore > 0 ) {
+ lowerLangTag.replace(foundUnderscore,1,1,'-');
+ filename = filenamePrefix + lowerLangTag + filenamePost;
+ FilesystemPath xml(filename);
+ if (! xml.IsFile()){
+ string shortLangTag = lowerLangTag.substr(0,foundUnderscore);
+ filename = filenamePrefix + shortLangTag + filenamePost;
+ FilesystemPath xml(filename);
+ if (! xml.IsFile()){
+ filename = filenamePrefix + defaultLang + filenamePost;
+ }
+ }
+ }else{
+ filename = filenamePrefix + langTag + filenamePost;
+ FilesystemPath xml(filename);
+ if (! xml.IsFile()){
+ filename = filenamePrefix + defaultLang + filenamePost;
+ }
+ }
+ }else{
+ string lowerLang(StringConverter::ToLower (lang) );
+ filename = filenamePrefix + lowerLang + filenamePost;
+ FilesystemPath xml(filename);
+ if (! xml.IsFile()){
+ int foundUnderscore = lowerLang.find("_");
+ if ( foundUnderscore > 0 ) {
+ lowerLang.replace(foundUnderscore,1,1,'-');
+ filename = filenamePrefix + lowerLang + filenamePost;
+ FilesystemPath xml(filename);
+ if (! xml.IsFile()){
+ filename = filenamePrefix + defaultLang + filenamePost;
+ }
+ }
+ }
+ }
+ }
+ }
+ FilesystemPath xml(filename);
+ if ( xml.IsFile() ){
+ File file;
+ file.Open (xml, File::OpenRead, File::ShareRead);
+ vector <byte> keyfileData (file.Length());
+ BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size());
+ file.ReadCompleteBuffer (keyfileDataBuf);
+ file.Close();
+ string langxml(keyfileData.begin(), keyfileData.end());
+ return langxml;
+ }
+ static byte LanguageXml[] =
+ {
+# include "Common/Language.xml.h"
+ , 0
+ };
+
+ return string ((const char*) LanguageXml);
#else
static byte LanguageXml[] =
{