Description

Tool for text internationalization inspired from GNU gettext.

Package Information

Version1.0.1 (2013-Oct-12)
Homepage http://github.com/NCrashed/dtext
Repository https://github.com/NCrashed/dtext
LicenseBoost Software License - Version 1.0
CopyrightCopyright © 2013, Gushcha Anton
AuthorsNCrashed - Gushcha Anton
Registered byAnton Gushcha
Dependencies none

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

Library provides functions to handle localization. Translated string is searched in special files with .lang extention by exact matching with original string.

Lang files are loaded in memory at program start up from current directory. Additional localizations can be loaded with loadLocaleFile function.

Example:

import std.stdio, std.opt, dtext;

void main(string[] args) 
{
  string locale;
  getopt(args,
    "l|lang", &locale);

  defaultLocale = locale;
  writeln(_("Hello, world!")); \\ or use getdtext
}

If text for translation cannot be found in specified locale name, the text will be saved and written down to a special fuzzy texts file at program shutdown. That should help to add new localization fast and without program recompilation.

TODO:

  • Load localization files on demand;
  • Add ability to unload unused locales;
  • Add ability to bind texts for arbitrary values (оbjects names, descriptions).

Available versions

1.0.1 1.0.0 ~master