www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - i18n

reply xancorreu <xancorreu gmail.com> writes:
Hi,

Is there any way for localizate and internationalizate messages?
I were shocked if D has something like Fantom 
[http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty 
ugly ;-)


If not, any plannings?

Thanks,
Xan.
Feb 02 2012
next sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
On 02/02/2012 18:48, xancorreu wrote:
 Hi,

 Is there any way for localizate and internationalizate messages?
 I were shocked if D has something like Fantom
 [http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty ugly ;-)
Is this just about supporting different human languages in your app? You can put the strings output by your app in a separate file or in a section within the code file to which they apply, and use either version blocks (compile-time) or arrays (run-time) to choose between them. Under Windows, you can use a stringtable resource. It's possible to make resources language-specific, but I don't know how. Stewart.
Feb 02 2012
next sibling parent xancorreu <xancorreu gmail.com> writes:
Al 02/02/12 20:40, En/na Stewart Gordon ha escrit:
 On 02/02/2012 18:48, xancorreu wrote:
 Hi,

 Is there any way for localizate and internationalizate messages?
 I were shocked if D has something like Fantom
 [http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty 
 ugly ;-)
Is this just about supporting different human languages in your app?
This is by displaying different messages depending of system locale of the user.
 Stewart.
Feb 03 2012
prev sibling parent reply "Kagamin" <spam here.lot> writes:
On Thursday, 2 February 2012 at 19:40:14 UTC, Stewart Gordon 
wrote:
 Under Windows, you can use a stringtable resource.  It's 
 possible to make resources language-specific, but I don't know 
 how.
With LANGUAGE statement? http://msdn.microsoft.com/en-us/library/windows/desktop/aa381019%28v=vs.85%29.aspx
Feb 04 2012
parent "Kagamin" <spam here.lot> writes:
Also 
http://msdn.microsoft.com/en-us/library/windows/desktop/aa381050%28v=vs.85%29.aspx
Feb 04 2012
prev sibling next sibling parent reply "Alex_Dovhal" <alex_dovhal yahoo.com> writes:
"xancorreu" <xancorreu gmail.com> wrote:
 Hi,

 Is there any way for localizate and internationalizate messages?
 I were shocked if D has something like Fantom 
 [http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty ugly 
 ;-)
I use small D script to internationalize Delphi projects. It's not perfect, but it's simple and easy to modify for one's needs. https://gist.github.com/1728860
Feb 03 2012
parent reply xancorreu <xancorreu gmail.com> writes:
Al 03/02/12 09:09, En/na Alex_Dovhal ha escrit:
 "xancorreu"<xancorreu gmail.com>  wrote:
 Hi,

 Is there any way for localizate and internationalizate messages?
 I were shocked if D has something like Fantom
 [http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty ugly
 ;-)
I use small D script to internationalize Delphi projects. It's not perfect, but it's simple and easy to modify for one's needs. https://gist.github.com/1728860
Thank you very much for your solution. I deduce so that there is no "official" support for that. If it's, it's a pain. Xan.
Feb 03 2012
parent reply Trass3r <un known.com> writes:
 I deduce so that there is no "official" support for that. If it's, it's  
 a pain.
Pain? Writing such a system can be done in a couple of lines.
Feb 03 2012
next sibling parent xancorreu <xancorreu gmail.com> writes:
Al 03/02/12 18:07, En/na Trass3r ha escrit:
 I deduce so that there is no "official" support for that. If it's, 
 it's a pain.
Pain? Writing such a system can be done in a couple of lines.
How? I don't know how to do that. How to read user current locale? An official version could simplify the things: people should not wrtite their own code.... Xan.
Feb 03 2012
prev sibling next sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Fri, Feb 03, 2012 at 09:03:54PM +0100, xancorreu wrote:
 Al 03/02/12 18:07, En/na Trass3r ha escrit:
I deduce so that there is no "official" support for that. If
it's, it's a pain.
Pain? Writing such a system can be done in a couple of lines.
How? I don't know how to do that. How to read user current locale? An official version could simplify the things: people should not wrtite their own code....
[...] Write your own version and submit it for review/improvement. Then it'll become official. :) T -- For every argument for something, there is always an equal and opposite argument against it. Debates don't give answers, only wounded or inflated egos.
Feb 03 2012
prev sibling parent Mantis <mail.mantis.88 gmail.com> writes:
03.02.2012 22:03, xancorreu пишет:
 Al 03/02/12 18:07, En/na Trass3r ha escrit:
 I deduce so that there is no "official" support for that. If it's, 
 it's a pain.
Pain? Writing such a system can be done in a couple of lines.
How? I don't know how to do that. How to read user current locale? An official version could simplify the things: people should not wrtite their own code.... Xan.
I doubt this is a good argument: "I don't know it, so it should be done for me". Anyway, for windows you probably need to use this function, or related ones: http://msdn.microsoft.com/en-us/library/windows/desktop/dd318136(v=vs.85).aspx I don't know how the thing is done on Unix family systems though, but as usual - Google is your best friend.
Feb 03 2012
prev sibling next sibling parent DNewbie <run3 myopera.com> writes:
You can build multiple versions of you app:
http://dsource.org/projects/tutorials/wiki/LocalesExample


On Thu, Feb 2, 2012, at 07:48 PM, xancorreu wrote:
 Hi,
 
 Is there any way for localizate and internationalizate messages?
 I were shocked if D has something like Fantom 
 [http://fantom.org/doc/docLang/Localization.html]. Gettext is pretty 
 ugly ;-)
 
 
 If not, any plannings?
 
 Thanks,
 Xan.
 
-- D
Feb 03 2012
prev sibling parent DNewbie <run3 myopera.com> writes:
On Fri, Feb 3, 2012, at 09:48 PM, Trass3r wrote:
 Thanks a lot, So I just need to "detect" user locale using.... How to do  
 that?
You can always use the functions you would use in C.
You can see your language id in this page: http://msdn.microsoft.com/en-us/library/dd318693(v=vs.85).aspx Example --------------------------------------------------------- import std.stdio; import std.c.windows.windows; alias DWORD LCID; extern (Windows) LCID GetSystemDefaultLCID(); int main() { LCID lcid = GetSystemDefaultLCID(); printf("GetSystemDefaultLCID = 0x%04X\n", lcid); switch (lcid) { case 0x0409: writeln("United States (US)"); break; case 0x040c: writeln("France (FR)"); break; default: writeln("Unknown"); break; } return 0; } ---------------------------------------------------------
Feb 03 2012