annotate mde/lookup/Translation.d @ 134:7ababdf97748

Moved mde.setup.paths to mde.file.paths and paths.mdeReader to mde.file.mergetag.Reader.MTMultiReader.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 29 Jan 2009 14:59:45 +0000
parents 41582439a42b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
1 /* LICENSE BLOCK
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
2 Part of mde: a Modular D game-oriented Engine
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
4
26
611f7b9063c6 Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 24
diff changeset
5 This program is free software: you can redistribute it and/or modify it under the terms
611f7b9063c6 Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 24
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
611f7b9063c6 Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 24
diff changeset
7 version 2 of the License, or (at your option) any later version.
17
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
8
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
11 See the GNU General Public License for more details.
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
12
26
611f7b9063c6 Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 24
diff changeset
13 You should have received a copy of the GNU General Public License
611f7b9063c6 Changed the licensing and removed a few dead files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 24
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
63
66d555da083e Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 26
diff changeset
15 /** Translation − internationalization module for translating strings
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
16 *
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 * The idea behind this module is a class which, when asked to load symbols for a particular module/
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18 * package/part of the program, will load internationalized names and optional descriptions for each
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
19 * symbol needing translation. No support for non-left-to-right scripts is currently planned, and
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
20 * this module is currently limited to translations, although support for different date formats,
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
21 * etc. could potentially be added later.
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
22 *
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
23 * Code symbols are used as identifiers for each name and its optional description. The code symbol
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
24 * will be used as a fallback in the case no entry exists, however it is not intended to provide the
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
25 * string for the default language (a "translation" should be used for the default language).
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
26 *
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
27 * Each locale may specify dependant locales/sections which will be loaded and merged in to the
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
28 * database, to cover for symbols with a missing entry. Sections are loaded in the order specified,
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
29 * with each section's sub-dependancies loaded before continuing with the next top-level dependancy.
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
30 * A list of loaded sections is used to prevent any locale/section from being loaded twice, and thus
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
31 * allow circular dependancies.
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
32 *
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
33 * In order that translated strings get updated correctly to reflect changes, each entry carries a
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
34 * version number. If, for any entry, a translation exists with a higher version number, that entry
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
35 * is out of date. A tool should be made for checking for out of date entries to take advantage of
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
36 * this feature. Of course, out of date entries are still valid for use.
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
37 */
63
66d555da083e Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 26
diff changeset
38 module mde.lookup.Translation;
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
39
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
40 import mde.lookup.Options;
134
7ababdf97748 Moved mde.setup.paths to mde.file.paths and paths.mdeReader to mde.file.mergetag.Reader.MTMultiReader.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 128
diff changeset
41 import mde.file.paths;
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
42 import mde.exception;
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
43
81
d8fccaa45d5f Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 79
diff changeset
44 import mde.file.mergetag.DataSet;
d8fccaa45d5f Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 79
diff changeset
45 import mde.file.mergetag.Reader;
d8fccaa45d5f Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 79
diff changeset
46 import mde.file.mergetag.exception;
d8fccaa45d5f Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 79
diff changeset
47 import mde.file.deserialize;
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
48
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
49 import tango.util.log.Log : Log, Logger;
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
50
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
51 /** The translation class
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
52 *
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
53 * See module description for details.
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
54 *
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
55 * Encoding used is UTF-8.
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
56 */
63
66d555da083e Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 26
diff changeset
57 class Translation : IDataSection
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
58 {
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
59 /** Load the translation for the requested module/package/...
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
60 *
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
61 * Options (mde.options) must have been loaded before this is run.
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
62 *
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
63 * Params:
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
64 * name The module/package/... to load strings for.
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
65 *
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
66 * Throws:
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
67 * If no localization exists for this name and the current locale (or any locale to be chain-
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
68 * loaded), or an error occurs while loading the database, a L10nLoadException will be thrown.
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
69 */
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
70 static {
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
71 /** Get Translation instance for _section section.
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
72 *
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
73 * On the first call, loads all Translation sections.
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
74 *
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
75 * These are loaded from data/L10n/locale.mtt where locale is the current locale, as well
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
76 * as any files named for locales specified in the header tag <char[][]|depends=[...]>.
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
77 *
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
78 * On errors, a message is logged and the function continues, likely resulting in some
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
79 * symbol names being untranslated. */
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
80 Translation get (char[] section) {
110
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
81 if (sections is null || loadedL10n !is miscOpts.L10n()) {
127
3328c6fb77ca 2 fixes for ldc - not that I was able to compile anyway (x86_64).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
82 if (sections.length) { // Clear entries hash-map, but re-use classes
110
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
83 foreach (s; sections)
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
84 s.entries = null;
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
85 }
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
86 loadedL10n = miscOpts.L10n();
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
87 debug logger.trace ("Loading L10n: "~loadedL10n);
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
88 char[][] files = [loadedL10n]; // initial locale plus dependencies
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
89 size_t read = 0; // index in files of next file to read
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
90 while (read < files.length) {
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
91 try {
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
92 IReader reader = dataDir.makeMTReader ("L10n/"~files[read++], PRIORITY.HIGH_LOW, null, true);
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
93 assert (reader.dataset.header);
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
94 auto dp = "depends" in reader.dataset.header._charAA;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
95 if (dp) { // append, making sure no duplicates are inserted
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
96 f1: foreach (dep; *dp) {
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
97 foreach (f; files)
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
98 if (f == dep)
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
99 continue f1;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
100 files ~= dep;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
101 }
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
102 }
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
103 reader.dataSecCreator = delegate IDataSection(ID sec) {
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
104 auto p = sec in sections;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
105 if (p) return *p;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
106 return new Translation (sec);
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
107 };
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
108 reader.read;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
109 } catch (MTException e) {
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
110 logger.error ("Mergetag exception occurred:");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
111 logger.error (e.msg);
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
112 }
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
113 }
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
114 }
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
115 auto p = section in sections;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
116 if (p is null) {
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
117 logger.warn ("Section "~section ~ " not found in files; strings will not be translated.");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
118 return new Translation (section);
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
119 }
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
120 return *p;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
121 }
110
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
122 private Translation[char[]] sections;
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
123 private char[] loadedL10n; // reload if different
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
124 }
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
125
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
126 final char[] section; // ONLY used to log an error message
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
127
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
128 alias entry opCall; /// Convenience alias
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
129
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
130 /** Get the translation for the given identifier.
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
131 * If no entry exists, the identifier will be returned.
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
132 *
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
133 * Optionally, the description can be returned. */
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
134 char[] entry (char[] id) {
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
135 Entry* p = id in entries;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
136 if (p) {
79
61ea26abe4dd Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
137 return p.name;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
138 } else {
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
139 return id;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
140 }
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
141 }
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
142 /** ditto */
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
143 char[] entry (char[] id, out char[] description) {
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
144 Entry* p = id in entries;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
145 if (p) {
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
146 description = p.desc;
79
61ea26abe4dd Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
147 return p.name;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
148 } else {
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
149 return id;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
150 }
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
151 }
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
152
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
153 /** Alternative usage: return a Translation.Entry struct. */
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
154 Entry getStruct (char[] id) {
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
155 Entry* p = id in entries;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
156 if (p) {
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
157 return *p;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
158 } else {
128
41582439a42b Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 127
diff changeset
159 logger.warn ("Unable to find translation for {} in {}", id, section);
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
160 Entry ret;
79
61ea26abe4dd Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
161 ret.name = id;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
162 return ret;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
163 }
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
164 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
165
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
166 static this() {
63
66d555da083e Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 26
diff changeset
167 logger = Log.getLogger ("mde.lookup.Translation");
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
168 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
169
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
170 /* Mergetag functionality.
110
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
171 *
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 107
diff changeset
172 * Merge tags in to entries, prefering existing values. */
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
173 void addTag (char[] tp, ID id, char[] dt) {
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
174 if (tp == "entry") {
79
61ea26abe4dd Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
175 // If the tag already exists, don't replace it
61ea26abe4dd Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
176 if (cast(char[]) id in entries) return;
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
177
79
61ea26abe4dd Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
178 Entry entry = deserialize!(Entry) (dt);
61ea26abe4dd Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
179 if (entry.name is null) { // This tag is invalid; ignore it
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
180 logger.error ("In L10n/*.mtt section "~section~": tag with ID "~cast(char[])id~" has no data");
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
181 return;
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
182 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
183 entries[cast(char[]) id] = entry;
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
184 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
185 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
186
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
187 // This class is read-only and has no need of being saved.
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
188 void writeAll (ItemDelg) {}
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
189
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
190 /** This struct is used to store each translation entry.
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
191 *
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
192 * Note that although each entry also has a version field, this is not loaded for general use.
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
193 */
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
194 struct Entry {
79
61ea26abe4dd Moved mde/mergetag/parse/parse(To/From) to mde/mergetag/(de)serialize. Implemented (de)serialization of structs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
195 char[] name; // The translated string
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
196 char[] desc; // An optional description
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
197 }
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
198
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
199 private:
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
200 /* Sets name and ensures only Translation's static functions can create instances. */
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
201 this (char[] n) {
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
202 section = n;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
203 sections[n] = this;
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
204 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
205
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
206 //BEGIN Data
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
207 static Logger logger;
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
208
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
209 Entry[char[]] entries; // all entries
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
210 //END Data
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
211
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
212 debug (mdeUnitTest) unittest {
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
213 // Relies on files in unittest/data/L10n: locale-x.mtt for x in 1..4
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
214
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
215 // Hack a specific locale. Also to allow unittest to run without init.
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
216 StringContent realL10n = miscOpts.L10n;
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
217 miscOpts.L10n = new StringContent ("L10n", "locale-1");
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
218
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
219 // Struct tests
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
220 Translation t = get ("section-2");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
221 Entry e = t.getStruct ("entry-1");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
222 assert (e.name == "Test 1");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
223 assert (e.desc == "Description");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
224 e = t.getStruct ("entry-2");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
225 assert (e.name == "Test 2");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
226 assert (e.desc is null);
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
227
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
228 // Dependency tests. Priority should be 1,2,3,4 (entries should come from first file in list that they appear in).
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
229 t = get ("section-1");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
230 char[] d = "1";
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
231 assert (t.entry ("file-1", d) == "locale-1");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
232 assert (d is null);
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
233 assert (t.entry ("file-2", d) == "locale-2");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
234 assert (d == "desc2");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
235 assert (t.entry ("file-3") == "locale-3");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
236 assert (t.entry ("file-4") == "locale-4");
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
237
19
db0b48f02b69 Minor changes regarding logging and unittests.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 17
diff changeset
238 // Restore
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 98
diff changeset
239 delete miscOpts.L10n;
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 98
diff changeset
240 miscOpts.L10n = realL10n;
107
20f7d813bb0f Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
241 sections = null;
19
db0b48f02b69 Minor changes regarding logging and unittests.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 17
diff changeset
242
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
243 logger.info ("Unittest complete.");
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
244 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
245 }