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/resources.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'gui/resources.hpp') diff --git a/gui/resources.hpp b/gui/resources.hpp index 0eb32674d..ce06d9679 100644 --- a/gui/resources.hpp +++ b/gui/resources.hpp @@ -6,6 +6,7 @@ #include #include #include +#include "rapidxml.hpp" struct ZipArchive; @@ -49,10 +50,19 @@ public: public: void* GetResource() { return this ? mFont : NULL; } int GetHeight() { return gr_getMaxFontHeight(this ? mFont : NULL); } + void Override(xml_node<>* node, ZipArchive* pZip); protected: void* mFont; Type m_type; + +private: + void LoadFont(xml_node<>* node, ZipArchive* pZip); + void DeleteFont(); + +private: + int origFontSize; + void* origFont; }; class ImageResource : public Resource @@ -92,19 +102,26 @@ class ResourceManager public: ResourceManager(); virtual ~ResourceManager(); - void LoadResources(xml_node<>* resList, ZipArchive* pZip); + void AddStringResource(std::string resource_source, std::string resource_name, std::string value); + void LoadResources(xml_node<>* resList, ZipArchive* pZip, std::string resource_source); public: FontResource* FindFont(const std::string& name) const; ImageResource* FindImage(const std::string& name) const; AnimationResource* FindAnimation(const std::string& name) const; std::string FindString(const std::string& name) const; + std::string FindString(const std::string& name, const std::string& default_string) const; + void DumpStrings() const; private: + struct string_resource_struct { + std::string value; + std::string source; + }; std::vector mFonts; std::vector mImages; std::vector mAnimations; - std::map mStrings; + std::map mStrings; }; #endif // _RESOURCE_HEADER -- cgit v1.2.3