Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » i18n
i18n [message #9707] Fri, 25 May 2007 23:15 Go to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

2 things i found on Linux Gentoo & FreeBSD

i have at the begining of App
SetLanguage(GetSystemLNG());

If i dont have locale on OS set with above invocation of Setlanguage the Format(..) function throws Assert
if I disable above SetLanguage, the Format for such string writes no . or , chars for double value.

Format( value < 0 ? "(%nl)" : "%nl", value);

[Updated on: Fri, 25 May 2007 23:16]

Report message to a moderator

Re: i18n [message #9709 is a reply to message #9707] Sat, 26 May 2007 07:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
This should fix it:

Core/Lang.cpp 130:

#ifdef PLATFORM_POSIX
int GetSystemLNG() {
	static int lang;
	ONCELOCK (
		String s = Environment().Get("LANG", Null);
		lang = LNGFromText(s);
		if(!lang)
			lang = LNG_ENGLISH;
		const char *q = strchr(s, '.');
		if(q)
			lang = SetLNGCharset(lang, CharsetByName(q + 1));
	);
	return lang;
};

#endif


Mirek
Re: i18n [message #9711 is a reply to message #9709] Sat, 26 May 2007 18:01 Go to previous messageGo to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

This will fix the app crash , ie read beoyond the string
But I'm not sure where to search fo lack of "." or "," in double values

#ifdef PLATFORM_POSIX
int GetSystemLNG() {
	static int lang;
	INIT_LOCK (
		String s = Environment().Get("LANG", Null);
		if ( s.GetCount()>4 )
			lang = LNGFromText(s);
		else
			lang = LNG_ENGLISH;
		const char *q = strchr(s, '.');
		if(q)
			lang = SetLNGCharset(lang, CharsetByName(q + 1));
	);
	return lang;
};

#endif
Re: i18n [message #9725 is a reply to message #9711] Mon, 28 May 2007 14:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
WEll, the idea of my fix was the if the language is not recognized, it is set as LNG_ENGLISH. Have you tried that?
Re: i18n [message #9750 is a reply to message #9725] Tue, 29 May 2007 17:36 Go to previous messageGo to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

lang = LNGFromText(s);
if(!lang)

I got app crashed becouse of attempt to read beoyound the string in
LNGFromText(s);

i have s.GetCount() == 0;

so
int LNGFromText(const char *s)
{
int l = 0;
if(IsAlpha(*s)) {

s == NULL , and will fail , Am i right ?
Re: i18n [message #9755 is a reply to message #9750] Tue, 29 May 2007 18:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, no. If s.GetCount() == 0, then *s == '\0'.

Not arguing with the crash, going to test it now Smile

Mirek
Re: i18n [message #9756 is a reply to message #9755] Tue, 29 May 2007 18:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
OK, just tested:

	DUMP(LNGFromText(String()));


and getting 0, no crash, just as expected.

Whatever crashes for you, must be something different...
Re: i18n [message #9758 is a reply to message #9707] Tue, 29 May 2007 18:52 Go to previous messageGo to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

ONCELOCK undefined ...

----- UppCalc ( GUI MAIN GCC DEBUG SHARED DEBUG_FULL BLITZ LINUX ) (9 / 9)
/root/uppsrc/Core/Lang.cpp: In function 'int Upp::GetSystemLNG()':
/root/uppsrc/Core/Lang.cpp:115: error: expected primary-expression before 's'
/root/uppsrc/Core/Lang.cpp:115: error: expected `)' before 's'
/root/uppsrc/Core/Lang.cpp:116: error: 's' was not declared in this scope
/root/uppsrc/Core/Lang.cpp:122: error: expected primary-expression before ')' token
/root/uppsrc/Core/Lang.cpp:122: error: expected `;' before ')' token
Core: 1 file(s) built in (0:04.03), 4038 msecs / file, duration = 4202 msecs, parallelization 0%

There were errors. (0:06.45)


but with INIT_LOCK works

Hoever there are still no . or , in values from double in formated string.
Re: i18n [message #9759 is a reply to message #9758] Tue, 29 May 2007 19:24 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
ONCELOCK: Sorry, should be

ONCELOCK { .... }

(is "( )").
Previous Topic: Adding subclass objects to base class array using AppendPick()
Next Topic: Format of GetSysTime()
Goto Forum:
  


Current Time: Sat Apr 20 13:24:45 CEST 2024

Total time taken to generate the page: 0.02695 seconds