Multiple Language Support

This is similar to https://gerrit.omnirom.org/#/c/14014

A lot of the features built in the older patch set have been split
out into separate patches, most of which have already been merged.
The remaining functionality here should all be directly related to
language selection and loading. We always load English as a base
before loading other languages over the top of the base. The idea
is that if another language is missing a translation, then we will
still display the English.

Maybe still to do: read the /cache/recovery/last_locale file and
load a language based on that. For me, this file contains just:
en_US
We probably won't bother with region specific translations so we
would have to look at either trimming off the _US or using some
other method like perhaps a symlink or a combination of the two.

Thanks to _that for twmsg.cpp class

Change-Id: I9647a22e47883a3ddd2de1da51f64aab7c328f74
diff --git a/data.cpp b/data.cpp
index 9f2e6b5..6b0f971 100644
--- a/data.cpp
+++ b/data.cpp
@@ -50,6 +50,7 @@
 #include "find_file.hpp"
 #include "set_metadata.h"
 #include <cutils/properties.h>
+#include "gui/gui.hpp"
 
 #define DEVID_MAX 64
 #define HWID_MAX 32
@@ -229,7 +230,7 @@
 	}
 
 	strcpy(device_id, "serialno");
-	LOGERR("=> device id not found, using '%s'\n", device_id);
+	LOGINFO("=> device id not found, using '%s'\n", device_id);
 	mConstValues.insert(make_pair("device_id", device_id));
 	return;
 }
@@ -616,8 +617,10 @@
 			}
 		}
 	} else {
-		if (PartitionManager.Fstab_Processed() != 0)
-			LOGERR("Storage partition '%s' not found\n", str.c_str());
+		if (PartitionManager.Fstab_Processed() != 0) {
+			LOGINFO("Storage partition '%s' not found\n", str.c_str());
+			gui_err("unable_locate_storage=Unable to locate storage device.");
+		}
 	}
 }
 
@@ -890,6 +893,8 @@
 #endif
 	mValues.insert(make_pair("tw_mount_system_ro", make_pair("2", 1)));
 	mValues.insert(make_pair("tw_never_show_system_ro_page", make_pair("0", 1)));
+	mValues.insert(make_pair("tw_language", make_pair(EXPAND(TW_DEFAULT_LANGUAGE), 1)));
+	LOGINFO("LANG: %s\n", EXPAND(TW_DEFAULT_LANGUAGE));
 
 	pthread_mutex_unlock(&m_valuesLock);
 }
@@ -1033,7 +1038,7 @@
 	}
 	FILE *fp = fopen(Path.c_str(), "w");
 	if (fp == NULL) {
-		LOGERR("Unable to open '%s'.\n", Path.c_str());
+		gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Path)(strerror(errno)));
 		return;
 	}
 	strcpy(version, TW_VERSION_STR);
@@ -1069,7 +1074,7 @@
 	{
 		usleep(500000);
 		if (!PartitionManager.Mount_Settings_Storage(false))
-			LOGERR("Unable to mount %s when trying to read settings file.\n", settings_file);
+			gui_msg(Msg(msg::kError, "unable_to_mount=Unable to mount {1}")(settings_file));
 	}
 
 	mkdir(mkdir_path, 0777);