1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.9.2.1'

This commit is contained in:
gnosygnu
2016-09-11 21:49:20 -04:00
parent 232838c732
commit 35d78f6106
310 changed files with 4358 additions and 5116 deletions

View File

@@ -20,7 +20,7 @@ import gplx.core.primitives.*; import gplx.core.btries.*;
public class Xol_grammar_ {
public static final byte Tid__max = 9;
public static final byte Tid_genitive = 0, Tid_elative = 1, Tid_partitive = 2, Tid_illative = 3, Tid_inessive = 4, Tid_accusative = 5, Tid_instrumental = 6, Tid_prepositional = 7, Tid_dative = 8, Tid_unknown = Byte_.Max_value_127;
private static final Btrie_slim_mgr Tid_trie = Btrie_slim_mgr.ci_a7() // NOTE:ci.ascii:MW kwds
private static final Btrie_slim_mgr Tid_trie = Btrie_slim_mgr.ci_a7() // NOTE:ci.ascii:MW kwds
.Add_str_byte("genitive", Tid_genitive)
.Add_str_byte("elative", Tid_elative)
.Add_str_byte("partitive", Tid_partitive)
@@ -41,16 +41,18 @@ public class Xol_grammar_ {
case Xol_lang_stub_.Id_fi: return new Xol_grammar_fi();
case Xol_lang_stub_.Id_ru: return new Xol_grammar_ru();
case Xol_lang_stub_.Id_he: return new Xol_grammar_he();
case Xol_lang_stub_.Id_pl: return Xol_grammar__noop.Instance;
case Xol_lang_stub_.Id_pl:
case Xol_lang_stub_.Id_cs: // PAGE:cs.q; DATE:2016-09-04
return Xol_grammar__noop.Instance;
default: return Xol_grammar__unimplemented.Instance;
}
}
}
class Xol_grammar__unimplemented implements Xol_grammar {
public boolean Grammar_eval(Bry_bfr bfr, Xol_lang_itm lang, byte[] word, byte[] type) {return false;}
public static final Xol_grammar__unimplemented Instance = new Xol_grammar__unimplemented(); Xol_grammar__unimplemented() {}
public static final Xol_grammar__unimplemented Instance = new Xol_grammar__unimplemented(); Xol_grammar__unimplemented() {}
}
class Xol_grammar__noop implements Xol_grammar {
public boolean Grammar_eval(Bry_bfr bfr, Xol_lang_itm lang, byte[] word, byte[] type) {bfr.Add(word); return true;}
public static final Xol_grammar__noop Instance = new Xol_grammar__noop(); Xol_grammar__noop() {}
public static final Xol_grammar__noop Instance = new Xol_grammar__noop(); Xol_grammar__noop() {}
}

View File

