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 --- gui/pages.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'gui/pages.hpp') diff --git a/gui/pages.hpp b/gui/pages.hpp index 018c2cab2..5dcc9e0b5 100644 --- a/gui/pages.hpp +++ b/gui/pages.hpp @@ -6,7 +6,9 @@ #include "../minzip/Zip.h" #include #include +#include #include "rapidxml.hpp" +#include "gui.hpp" using namespace rapidxml; enum TOUCH_STATE { @@ -27,12 +29,18 @@ struct COLOR { : red(r), green(g), blue(b), alpha(a) {} }; +struct language_struct { + std::string filename; + std::string displayvalue; +}; + +extern std::vector Language_List; + // Utility Functions int ConvertStrToColor(std::string str, COLOR* color); int gui_forceRender(void); int gui_changePage(std::string newPage); int gui_changeOverlay(std::string newPage); -std::string gui_parse_text(string inText); class Resource; class ResourceManager; @@ -82,7 +90,8 @@ public: virtual ~PageSet(); public: - int Load(ZipArchive* package, char* xmlFile); + int LoadLanguage(char* languageFile, ZipArchive* package); + int Load(ZipArchive* package, char* xmlFile, char* languageFile); int CheckInclude(ZipArchive* package, xml_document<> *parentDoc); Page* FindPage(std::string name); @@ -103,6 +112,7 @@ public: int NotifyVarChange(std::string varName, std::string value); std::vector*> styles; + void AddStringResource(std::string resource_source, std::string resource_name, std::string value); protected: int LoadPages(xml_node<>* pages); @@ -121,6 +131,8 @@ class PageManager public: // Used by GUI static char* LoadFileToBuffer(std::string filename, ZipArchive* package); + static void LoadLanguageList(ZipArchive* package); + static void LoadLanguage(std::string filename); static int LoadPackage(std::string name, std::string package, std::string startpage); static PageSet* SelectPackage(std::string name); static int ReloadPackage(std::string name, std::string package); @@ -155,9 +167,14 @@ public: static HardwareKeyboard *GetHardwareKeyboard(); static xml_node<>* FindStyle(std::string name); + static void AddStringResource(std::string resource_source, std::string resource_name, std::string value); protected: static PageSet* FindPackage(std::string name); + static void LoadLanguageListDir(std::string dir); + static void Translate_Partition(const char* path, const char* resource_name, const char* default_value); + static void Translate_Partition(const char* path, const char* resource_name, const char* default_value, const char* storage_resource_name, const char* storage_default_value); + static void Translate_Partition_Display_Names(); protected: static std::map mPageSets; -- cgit v1.2.3