From 74db157b9406594a549a70415668dd6cbe17d1d3 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Wed, 28 Oct 2015 12:44:49 -0500 Subject: 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 --- twrp.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'twrp.cpp') diff --git a/twrp.cpp b/twrp.cpp index d49ae801c..b33a6ad1a 100644 --- a/twrp.cpp +++ b/twrp.cpp @@ -15,12 +15,13 @@ #include #include -#include +#include #include #include #include #include #include +#include "gui/twmsg.h" #include "cutils/properties.h" extern "C" { @@ -37,6 +38,9 @@ extern "C" { #include "gui/gui.h" #include "set_metadata.h" } +#include "gui/gui.hpp" +#include "gui/pages.hpp" +#include "gui/objects.hpp" #include "twcommon.h" #include "twrp-functions.hpp" #include "data.hpp" @@ -162,14 +166,14 @@ int main(int argc, char **argv) { lgetfilecon("/sbin/teamwin", &contexts); } if (!contexts) { - gui_print_color("warning", "Kernel does not have support for reading SELinux contexts.\n"); + gui_warn("no_kernel_selinux=Kernel does not have support for reading SELinux contexts."); } else { free(contexts); - gui_print("Full SELinux support is present.\n"); + gui_msg("full_selinux=Full SELinux support is present."); } } #else - gui_print_color("warning", "No SELinux support (no libselinux).\n"); + gui_warn("no_selinux=No SELinux support (no libselinux)."); #endif PartitionManager.Mount_By_Path("/cache", true); @@ -307,6 +311,8 @@ int main(int argc, char **argv) { DataManager::SetValue("tw_mtp_enabled", 1); #endif DataManager::ReadSettingsFile(); + PageManager::LoadLanguage(DataManager::GetStrValue("tw_language")); + GUIConsole::Translate_Now(); // Fixup the RTC clock on devices which require it if(crash_counter == 0) @@ -328,13 +334,13 @@ int main(int argc, char **argv) { if (!PartitionManager.Enable_MTP()) PartitionManager.Disable_MTP(); else - gui_print("MTP Enabled\n"); + gui_msg("mtp_enabled=MTP Enabled"); } else { PartitionManager.Disable_MTP(); } property_set("mtp.crash_check", "0"); } else { - gui_print_color("warning", "MTP Crashed, not starting MTP on boot.\n"); + gui_warn("mtp_crash=MTP Crashed, not starting MTP on boot."); DataManager::SetValue("tw_mtp_enabled", 0); PartitionManager.Disable_MTP(); } @@ -367,7 +373,6 @@ int main(int argc, char **argv) { } } #endif - // Launch the main GUI gui_start(); @@ -391,7 +396,7 @@ int main(int argc, char **argv) { // Reboot TWFunc::Update_Intent_File(Reboot_Value); TWFunc::Update_Log_File(); - gui_print("Rebooting...\n"); + gui_msg(Msg("rebooting=Rebooting...")); string Reboot_Arg; DataManager::GetValue("tw_reboot_arg", Reboot_Arg); if (Reboot_Arg == "recovery") -- cgit v1.2.3