More Bidi support (applied patch #479)

Also added Ely Levy's name to the translation team credits.
This commit is contained in:
Oron Peled 2005-11-07 23:57:15 +00:00
parent db22d64766
commit 75916529d2
5 changed files with 29 additions and 4 deletions

View File

@ -1,4 +1,5 @@
[locale]
name="עברית (Hebrew)"
locale=he_IL
dir=rtl
[/locale]

View File

@ -242,6 +242,7 @@ std::vector<std::string> get_text() {
"_" N_("+Hebrew Translation"),
"- Oron Peled",
"- Ely Levy",
"_" N_("+Hungarian Translation"),
"- adson",

View File

@ -29,6 +29,7 @@
#include "video.hpp"
#include "widgets/button.hpp"
#include "game_events.hpp"
#include "language.hpp"
#include <cstdlib>
#include <sstream>
@ -91,6 +92,7 @@ bool show_intro_part(display &disp, const config& part,
}
CKey key;
bool lang_rtl = current_language_rtl();
gui::button next_button(video,_("Next") + std::string(">>>"));
gui::button skip_button(video,_("Skip"));
@ -240,6 +242,8 @@ bool show_intro_part(display &disp, const config& part,
update_rect(textx, texty, total_size.w, total_size.h);
}
if(lang_rtl)
textx += max_width;
int xpos = textx, ypos = texty;
//the maximum position that text can reach before wrapping
@ -257,6 +261,8 @@ bool show_intro_part(display &disp, const config& part,
// FIXME: this is broken: it does not take kerning into account.
std::string tmp;
tmp.append(itor.substr().first, itor.substr().second);
if(lang_rtl)
xpos -= font::line_width(tmp, font::SIZE_PLUS);
const SDL_Rect rect = font::draw_text(&video,
screen_area(),font::SIZE_PLUS,
font::NORMAL_COLOUR,tmp,xpos,ypos,
@ -264,7 +270,8 @@ bool show_intro_part(display &disp, const config& part,
if(rect.h > height)
height = rect.h;
xpos += rect.w;
if(!lang_rtl)
xpos += rect.w;
update_rect(rect);
++itor;

View File

@ -45,6 +45,16 @@ std::string languagedef_name (const language_def& def)
return def.language;
}
bool languagedef_rtl (const language_def& def)
{
return def.rtl;
}
bool current_language_rtl()
{
return get_language().rtl;
}
bool languagedef_lessthan_p (const language_def& def1, const language_def& def2)
{
return (def1.language < def2.language);
@ -89,11 +99,13 @@ bool load_language_list()
}
known_languages.clear();
known_languages.push_back(language_def("", t_string(N_("System default language"), "wesnoth")));
known_languages.push_back(
language_def("", t_string(N_("System default language"), "wesnoth"), "ltr"));
config::const_child_itors langs = cfg.child_range("locale");
for(;langs.first != langs.second; ++langs.first) {
known_languages.push_back(language_def((**langs.first)["locale"], (**langs.first)["name"]));
known_languages.push_back(
language_def((**langs.first)["locale"], (**langs.first)["name"], (**langs.first)["dir"]));
}
return true;

View File

@ -28,14 +28,17 @@ class config;
struct language_def
{
language_def() {}
language_def(const std::string& name, const t_string& lang) : localename(name), language(lang)
language_def(const std::string& name, const t_string& lang, const std::string& dir) :
localename(name), language(lang), rtl(dir == "rtl")
{}
std::string localename;
t_string language;
bool rtl; // A right to left language? (e.g: Hebrew)
bool operator== (const language_def&) const;
};
std::string languagedef_name (const language_def& def);
bool languagedef_rtl (const language_def& def);
bool languagedef_lessthan_p (const language_def& def1, const language_def& def2);
struct symbol_table
@ -61,6 +64,7 @@ bool set_language(const language_def& locale);
//function which returns the name of the language currently used
const language_def& get_language();
bool current_language_rtl();
//function which attempts to query and return the locale on the system
const language_def& get_locale();