language.hpp

Go to the documentation of this file.
00001 /* $Id: language.hpp 26686 2008-05-18 09:34:19Z mordante $ */
00002 /*
00003    Copyright (C) 2003 - 2008 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 version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 #ifndef LANGUAGE_HPP_INCLUDED
00015 #define LANGUAGE_HPP_INCLUDED
00016 
00017 #include "tstring.hpp"
00018 #include "serialization/string_utils.hpp"
00019 
00020 #include <map>
00021 #include <string>
00022 #include <vector>
00023 #include <iterator>
00024 
00025 //this module controls internationalization.
00026 
00027 class t_string;
00028 class config;
00029 
00030 struct language_def
00031 {
00032     language_def() :
00033         localename(),
00034         alternates(),
00035         language(),
00036         rtl(false)
00037         {}
00038 
00039     language_def(const std::string& name, const t_string& lang, const std::string& dir,
00040         const std::string &salternates = "") :
00041         localename(name), 
00042         alternates(),
00043         language(lang), 
00044         rtl(dir == "rtl")
00045     {
00046             alternates = utils::split(salternates);
00047         }
00048     std::string localename;
00049     std::vector<std::string> alternates;
00050     t_string language;
00051     bool rtl;       // A right to left language? (e.g: Hebrew)
00052     bool operator== (const language_def&) const;
00053     
00054     /**
00055      * Is the locale available on the system?
00056      *
00057      * If the dummy locales are selected we always return true.
00058      */
00059     bool available() const;
00060 };
00061 
00062 std::string languagedef_name (const language_def& def);
00063 
00064 struct symbol_table
00065 {
00066     const t_string& operator[](const std::string& key) const;
00067     const t_string& operator[](const char* key) const;
00068 };
00069 
00070 //table of strings which are displayed to the user. Maps ids -> text.
00071 //this table should be consulted whenever something is to be
00072 //displayed on screen.
00073 extern symbol_table string_table;
00074 
00075 //function which, given the main configuration object, will return
00076 //a list of the translations of the game available.
00077 std::vector<language_def> get_languages();
00078 
00079 //function which, given the main configuration object, and a locale,
00080 //will set string_table to be populated with data from that locale.
00081 //locale may be either the full name of the language, like 'English',
00082 //or the 2-letter version, like 'en'.
00083 bool set_language(const language_def& locale);
00084 
00085 //function which returns the name of the language currently used
00086 const language_def& get_language();
00087 bool current_language_rtl();
00088 
00089 //function which attempts to query and return the locale on the system
00090 const language_def& get_locale();
00091 
00092 /** Initializes the list of textdomains from a configuration object */
00093 void init_textdomains(const config& cfg);
00094 
00095 bool load_language_list();
00096 
00097 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs