Skip to content

Commit 11c556f

Browse files
committed
added greek localization file
support for greek language wiktionary
1 parent 0c58bf7 commit 11c556f

4 files changed

Lines changed: 41 additions & 16 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Main software is written in Java and uses LUA modules from Wikimedia.
77

88
The library has been developed to parse and render English Wiktionary, starting from the dump **enwiktionary-latest-pages-articles.xml.bz2** available in https://dumps.wikimedia.org/enwiktionary/latest/
99

10+
In addition to English, several other languages are supported, as described below in section ``Localization``.
11+
1012
As an example of a wiktionary definition parsed by ``TemplateParser`` and rendered by ``WikiFormatter``, please look at [time](wiki.html) definition.
1113

1214
# WikiSplitter
@@ -107,6 +109,21 @@ The following optional properties may be defined in localization files:
107109
- ``parser.ifexpr``: alias for #ifexpr
108110
- ``parser.ifeq``: alias for #ifeq
109111

112+
Following languages are supported in the current implementation:
113+
- ``Arab``
114+
- ``Dutch``
115+
- ``English`` (default)
116+
- ``French``
117+
- ``German``
118+
- ``Greek``
119+
- ``Italian``
120+
- ``Latin``
121+
- ``Portuguese``
122+
- ``Romanian``
123+
- ``Russian``
124+
- ``Spanish``
125+
- ``Turkish``
126+
110127
# Credits
111128
This software integrates 3pp software to perform specific activities.
112129
The following 3pp are used by this software:

info/bliki/extensions/scribunto/engine/lua/ScribuntoLuaEngine.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ public LuaTable getInterface() {
297297
table.set("preprocess", preprocess());
298298
table.set("incrementExpensiveFunctionCount", incrementExpensiveFunctionCount());
299299
table.set("isSubsting", isSubsting());
300+
table.set("addWarning", addWarning());
300301
return table;
301302
}
302303

@@ -362,6 +363,14 @@ private LuaValue incrementExpensiveFunctionCount() {
362363
};
363364
}
364365

366+
private OneArgFunction addWarning() {
367+
return new OneArgFunction() {
368+
@Override public LuaValue call(LuaValue packageName) {
369+
return NIL;
370+
}
371+
};
372+
}
373+
365374
private LuaValue preprocess() {
366375
return new TwoArgFunction() {
367376
@Override public LuaValue call(LuaValue frameId, LuaValue text) {

info/bliki/extensions/scribunto/engine/lua/interfaces/MwTitle.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
import org.luaj.vm2.LuaTable;
44
import org.luaj.vm2.LuaValue;
5+
import org.luaj.vm2.LuaInteger;
56
import org.luaj.vm2.Varargs;
67
import org.luaj.vm2.lib.LibFunction;
78
import org.luaj.vm2.lib.OneArgFunction;
89
import org.luaj.vm2.lib.TwoArgFunction;
910

1011
import wiki.tools.WikiPage;
12+
import static wiki.NameSpaces.getNameSpaceByNumber;
13+
import static wiki.NameSpaces.getNameSpaceNumber;
1114

1215
import static info.bliki.extensions.scribunto.template.Frame.toLuaString;
1316

@@ -45,7 +48,7 @@ public LuaTable getInterface() {
4548
@Override
4649
public LuaValue getSetupOptions() {
4750
LuaTable table = new LuaTable();
48-
table.set("thisTitle", title("", wp.getPagename()));
51+
table.set("thisTitle", title(LuaValue.valueOf(0), toLuaString(wp.getPagename()), LuaValue.NIL, LuaValue.NIL));
4952
table.set("NS_MEDIA", -2);
5053
return table;
5154
}
@@ -142,16 +145,18 @@ public LuaValue call(LuaValue text_or_id, LuaValue defaultNamespace) {
142145
if (isValidTitle(text_or_id, defaultNamespace)) {
143146
String text = text_or_id.checkjstring();
144147
String interwiki = null;
148+
Integer ns_id = null;
145149
int idx = text.indexOf(":");
146150
if (idx != -1) {
147151
String prefix = text.substring(0, idx);
148152
if (prefix.equals("w") || prefix.equals("wikipedia") || prefix.equals("wikt") || prefix.equals("wiktionary"))//to be extended with more interwikis
149153
interwiki = prefix;
154+
else ns_id = getNameSpaceNumber(prefix);//ns_id != null in case prefix is namespace
150155
}
151156
int fragment_idx = text.indexOf("#");
152157
return title(
153-
defaultNamespace,
154-
text_or_id,
158+
ns_id == null ? defaultNamespace : LuaInteger.valueOf(ns_id),
159+
ns_id == null ? text_or_id : toLuaString(text.substring(idx + 1)),
155160
fragment_idx == -1 ? NIL : toLuaString(text.substring(fragment_idx + 1)),
156161
interwiki == null ? NIL : toLuaString(interwiki));
157162
} else {
@@ -202,32 +207,21 @@ public Varargs invoke(Varargs args) {
202207
};
203208
}
204209

205-
206-
private LuaValue title(String namespace, String pageName) {
207-
return title(
208-
toLuaString(namespace != null ? namespace : ""),
209-
toLuaString(pageName != null ? pageName : ""),
210-
LuaValue.NIL,
211-
LuaValue.NIL
212-
);
213-
}
214-
215210
private LuaValue title(LuaValue ns, LuaValue title, LuaValue fragment, LuaValue interwiki) {
216211
LuaTable table = new LuaTable();
217212
table.set("isLocal", EMPTYSTRING);
218213
table.set("isRedirect", EMPTYSTRING);
219214
table.set("subjectNsText", EMPTYSTRING);
220215
table.set("interwiki", interwiki.isnil() ? EMPTYSTRING : interwiki);
221-
table.set("namespace", LuaValue.valueOf(0));
222-
table.set("nsText", ns.isnil() ? LuaValue.EMPTYSTRING : ns);
216+
table.set("namespace", ns.isnil() ? LuaValue.valueOf(0) : ns);
217+
table.set("nsText", ns.isnil() ? LuaValue.EMPTYSTRING : toLuaString(getNameSpaceByNumber(ns.checkint())));
223218
table.set("text", title);
224219
table.set("id", title);
225220
table.set("fragment", fragment.isnil() ? EMPTYSTRING : fragment);
226221
table.set("contentModel", EMPTYSTRING);
227222
table.set("thePartialUrl", EMPTYSTRING);
228223
table.set("exists", LuaValue.TRUE);
229224

230-
231225
return table;
232226
}
233227
}

wiki/wiktionary_el.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#property file for greek
2+
thislanguage: .*\\{\\{-el-\\}\\}.*
3+
language_pattern: .*== ?\\{\\{-.*
4+
template: \u03a0\u03c1\u03cc\u03c4\u03c5\u03c0\u03bf
5+
redirect: \u03b1\u03bd\u03b1\u03ba\u03b1\u03c4\u03b5\u03c5\u03b8\u03c5\u03bd\u03c3\u03b7

0 commit comments

Comments
 (0)