# Changes 0.2.4-1
- Add GIT_BRANCH (for development and stable) - Write Documentation of - pd-core (exept of vec.hpp) - pd-app - pd-drivers - pd-lib3ds - pd-image - pd-image - pd-ui7
This commit is contained in:
@@ -26,32 +26,73 @@ SOFTWARE.
|
||||
#include <pd/core/common.hpp>
|
||||
|
||||
namespace PD {
|
||||
/// @brief Lang System
|
||||
///< Translations are saved into json files
|
||||
///< Path should point to a directory the fils
|
||||
///< for example the files ar named [en.json, de.json, fr.json]
|
||||
/**
|
||||
* Language System
|
||||
*
|
||||
* - Translations are saved into json files
|
||||
* - path should point to a directory containing the json files
|
||||
* - example for filenames: `en.json`, `de.json`, `fr.json`
|
||||
*/
|
||||
class Lang : public SmartCtor<Lang> {
|
||||
public:
|
||||
Lang() = default;
|
||||
~Lang() = default;
|
||||
|
||||
/**
|
||||
* Function to set the path to search for Language files
|
||||
* @param path Path to search the files
|
||||
*/
|
||||
void SetBasePath(const std::string &path) { langs_path = path; }
|
||||
/**
|
||||
* Load a language file by the language key
|
||||
* @param lang_key Language key for example `de`
|
||||
*/
|
||||
void Load(const std::string &lang_key) {
|
||||
LoadFile(langs_path + "/" + lang_key + ".json");
|
||||
}
|
||||
/**
|
||||
* Directly load a Language file from a specific path
|
||||
* @param path Path to load the file from
|
||||
*/
|
||||
void LoadFile(const std::string &path);
|
||||
/**
|
||||
* Get a String by a `Keyword`
|
||||
* @param k Keyword to search for
|
||||
* @return Returns the string or if none found it returns the Keyword
|
||||
*/
|
||||
const std::string &Get(const std::string &k);
|
||||
/**
|
||||
* Get the Language Name
|
||||
* @return Returns the Language Name
|
||||
*/
|
||||
const std::string &GetName() { return lang_name; }
|
||||
/**
|
||||
* Get the Language ID / Key
|
||||
* @return Returns the Language ID
|
||||
*/
|
||||
const std::string &GetID() { return lang_id; }
|
||||
/**
|
||||
* Get the Language Author(s)
|
||||
* @return Returns the Author(s) of the Language file
|
||||
*/
|
||||
const std::string &GetAuthor() { return lang_author; }
|
||||
/**
|
||||
* Get the Language File Search Path
|
||||
* @return Returns Path where the Files are searched for
|
||||
*/
|
||||
const std::string &GetPath() { return langs_path; }
|
||||
|
||||
private:
|
||||
const int ver = 0;
|
||||
/** Language Files Root path */
|
||||
std::string langs_path = "romfs:/lang";
|
||||
/** Language Name */
|
||||
std::string lang_name;
|
||||
/** Language ID / Key */
|
||||
std::string lang_id;
|
||||
/** Language Author */
|
||||
std::string lang_author;
|
||||
/** KEY - STRING Table for faster Key access */
|
||||
std::map<std::string, std::string> ltable;
|
||||
};
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user