Description

Localization for D language

Package Information

Version0.1.7 (2016-Mar-17)
Repositoryhttps://github.com/anton-dutov/l10n-d
LicensePUBLIC DOMAIN
CopyrightCopyright © 2016, Anton Dutov
AuthorsAnton Dutov
Registered byAnton Dutov
Dependenciesnone

Installation

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

dub.json
dub.sdl

Readme

Localization for D language

Concept

Autogenerated code from unicode CLDR 28 (Generation tool will be published soon)

See examples folder

TODO:

  • (DONE) Localized languages
  • (DONE) Localized language scripts
  • (DONE) Localized territories
  • (DONE) Localized countries
  • Locale Scripts and Territory support ("es_mx" etc.)
  • (PARTIAL) Numbers to string using locale format
  • Numbers from string using locale format
  • (PARTIAL) Date/Time to string using locale format
  • Date/time from string using locale format
  • Numbers plurals
  • Measurement systems conversions ?
  • docs
  • unittests
  • some other ideas

Resources:

Usage:

import std.stdio;

import l10n;

void main()
{
    // By string
    auto en = Locale("en"); // Language.english

    // By enum
    auto ru = Locale(Language.russian);

    // String case no matter
    auto de = Locale("De");

    // Languages
    writefln("Russian in English: %s", en.asString(Language.english));
    writefln("Frech in German: %s", de.asString(toLanguage("fr")));
    writefln("Tajik in French: %s", Locale("fr").asString(Language.tajik));

    // Territory (Territory enum includes Countries)
    writefln("World in Russian: %s", ru.asString(Territory.world));
    writefln("Russia in English: %s", en.asString(Territory.russia));
    writefln("Germany in French: %s", Locale("fr").asString(Country.germany));

    // Number separated by locale specified group symbol
    auto sample = 1234567;
    writefln("English: %s -> %s", sample, en.asString(sample));
    writefln("Russian: %s -> %s", sample, ru.asString(sample));
    writefln("German:  %s -> %s", sample, de.asString(sample));

    // Dates
    auto someDate = Date(2016, Month.feb, 29);
    writefln("English Date(full): %s -> %s", someDate, en.asString(someDate, DateFormat.full));
    writefln("English Date(long): %s -> %s", someDate, en.asString(someDate, DateFormat.long_));
    writefln("English Date(medium): %s -> %s", someDate, en.asString(someDate, DateFormat.medium));
    writefln("English Date(short): %s -> %s", someDate, en.asString(someDate, DateFormat.short_));

    writefln("Russian Date(full): %s -> %s", someDate, ru.asString(someDate, DateFormat.full));
    writefln("Russian Date(long): %s -> %s", someDate, ru.asString(someDate, DateFormat.long_));
    writefln("Russian Date(medium): %s -> %s", someDate, ru.asString(someDate, DateFormat.medium));
    writefln("Russian Date(short): %s -> %s", someDate, ru.asString(someDate, DateFormat.short_));

    writefln("German Date(full): %s -> %s", someDate, de.asString(someDate, DateFormat.full));
    writefln("German Date(long): %s -> %s", someDate, de.asString(someDate, DateFormat.long_));
    writefln("German Date(medium): %s -> %s", someDate, de.asString(someDate, DateFormat.medium));
    writefln("German Date(short): %s -> %s", someDate, de.asString(someDate, DateFormat.short_));
}

Output:

Russian in English: English
Frech in German: Französisch
Tajik in French: tadjik

World in Russian: Мир
Russia in English: Russia
Germany in French: Allemagne

English: 1234567 -> 1,234,567
Russian: 1234567 -> 1 234 567
German:  1234567 -> 1.234.567

English Date(full): 2016-Feb-29 -> Monday, February 29, 2016
English Date(long): 2016-Feb-29 -> February 29, 2016
English Date(medium): 2016-Feb-29 -> Feb 29, 2016
English Date(short): 2016-Feb-29 -> 2/29/16

Russian Date(full): 2016-Feb-29 -> понедельник, 29 февраля 2016 г.
Russian Date(long): 2016-Feb-29 -> 29 февраля 2016 г.
Russian Date(medium): 2016-Feb-29 -> 29 февр. 2016 г.
Russian Date(short): 2016-Feb-29 -> 29.02.16

German Date(full): 2016-Feb-29 -> Montag, 29. Februar 2016
German Date(long): 2016-Feb-29 -> 29. Februar 2016
German Date(medium): 2016-Feb-29 -> 29.02.2016
German Date(short): 2016-Feb-29 -> 29.02.16

Available versions

0.1.7 0.1.5 0.1.0 0.0.5 0.0.4 0.0.3 0.0.2 0.0.1 ~master