Uses _("LANGUAGE") instead of _("WinLangID") in localized resource dll names.
When loading a script or font texture "file.ext", tries to load the file "file_LL.ext" first where LL is the value _("LANGUAGE").pull/3/head
parent
250fcca9cc
commit
9375a9f5bf
|
@ -73,6 +73,8 @@ src/celestia/winssbrowser.cpp
|
|||
src/celestia/winstarbrowser.cpp
|
||||
src/celestia/wintime.cpp
|
||||
|
||||
src/celutil/util.cpp
|
||||
|
||||
# Config
|
||||
#po/celestia.cfg.pot
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ foreach my $po (@po_files) {
|
|||
print OUT $res;
|
||||
close OUT;
|
||||
system qq{rc /l $lang{$lang}[0] /d "NDEBUG" /fo $dir\\..\\src\\celestia\\celestia_$lang.res /i "$dir\\..\\src\\celestia\\res" $dir\\..\\src\\celestia\\res\\celestia_$lang.rc};
|
||||
system qq{link /nologo /noentry /dll /machine:I386 /out:$dir\\..\\locale\\res$lang{$lang}[0].dll $dir\\..\\src\\celestia\\celestia_$lang.res};
|
||||
system qq{link /nologo /noentry /dll /machine:I386 /out:$dir\\..\\locale\\res_$lang.dll $dir\\..\\src\\celestia\\celestia_$lang.res};
|
||||
system qq{msgfmt $dir\\$lang.po -o $dir\\..\\locale\\$lang\\LC_MESSAGES\\celestia.mo};
|
||||
}
|
||||
|
||||
|
|
|
@ -509,11 +509,12 @@ void CelestiaCore::runScript(CommandSequence* script)
|
|||
void CelestiaCore::runScript(const string& filename)
|
||||
{
|
||||
cancelScript();
|
||||
ContentType type = DetermineFileType(filename);
|
||||
string localeFilename = LocaleFilename(filename);
|
||||
ContentType type = DetermineFileType(localeFilename);
|
||||
|
||||
if (type == Content_CelestiaLegacyScript)
|
||||
{
|
||||
ifstream scriptfile(filename.c_str());
|
||||
ifstream scriptfile(localeFilename.c_str());
|
||||
if (!scriptfile.good())
|
||||
{
|
||||
if (alerter != NULL)
|
||||
|
@ -546,11 +547,11 @@ void CelestiaCore::runScript(const string& filename)
|
|||
#ifdef CELX
|
||||
else if (type == Content_CelestiaScript)
|
||||
{
|
||||
ifstream scriptfile(filename.c_str());
|
||||
ifstream scriptfile(localeFilename.c_str());
|
||||
if (!scriptfile.good())
|
||||
{
|
||||
char errMsg[1024];
|
||||
sprintf(errMsg, _("Error opening script '%s'"), filename.c_str());
|
||||
sprintf(errMsg, _("Error opening script '%s'"), localeFilename.c_str());
|
||||
if (alerter != NULL)
|
||||
alerter->fatalError(errMsg);
|
||||
else
|
||||
|
@ -563,7 +564,7 @@ void CelestiaCore::runScript(const string& filename)
|
|||
celxScript->init(this);
|
||||
}
|
||||
|
||||
int status = celxScript->loadScript(scriptfile, filename);
|
||||
int status = celxScript->loadScript(scriptfile, localeFilename);
|
||||
if (status != 0)
|
||||
{
|
||||
string errMsg = celxScript->getErrorMessage();
|
||||
|
@ -2622,11 +2623,11 @@ static void displayDistance(Overlay& overlay, double distance)
|
|||
}
|
||||
else if (abs(distance) >= astro::AUtoLightYears(1000.0f))
|
||||
{
|
||||
units = "ly";
|
||||
units = _("ly");
|
||||
}
|
||||
else if (abs(distance) >= astro::kilometersToLightYears(10000000.0))
|
||||
{
|
||||
units = "au";
|
||||
units = _("au");
|
||||
distance = astro::lightYearsToAU(distance);
|
||||
}
|
||||
else if (abs(distance) > astro::kilometersToLightYears(1.0f))
|
||||
|
|
|
@ -2989,7 +2989,7 @@ public:
|
|||
|
||||
virtual void update(const string& filename)
|
||||
{
|
||||
splash->setMessage(string("Loading: ") + filename);
|
||||
splash->setMessage(string(_("Loading: ")) + filename);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3147,7 +3147,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
|||
|
||||
// Loading localized resources
|
||||
char res[255];
|
||||
sprintf(res, "locale\\res%s.dll", _("WinLangID"));
|
||||
sprintf(res, "locale\\res_%s.dll", _("LANGUAGE"));
|
||||
int langID;
|
||||
sscanf(_("WinLangID"), "%x", &langID);
|
||||
SetThreadLocale(langID);
|
||||
|
@ -3720,7 +3720,7 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd,
|
|||
|
||||
if (!urlString.substr(0,4).compare("cel:"))
|
||||
{
|
||||
appCore->flash("Loading URL");
|
||||
appCore->flash(_("Loading URL"));
|
||||
appCore->goToUrl(urlString);
|
||||
}
|
||||
else if (DetermineFileType(urlString) == Content_CelestiaScript)
|
||||
|
@ -3732,7 +3732,7 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd,
|
|||
ifstream scriptfile(urlString.c_str());
|
||||
if (!scriptfile.good())
|
||||
{
|
||||
appCore->flash("Error opening script");
|
||||
appCore->flash(_("Error opening script"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3751,12 +3751,12 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd,
|
|||
}
|
||||
else
|
||||
{
|
||||
appCore->flash("Error loading script");
|
||||
appCore->flash(_("Error loading script"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
appCore->flash("Running script");
|
||||
appCore->flash(_("Running script"));
|
||||
appCore->runScript(script);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <celutil/debug.h>
|
||||
#include <celutil/bytes.h>
|
||||
#include <celutil/utf8.h>
|
||||
#include <celutil/util.h>
|
||||
#include <celengine/gl.h>
|
||||
#include "texturefont.h"
|
||||
|
||||
|
@ -437,7 +438,8 @@ TextureFont* TextureFont::load(istream& in)
|
|||
|
||||
TextureFont* LoadTextureFont(const string& filename)
|
||||
{
|
||||
ifstream in(filename.c_str(), ios::in | ios::binary);
|
||||
string localeFilename = LocaleFilename(filename);
|
||||
ifstream in(localeFilename.c_str(), ios::in | ios::binary);
|
||||
if (!in.good())
|
||||
{
|
||||
DPRINTF(0, "Could not open font file %s\n", filename.c_str());
|
||||
|
|
|
@ -22,7 +22,7 @@ OBJS=\
|
|||
|
||||
TARGETLIB = cel_txf.lib
|
||||
|
||||
INCLUDEDIRS=/I ..
|
||||
INCLUDEDIRS=/I .. /I ../../inc/libintl
|
||||
|
||||
!IF "$(CFG)" == "Release"
|
||||
CPP=cl.exe
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
// of the License, or (at your option) any later version.
|
||||
|
||||
#include "util.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -57,3 +59,24 @@ bool CompareIgnoringCasePredicate::operator()(const string& s1,
|
|||
{
|
||||
return compareIgnoringCase(s1, s2) < 0;
|
||||
}
|
||||
|
||||
|
||||
string LocaleFilename(const string & filename)
|
||||
{
|
||||
string localeFilename;
|
||||
struct stat filestat;
|
||||
string::size_type pos;
|
||||
|
||||
if ((pos = filename.rfind('.')) != string::npos)
|
||||
{
|
||||
localeFilename = filename.substr(0, pos) + '_' + _("LANGUAGE") + filename.substr(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
localeFilename = filename + '_' + _("LANGUAGE");
|
||||
}
|
||||
if (stat(localeFilename.c_str(), &filestat) != 0) {
|
||||
localeFilename = filename;
|
||||
}
|
||||
return localeFilename;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
extern int compareIgnoringCase(const std::string& s1, const std::string& s2);
|
||||
extern int compareIgnoringCase(const std::string& s1, const std::string& s2, int n);
|
||||
extern std::string LocaleFilename(const std::string & filename);
|
||||
|
||||
class CompareIgnoringCasePredicate : public std::binary_function<std::string, std::string, bool>
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue