Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Locales

Part of TutorialAdvanced

Description

An example using version that shows how to use version to compile different executables for different languages.

Example

version(English)  
{
    const string salutation = "Hi";
    const string negative = "No";
}

version(Espanol) 
{
    const string salutation = "Hola";
    const string negative = "No";
} 

version(Francais)
{
    const string salutation = "Bonjour";
    const string negative = "Non";
} 

version(Deutsch)  
{
    const string salutation = "Hallo";
    const string negative = "Nein";
} 

int main()
{ 
    writef("%s\n", salutation);
    return 0;
}

Compiling Tips

Compile for the English locale:

dmd locales.d -version=English

Compile for the German locale:

dmd locales.d -version=Deutsch

More Information

For more examples that use version, see VersioningCategory.

Source

Link http://jcc_7.tripod.com/d/tutor/locales1.html
Author jcc7
Date October 6, 2003