2 question: internationalization and serialization
Lloyd Dupont
ld-REMOVE at galador.net
Wed Jun 1 06:50:11 PDT 2011
I found half the answer to question 1 (internationalization)
I still dunno how to get the local language (I guess I'll have to find the
win32 method which return it)
but I found how to do the resources!! (using mixins)
what do you think?
=== D file ===
string[string][string] lang;
mixin(import("lang.txt"));
mixin(import("lang.fr.txt"));
=== lang.txt ==
lang["en"] = [
"start" : "start",
"quit" : "quit",
];
=== lang.fr.txt
lang["fr"] = [
"start" : "demarrer",
"quit" : "quitter",
];
============
"Lloyd Dupont" wrote in message news:is5cs7$128p$1 at digitalmars.com...
Hi I'm a newbie with big ambitions! (Sorry, got spoiled by C#)
Anyhow I'm toying with a D learning project and there are 2 .NET feature
that will be welcome in this D project:
1. internationalization.
the app will contains a bunch of simple UIs and I was wondering how I would
go on internationalizing the application. I.e. embed multiple "resource" for
different languages in the EXE and show the appropriate ones for the target
/ running computer
2. I'd like a part of my library (in progress) to read / write some
arbitrary settings. I was thing to use something akin to the
DataContractSerialization we have in .NET
where I could define a few classes with attribute
[DataContract]
class Root
{
[DataMember]
public int Prop1 { get; set; }
[DataMember]
public B PropB { get; set; }
}
[DataContract]
class B
{
[DataMember]
public string Name { get; set; }
}
a reader / writer class can turn this class (using the atributes) into text
(XML, JSON, I don't care) and back from text into object instance
How would I implement something similar in D? Is there already a library
doing it?
More information about the Digitalmars-d-learn
mailing list