language.hpp

Go to the documentation of this file.
00001 /* $Id: language.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 #ifndef LANGUAGE_HPP_INCLUDED
00016 #define LANGUAGE_HPP_INCLUDED
00017 
00018 #include "tstring.hpp"
00019 #include "serialization/string_utils.hpp"
00020 
00021 #include <iterator>
00022 
00023 //this module controls internationalization.
00024 
00025 class config;
00026 
00027 struct language_def
00028 {
00029     language_def() :
00030         localename(),
00031         alternates(),
00032         language(),
00033         sort_name(),
00034         rtl(false)
00035         {}
00036 
00037     language_def(const std::string& name, const t_string& lang, const std::string& dir,
00038             const std::string &salternates = "", const std::string& sort_name = "") :
00039         localename(name),
00040         alternates(utils::split(salternates)),
00041         language(lang),
00042         sort_name(sort_name.empty() ? std::string(lang) : sort_name),
00043         rtl(dir == "rtl")
00044     {
00045     }
00046 
00047     std::string localename;
00048     std::vector<std::string> alternates;
00049     t_string language;
00050     std::string sort_name;
00051     bool rtl;       // A right to left language? (e.g: Hebrew)
00052     bool operator== (const language_def&) const;
00053     bool operator< (const language_def& a) const
00054         { return sort_name < a.sort_name; }
00055 };
00056 
00057 typedef std::vector<language_def> language_list;
00058 
00059 struct symbol_table
00060 {
00061     const t_string& operator[](const std::string& key) const;
00062     const t_string& operator[](const char* key) const;
00063 };
00064 
00065 //table of strings which are displayed to the user. Maps ids -> text.
00066 //this table should be consulted whenever something is to be
00067 //displayed on screen.
00068 extern symbol_table string_table;
00069 
00070 //function which, given the main configuration object, will return
00071 //a list of the translations of the game available.
00072 std::vector<language_def> get_languages();
00073 
00074 //function which, given the main configuration object, and a locale,
00075 //will set string_table to be populated with data from that locale.
00076 //locale may be either the full name of the language, like 'English',
00077 //or the 2-letter version, like 'en'.
00078 void set_language(const language_def& locale);
00079 
00080 //function which returns the name of the language currently used
00081 const language_def& get_language();
00082 bool current_language_rtl();
00083 
00084 //function which attempts to query and return the locale on the system
00085 const language_def& get_locale();
00086 
00087 /** Initializes the list of textdomains from a configuration object */
00088 void init_textdomains(const config& cfg);
00089 
00090 /** Initializes certain english strings */
00091 bool init_strings(const config& cfg);
00092 
00093 bool load_language_list();
00094 
00095 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:03 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs