From e75f63e0385c0cba8038233d4ad3a1cbf525fe31 Mon Sep 17 00:00:00 2001 From: twanvl Date: Sun, 18 Mar 2007 15:23:19 +0000 Subject: [PATCH] fixed bug with package specific localization. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@214 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/locale.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/data/locale.cpp b/src/data/locale.cpp index b9e9f410..cc5dd32f 100644 --- a/src/data/locale.cpp +++ b/src/data/locale.cpp @@ -72,27 +72,39 @@ String tr(LocaleCategory cat, const String& key) { String tr(const Game& g, const String& key) { if (!the_locale) return key; // no locale loaded (yet) - return the_locale->game_translations[g.name()]->tr(key); + SubLocaleP loc = the_locale->game_translations[g.name()]; + if (!loc) return key; // no information on this game + return loc->tr(key); } String tr(const StyleSheet& s, const String& key) { if (!the_locale) return key; // no locale loaded (yet) - return the_locale->stylesheet_translations[s.name()]->tr(key); + SubLocaleP loc = the_locale->stylesheet_translations[s.name()]; + if (!loc) return key; // no information on this stylesheet + return loc->tr(key); } String tr(const SymbolFont& f, const String& key) { if (!the_locale) return key; // no locale loaded (yet) - return the_locale->symbol_font_translations[f.name()]->tr(key); + SubLocaleP loc = the_locale->symbol_font_translations[f.name()]; + if (!loc) return key; // no information on this symbol font + return loc->tr(key); } String tr(const Game& g, const String& key, const String& def) { if (!the_locale) return key; // no locale loaded (yet) - return the_locale->game_translations[g.name()]->tr(key, def); + SubLocaleP loc = the_locale->game_translations[g.name()]; + if (!loc) return key; // no information on this game + return loc->tr(key, def); } String tr(const StyleSheet& s, const String& key, const String& def) { if (!the_locale) return key; // no locale loaded (yet) - return the_locale->stylesheet_translations[s.name()]->tr(key, def); + SubLocaleP loc = the_locale->stylesheet_translations[s.name()]; + if (!loc) return key; // no information on this stylesheet + return loc->tr(key, def); } String tr(const SymbolFont& f, const String& key, const String& def) { if (!the_locale) return key; // no locale loaded (yet) - return the_locale->symbol_font_translations[f.name()]->tr(key, def); + SubLocaleP loc = the_locale->symbol_font_translations[f.name()]; + if (!loc) return key; // no information on this symbol font + return loc->tr(key, def); }