From cc6610bbc18a8980a60eb108ec1fbcb7b8f6e9b7 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 6 Jan 2015 23:06:05 +0300 Subject: [PATCH] update docs for i18n --- src/dlangui/core/i18n.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dlangui/core/i18n.d b/src/dlangui/core/i18n.d index ace4263a..42797219 100644 --- a/src/dlangui/core/i18n.d +++ b/src/dlangui/core/i18n.d @@ -36,14 +36,18 @@ import dlangui.core.i18n; // use global i18n object to get translation for string ID dstring translated = i18n.get("STR_FILE_OPEN"); +// as well, you can specify fallback value - to return if translation is not found +dstring translated = i18n.get("STR_FILE_OPEN", "Open..."d); // UIString type can hold either string resource id or dstring raw value. UIString text; -// assign resource id as string +// assign resource id as string (will remove dstring value if it was here) text = "ID_FILE_EXIT"; -// or assign raw value as dstring +// or assign raw value as dstring (will remove id if it was here) text = "some text"d; +// assign both resource id and fallback value - to use if string resource is not found +text = UIString("ID_FILE_EXIT", "Exit"d); // i18n.get() will automatically be invoked when getting UIString value (e.g. using alias this). dstring translated = text;