Localizing a D application - best practices?

Chris via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 29 14:47:20 PDT 2014


On Sunday, 28 September 2014 at 21:29:21 UTC, Cliff wrote:
> Coming from the C# world, all of localization we did was based 
> on defining string resource files (XML-formatted source files 
> which were translated into C# classes with named-string 
> accessors by the build process) that would get included in the 
> final application.  For log messages, exception messages 
> (because unhandled exceptions could make it to the user in the 
> case of a bug) and format strings used for the above we would 
> create a string table entry and this file would eventually get 
> localized by the appropriate team.
>
> Is there a recommended pattern for applications in D that wish 
> to do localization?
>
> Thanks.

I don't know. But JSON is very popular in the D community. dub, 
the package manager uses it for configuration files, I use JSON 
for the same purpose in my applications. Although the present 
std.json is not up to current D standards (still?), it is 
perfectly usable. Alternatively you can have a look at vibe.d's 
implementation (http://vibed.org/api/vibe.data.json/) which I use 
in vibe.d apps.

I do not recommend XML, not only because it may be overkill for 
localization, but because the std.xml module should have been put 
down a long time ago. If you do want to use XML, however, you may 
have a look at Adam D. Ruppe's dom.d[1][2].

In the D community JSON is usually preferred to XML.

[1] https://github.com/adamdruppe/HTML-DOM
[2] https://github.com/adamdruppe/arsd


More information about the Digitalmars-d-learn mailing list