Mercurial > projects > mde
diff mde/lookup/Translation.d @ 110:6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Gave AContent support for multiple callbacks.
New locale: "en".
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 05 Dec 2008 11:29:39 +0000 |
parents | 20f7d813bb0f |
children | 3328c6fb77ca |
line wrap: on
line diff
--- a/mde/lookup/Translation.d Thu Dec 04 10:32:20 2008 +0000 +++ b/mde/lookup/Translation.d Fri Dec 05 11:29:39 2008 +0000 @@ -78,8 +78,14 @@ * On errors, a message is logged and the function continues, likely resulting in some * symbol names being untranslated. */ Translation get (char[] section) { - if (sections is null) { - char[][] files = [miscOpts.L10n()]; // initial locale plus dependencies + if (sections is null || loadedL10n !is miscOpts.L10n()) { + if (sections) { // Clear entries hash-map, but re-use classes + foreach (s; sections) + s.entries = null; + } + loadedL10n = miscOpts.L10n(); + debug logger.trace ("Loading L10n: "~loadedL10n); + char[][] files = [loadedL10n]; // initial locale plus dependencies size_t read = 0; // index in files of next file to read while (read < files.length) { try { @@ -113,7 +119,8 @@ } return *p; } - Translation[char[]] sections; + private Translation[char[]] sections; + private char[] loadedL10n; // reload if different } final char[] section; // ONLY used to log an error message @@ -160,16 +167,8 @@ } /* Mergetag functionality. - * - * Merge tags in to entries, prefering existing values. - * Replace depends. - * - * User-defined type "entry": - * first two element is string and must exist - * second element is description and is optional - * third element is version and is optional - * no limit on number of elements to allow future extensions - */ + * + * Merge tags in to entries, prefering existing values. */ void addTag (char[] tp, ID id, char[] dt) { if (tp == "entry") { // If the tag already exists, don't replace it @@ -181,8 +180,6 @@ return; } entries[cast(char[]) id] = entry; - } else if (tp == "char[][]") { - if (id == cast(ID)"depends") depends = cast(ID[]) parseTo!(char[][]) (dt); } } @@ -209,8 +206,6 @@ static Logger logger; Entry[char[]] entries; // all entries - - ID[] depends; // dependancy sections (only used while loading) //END Data debug (mdeUnitTest) unittest {