@@ -144,7 +144,7 @@ public static final int
, Id_ns_blankns = 122
, Id_ctg_page_label = 123
, Id_ctg_page_header = 124
, Id_ctg_subc_label = 125
, Id_ctg_subc_header = 125
, Id_ctg_file_header = 126
, Id_ctg_empty = 127
, Id_ctg_subc_count = 128
@@ -402,7 +402,7 @@ case Xol_msg_itm_.Id_scribunto_parser_error: return new_(Xol_msg_itm_.Id_scribun
case Xol_msg_itm_.Id_ns_blankns: return new_(Xol_msg_itm_.Id_ns_blankns, "blanknamespace", "(Main)");
case Xol_msg_itm_.Id_ctg_page_label: return new_(Xol_msg_itm_.Id_ctg_page_label, "pagecategories", "{{PLURAL:~{0}|Category|Categories}}");
case Xol_msg_itm_.Id_ctg_page_header: return new_(Xol_msg_itm_.Id_ctg_page_header, "category_header", "Pages in category \"~{0}\"");
case Xol_msg_itm_.Id_ctg_subc_label: return new_(Xol_msg_itm_.Id_ctg_subc_label, "subcategories", "Subcategories");
case Xol_msg_itm_.Id_ctg_subc_header: return new_(Xol_msg_itm_.Id_ctg_subc_header, "subcategories", "Subcategories");
case Xol_msg_itm_.Id_ctg_file_header: return new_(Xol_msg_itm_.Id_ctg_file_header, "category-media-header", "Media in category \"~{0}\"");
case Xol_msg_itm_.Id_ctg_empty: return new_(Xol_msg_itm_.Id_ctg_empty, "category-empty", "''This category currently contains no pages or media.''");
case Xol_msg_itm_.Id_ctg_subc_count: return new_(Xol_msg_itm_.Id_ctg_subc_count, "category-subcat-count", "{{PLURAL:~{1}|This category has only the following subcategory.|This category has the following {{PLURAL:~{0}|subcategory|~{0} subcategories}}, out of ~{1} total.}}");

View File

@@ -19,6 +19,8 @@ package gplx.xowa.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xow
import gplx.core.brys.fmtrs.*;
import gplx.langs.phps.*; import gplx.xowa.parsers.*;
import gplx.xowa.apps.gfs.*;
import gplx.xowa.htmls.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.dbs.*;
public class Xol_msg_mgr_ {
// public static String Get_msg_val_gui_or_null(Xol_lang_itm lang, byte[] pre, byte[] key, byte[] suf) {
// String rv = Get_msg_val_gui_or_null(lang, pre, key, suf);
@@ -39,7 +41,7 @@ public class Xol_msg_mgr_ {
msg_itm = lang_mgr.Lang_en().Msg_mgr().Itm_by_key_or_null(msg_key);
return msg_itm == null ? null : String_.new_u8(msg_itm.Val());
}
public static byte[] Get_msg_val(Xowe_wiki wiki, Xol_lang_itm lang, byte[] msg_key, byte[][] fmt_args) {
public static byte[] Get_msg_val(Xow_wiki wiki, Xol_lang_itm lang, byte[] msg_key, byte[][] fmt_args) {
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
Xol_msg_itm msg_itm = Get_msg_itm(tmp_bfr, wiki, lang, msg_key);
byte[] rv = (msg_itm.Defined_in_none())
@@ -48,7 +50,7 @@ public class Xol_msg_mgr_ {
tmp_bfr.Mkr_rls();
return rv;
} private static final byte[] Missing_bry = Bry_.new_a7("$"), Slash_bry = new byte[] {Byte_ascii.Slash};
public static byte[] Get_msg_val(Bry_bfr tmp_bfr, Xowe_wiki wiki, Xol_msg_itm msg_itm, byte[][] fmt_args) {
public static byte[] Get_msg_val(Bry_bfr tmp_bfr, Xow_wiki wiki, Xol_msg_itm msg_itm, byte[][] fmt_args) {
byte[] msg_val = msg_itm.Val();
boolean has_fmt = msg_itm.Has_fmt_arg(), has_tmpl = msg_itm.Has_tmpl_txt();
if (!has_fmt && !has_tmpl) // no fmt or tmpl; just add val
@@ -60,13 +62,16 @@ public class Xol_msg_mgr_ {
msg_val = tmp_bfr.To_bry_and_clear();
}
if (has_tmpl) {
Xop_ctx sub_ctx = Xop_ctx.New__sub__reuse_page(wiki.Parser_mgr().Ctx()); Xop_tkn_mkr tkn_mkr = sub_ctx.Tkn_mkr();
Xop_root_tkn sub_root = tkn_mkr.Root(msg_val);
msg_val = wiki.Parser_mgr().Main().Expand_tmpl(sub_root, sub_ctx, tkn_mkr, msg_val);
if (wiki.Type_is_edit()) {
Xowe_wiki wikie = (Xowe_wiki)wiki;
Xop_ctx sub_ctx = Xop_ctx.New__sub__reuse_page(wikie.Parser_mgr().Ctx()); Xop_tkn_mkr tkn_mkr = sub_ctx.Tkn_mkr();
Xop_root_tkn sub_root = tkn_mkr.Root(msg_val);
msg_val = wikie.Parser_mgr().Main().Expand_tmpl(sub_root, sub_ctx, tkn_mkr, msg_val);
}
}
return msg_val;
}
public static Xol_msg_itm Get_msg_itm(Bry_bfr tmp_bfr, Xowe_wiki wiki, Xol_lang_itm lang, byte[] msg_key) {
public static Xol_msg_itm Get_msg_itm(Bry_bfr tmp_bfr, Xow_wiki wiki, Xol_lang_itm lang, byte[] msg_key) {
byte[] msg_key_sub_root = msg_key;
int slash_pos = Bry_find_.Find_bwd(msg_key, Byte_ascii.Slash);
if (slash_pos != Bry_find_.Not_found) { // key is of format "key/lang"; EX: "January/en"
@@ -83,9 +88,9 @@ public class Xol_msg_mgr_ {
Xol_msg_itm msg_in_wiki = wiki.Msg_mgr().Get_or_null(msg_key); // check wiki; used to be check lang, but Search_mediawiki should never be toggled on lang; DATE:2014-05-13
if (msg_in_wiki != null) return msg_in_wiki; // NOTE: all new msgs will Search_mediawiki once; EX: de.w:{{int:Autosumm-replace}}; DATE:2013-01-25
msg_in_wiki = wiki.Msg_mgr().Get_or_make(msg_key);
Xoae_page msg_page = Get_msg_itm_from_db(wiki, lang, msg_key, msg_key_sub_root);
byte[] msg_db = Get_msg_from_db_or_null(wiki, lang, msg_key, msg_key_sub_root);
byte[] msg_val = Bry_.Empty;
if (msg_page.Db().Page().Exists_n()) { // [[MediaWiki:key/fallback]] still not found; search "lang.gfs";
if (msg_db == null) { // [[MediaWiki:key/fallback]] still not found; search "lang.gfs";
Xol_msg_itm msg_in_lang = Get_msg_itm_from_gfs(wiki, lang, msg_key_sub_root);
if (msg_in_lang == null) {
msg_val = tmp_bfr.Add_byte(Byte_ascii.Lt).Add(msg_key).Add_byte(Byte_ascii.Gt).To_bry_and_clear(); // set val to <msg_key>
@@ -97,29 +102,78 @@ public class Xol_msg_mgr_ {
}
}
else { // page found; dump entire contents
msg_val = Xoa_gfs_php_mgr.Xto_gfs(tmp_bfr, msg_page.Db().Text().Text_bry()); // note that MediaWiki msg's use php arg format ($1); xowa.gfs msgs are already converted
msg_val = Xoa_gfs_php_mgr.Xto_gfs(tmp_bfr, msg_db); // note that MediaWiki msg's use php arg format ($1); xowa.gfs msgs are already converted
msg_in_wiki.Defined_in_(Xol_msg_itm.Defined_in__wiki);
}
// Xoa_page msg_page = Get_msg_itm_from_db(wiki, lang, msg_key, msg_key_sub_root);
// byte[] msg_val = Bry_.Empty;
// if (msg_page.Db().Page().Exists_n()) { // [[MediaWiki:key/fallback]] still not found; search "lang.gfs";
// Xol_msg_itm msg_in_lang = Get_msg_itm_from_gfs(wiki, lang, msg_key_sub_root);
// if (msg_in_lang == null) {
// msg_val = tmp_bfr.Add_byte(Byte_ascii.Lt).Add(msg_key).Add_byte(Byte_ascii.Gt).To_bry_and_clear(); // set val to <msg_key>
// msg_in_wiki.Defined_in_(Xol_msg_itm.Defined_in__none);
// }
// else {
// msg_val = msg_in_lang.Val();
// msg_in_wiki.Defined_in_(Xol_msg_itm.Defined_in__lang);
// }
// }
// else { // page found; dump entire contents
// msg_val = Xoa_gfs_php_mgr.Xto_gfs(tmp_bfr, msg_page.Db().Text().Text_bry()); // note that MediaWiki msg's use php arg format ($1); xowa.gfs msgs are already converted
// msg_in_wiki.Defined_in_(Xol_msg_itm.Defined_in__wiki);
// }
Xol_msg_itm_.update_val_(msg_in_wiki, msg_val);
return msg_in_wiki;
}
private static Xoae_page Get_msg_itm_from_db(Xowe_wiki wiki, Xol_lang_itm lang, byte[] msg_key, byte[] msg_key_sub_root) {
// private static Xoa_page Get_msg_itm_from_db(Xowe_wiki wiki, Xol_lang_itm lang, byte[] msg_key, byte[] msg_key_sub_root) {
// byte[] ns_bry = wiki.Ns_mgr().Ns_mediawiki().Name_db_w_colon();
// Xoa_ttl ttl = wiki.Ttl_parse(Bry_.Add(ns_bry, msg_key)); // ttl="MediaWiki:msg_key"; note that there may be "/lang"; EX:pl.d:Wikislownik:Bar/Archiwum_6 and newarticletext/pl
// Xoae_page rv = ttl == null ? Xoae_page.Empty : wiki.Data_mgr().Load_page_by_ttl_for_msg(ttl);
// if (rv.Db().Page().Exists_n()) { // [[MediaWiki:key]] not found; search for [[MediaWiki:key/fallback]]
// byte[][] fallback_ary = lang.Fallback_bry_ary();
// int fallback_ary_len = fallback_ary.length;
// for (int i = 0; i < fallback_ary_len; i++) {
// byte[] fallback = fallback_ary[i];
// ttl = wiki.Ttl_parse(Bry_.Add(ns_bry, msg_key_sub_root, Slash_bry, fallback)); // ttl="MediaWiki:msg_key/fallback"
// rv = ttl == null ? Xoae_page.Empty : wiki.Data_mgr().Load_page_by_ttl_for_msg(ttl);
// if (rv.Db().Page().Exists()) break;
// }
// }
// return rv;
// }
private static byte[] Get_msg_from_db_or_null(Xow_wiki wiki, Xol_lang_itm lang, byte[] msg_key, byte[] msg_key_sub_root) {
byte[] ns_bry = wiki.Ns_mgr().Ns_mediawiki().Name_db_w_colon();
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.Add(ns_bry, msg_key)); // ttl="MediaWiki:msg_key"; note that there may be "/lang"; EX:pl.d:Wikislownik:Bar/Archiwum_6 and newarticletext/pl
Xoae_page rv = ttl == null ? Xoae_page.Empty : wiki.Data_mgr().Load_page_by_ttl_for_msg(ttl);
if (rv.Db().Page().Exists_n()) { // [[MediaWiki:key]] not found; search for [[MediaWiki:key/fallback]]
byte[] rv = null;
if (ttl != null)
rv = Load_msg_from_db_or_null(wiki, ttl);
if (rv == null) {// [[MediaWiki:key]] not found; search for [[MediaWiki:key/fallback]]
byte[][] fallback_ary = lang.Fallback_bry_ary();
int fallback_ary_len = fallback_ary.length;
for (int i = 0; i < fallback_ary_len; i++) {
byte[] fallback = fallback_ary[i];
ttl = wiki.Ttl_parse(Bry_.Add(ns_bry, msg_key_sub_root, Slash_bry, fallback)); // ttl="MediaWiki:msg_key/fallback"
rv = ttl == null ? Xoae_page.Empty : wiki.Data_mgr().Load_page_by_ttl_for_msg(ttl);
if (rv.Db().Page().Exists()) break;
if (ttl != null)
rv = Load_msg_from_db_or_null(wiki, ttl);
if (rv != null) break;
}
}
return rv;
}
private static Xol_msg_itm Get_msg_itm_from_gfs(Xowe_wiki wiki, Xol_lang_itm lang, byte[] msg_key_sub_root) {
private static byte[] Load_msg_from_db_or_null(Xow_wiki wiki, Xoa_ttl ttl) {
Xoa_page pg = null;
if (wiki.Type_is_edit()) {
pg = ((Xowe_wiki)wiki).Data_mgr().Load_page_by_ttl_for_msg(ttl);
}
else {
Xoh_page hpg = new Xoh_page();
pg = hpg;
hpg.Ctor_by_hview(wiki, Xoa_url.New(wiki, ttl), ttl, -1);
((Xowv_wiki)wiki).Pages_get(hpg, gplx.core.net.Gfo_url.Empty, ttl); // NOTE: url is only for "Special:" pages
}
return pg.Db().Page().Exists() ? pg.Db().Text().Text_bry() : null;
}
private static Xol_msg_itm Get_msg_itm_from_gfs(Xow_wiki wiki, Xol_lang_itm lang, byte[] msg_key_sub_root) {
Xol_msg_itm rv = lang.Msg_mgr().Itm_by_key_or_null(msg_key_sub_root); // NOTE: should always be msg_key_sub_root; EX: "msg/lang" will never be in lang.gfs
if (rv == null) { // msg not found; check fallbacks; note that this is different from MW b/c when MW constructs a lang, it automatically adds all fallback msgs to the current lang
byte[][] fallback_ary = lang.Fallback_bry_ary();

View File

@@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
import gplx.core.brys.fmtrs.*;
import gplx.xowa.htmls.sidebar.*;
import gplx.xowa.addons.htmls.sidebars.*;
public class Xow_msg_mgr implements Gfo_invk {
private final Xowe_wiki wiki; private Xol_lang_itm lang; private final Xol_msg_mgr msg_mgr;
private final Xow_wiki wiki; private Xol_lang_itm lang; private final Xol_msg_mgr msg_mgr;
private final Bry_fmtr tmp_fmtr = Bry_fmtr.New__tmp();
public Xow_msg_mgr(Xowe_wiki wiki, Xol_lang_itm lang) {
public Xow_msg_mgr(Xow_wiki wiki, Xol_lang_itm lang) {
this.wiki = wiki;
this.lang = lang;
this.msg_mgr = new Xol_msg_mgr(wiki, false);
@@ -73,7 +73,7 @@ public class Xow_msg_mgr implements Gfo_invk {
public byte[] Val_by_itm(Bry_bfr tmp_bfr, Xol_msg_itm itm, Object[] args) {
byte[] rv = itm.Val();
if (args != null) rv = itm.Fmt_tmp(tmp_bfr, tmp_fmtr, rv, args);
if (itm.Has_tmpl_txt()) rv = wiki.Parser_mgr().Main().Expand_tmpl(rv);
if (itm.Has_tmpl_txt()) rv = wiki.Wtxt__expand_tmpl(rv);
return rv;
}
public byte[] Val_html_accesskey_and_title(byte[] id) {
@@ -82,7 +82,7 @@ public class Xow_msg_mgr implements Gfo_invk {
bfr.Mkr_rls();
return rv;
}
public byte[] Val_html_accesskey_and_title(byte[] id, Bry_bfr bfr, Xowh_sidebar_itm itm) {
public byte[] Val_html_accesskey_and_title(byte[] id, Bry_bfr bfr, Xoh_sidebar_itm itm) {
byte[] tooltip_key = Bry_.Add(CONST_prefix_tooltip, id);
byte[] tooltip_val = Val_by_key_obj(tooltip_key);
boolean tooltip_found = Bry_.Len_gt_0(tooltip_val);
@@ -103,7 +103,7 @@ public class Xow_msg_mgr implements Gfo_invk {
if (itm == null)
return rv;
else {
itm.Accesskey_(accesskey_val).Title_(tooltip_val).Atr_accesskey_and_title_(rv);
itm.Init_by_title_and_accesskey(tooltip_val, accesskey_val, rv);
return null;
}
} private static final byte[] CONST_prefix_tooltip = Bry_.new_a7("tooltip-"), CONST_prefix_accesskey = Bry_.new_a7("accesskey-"), CONST_atr_title = Bry_.new_a7(" title=\""), CONST_atr_accesskey = Bry_.new_a7(" accesskey=\"");