www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - 2 question: internationalization and serialization

reply "Lloyd Dupont" <ld-REMOVE galador.net> writes:


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? 
Jun 01 2011
next sibling parent "Lloyd Dupont" <ld-REMOVE galador.net> writes:
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 digitalmars.com...



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? 
Jun 01 2011
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2011-06-01 14:51, Lloyd Dupont wrote:


 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?
For the serialization you could have a look at Orange: http://www.dsource.org/projects/orange Don't know if it works with the latest compilers, it's been a while since I updated the code. I'm also in the middle of complete rewrite of the library. At lease you can perhaps find some ideas. -- /Jacob Carlborg
Jun 01 2011
next sibling parent "Lloyd Dupont" <ld-REMOVE galador.net> writes:
Awesome! WIll take a look at it tonight!
Thanks for the link! :)

"Jacob Carlborg"  wrote in message news:is5msf$1lt0$1 digitalmars.com... 

On 2011-06-01 14:51, Lloyd Dupont wrote:


 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?
For the serialization you could have a look at Orange: http://www.dsource.org/projects/orange Don't know if it works with the latest compilers, it's been a while since I updated the code. I'm also in the middle of complete rewrite of the library. At lease you can perhaps find some ideas. -- /Jacob Carlborg
Jun 01 2011
prev sibling parent reply "Lloyd Dupont" <ld-REMOVE galador.net> writes:
I'm looking!
mm... how do I download the repository!?! :~


"Jacob Carlborg"  wrote in message news:is5msf$1lt0$1 digitalmars.com... 

For the serialization you could have a look at Orange: 
http://www.dsource.org/projects/orange
Don't know if it works with the latest compilers, it's been a while 
since I updated the code. I'm also in the middle of complete rewrite of 
the library. At lease you can perhaps find some ideas.

-- 
/Jacob Carlborg
Jun 01 2011
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
You need mercurial and do 'hg clone
http://hg.dsource.org/projects/orange' from the command line.
Jun 01 2011
parent =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Andrej Mitrovic wrote:
 You need mercurial and do 'hg clone
 http://hg.dsource.org/projects/orange' from the command line.
Or you can just click on the "zip", "gz" or "bz2" button at the top of http://hg.dsource.org/projects/orange if you do not care about the history. Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Jun 01 2011