annotate mde/lookup/Translation.d @ 107:20f7d813bb0f

Translation: now has a file for each locale, instead of a file for each section. Items updated; all strings translated. New unittest for Translation; I realised the old one wasn't run anymore. Changed unittest data and conf dirs.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sun, 30 Nov 2008 17:17:56 +0000
parents 42e241e7be3e
children 6acd96f8685f
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;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
41 import mde.setup.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) {
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
81 if (sections 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
82 char[][] files = [miscOpts.L10n()]; // initial locale plus dependencies
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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 }
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 }
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 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
98 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
99 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
100 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
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 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
103 } 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
104 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
105 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
106 }
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 }
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 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
110 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
111 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
112 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
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 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
115 }
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 Translation[char[]] 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
117 }
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
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 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
120
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
121 alias entry opCall; /// Convenience alias
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
122
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
123 /** Get the translation for the given identifier.
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
124 * If no entry exists, the identifier will be returned.
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
125 *
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
126 * Optionally, the description can be returned. */
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
127 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
128 Entry* p = id in entries;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
129 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
130 return p.name;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
131 } else {
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
132 return id;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
133 }
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
134 }
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
135 /** ditto */
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
136 char[] entry (char[] id, out char[] description) {
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
137 Entry* p = id in entries;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
138 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
139 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
140 return p.name;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
141 } 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
142 return id;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
143 }
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
144 }
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
145
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
146 /** Alternative usage: return a Translation.Entry struct. */
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
147 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
148 Entry* p = id in entries;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
149 if (p) {
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
150 return *p;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
151 } else {
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
152 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
153 ret.name = id;
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
154 return ret;
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
155 }
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
156 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
157
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
158 static this() {
63
66d555da083e Moved many modules/packages to better reflect usage.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 26
diff changeset
159 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
160 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
161
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
162 /* Mergetag functionality.
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
163 *
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 * Merge tags in to entries, prefering existing values.
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 * Replace depends.
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 *
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
167 * User-defined type "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
168 * first two element is string and must exist
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 * second element is description and is optional
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 * third element is version and is optional
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
171 * no limit on number of elements to allow future extensions
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
172 */
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 } else if (tp == "char[][]") {
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 if (id == cast(ID)"depends") depends = cast(ID[]) parseTo!(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
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 }
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
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 // 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
190 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
191
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
192 /** This struct is used to store each translation entry.
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 * 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
195 */
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
196 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
197 char[] name; // The translated string
74
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
198 char[] desc; // An optional description
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
199 }
cee261eba249 Minor tweaks.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 70
diff changeset
200
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
201 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
202 /* 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
203 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
204 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
205 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
206 }
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
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 //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
209 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
210
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 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
212
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
213 ID[] depends; // dependancy sections (only used while loading)
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 //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
215
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
216 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
217 // 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
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 // 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
220 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
221 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
222
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
223 // 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231
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 // 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241
19
db0b48f02b69 Minor changes regarding logging and unittests.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 17
diff changeset
242 // 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
243 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
244 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
245 sections = null;
19
db0b48f02b69 Minor changes regarding logging and unittests.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 17
diff changeset
246
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
247 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
248 }
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
249 }