mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.10.3.1
This commit is contained in:
@@ -16,104 +16,34 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.intls.*;
|
||||
import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.langs.cfgs.*; import gplx.xowa.bldrs.langs.*; import gplx.xowa.langs.vnts.*;
|
||||
public class Xoa_lang_mgr implements GfoInvkAble {
|
||||
private final Xoa_fsys_mgr fsys_mgr; private final Gfo_msg_log msg_log; private final Xol_lang lang_en;
|
||||
private final Ordered_hash hash = Ordered_hash_.new_bry_(); private final Hash_adp_bry fallback_regy = Hash_adp_bry.cs();
|
||||
public Xoa_lang_mgr(Xoae_app app) {
|
||||
this.fsys_mgr = app.Fsys_mgr(); this.msg_log = app.Msg_log();
|
||||
mw_converter = new Xobc_utl_make_lang(this, fsys_mgr, msg_log);
|
||||
lang_en = Lang_en_make(this); this.Add(lang_en);
|
||||
import gplx.xowa.langs.bldrs.*;
|
||||
public class Xoa_lang_mgr implements GfoInvkAble {
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
private final Xobc_utl_make_lang mw_converter;
|
||||
public Xoa_lang_mgr(Xoa_app app) {
|
||||
this.mw_converter = new Xobc_utl_make_lang(this, app.Fsys_mgr(), app.Tid_is_edit() ? ((Xoae_app)app).Msg_log() : null);
|
||||
this.lang_en = Xol_lang_itm_.Lang_en_make(this); this.Add(lang_en);
|
||||
}
|
||||
public void Clear() {hash.Clear();}
|
||||
public int Len() {return hash.Count();}
|
||||
public void Add(Xol_lang itm) {hash.Add(itm.Key_bry(), itm);}
|
||||
public Xol_lang Get_at(int i) {return (Xol_lang)hash.Get_at(i);}
|
||||
public Xol_lang Get_by_key(byte[] key) {return (Xol_lang)hash.Get_by(key);}
|
||||
public Xol_lang Get_by_key_or_load(byte[] key) {return Get_by_key_or_new(key).Init_by_load_assert();}
|
||||
public Xol_lang Get_by_key_or_new(byte[] key) {
|
||||
Xol_lang rv = Get_by_key(key);
|
||||
public Xol_lang_itm Lang_en() {return lang_en;} private final Xol_lang_itm lang_en;
|
||||
public void Clear() {hash.Clear();}
|
||||
public int Len() {return hash.Count();}
|
||||
public void Add(Xol_lang_itm itm) {hash.Add(itm.Key_bry(), itm);}
|
||||
public Xol_lang_itm Get_at(int i) {return (Xol_lang_itm)hash.Get_at(i);}
|
||||
public Xol_lang_itm Get_by(byte[] key) {return (Xol_lang_itm)hash.Get_by(key);}
|
||||
public Xol_lang_itm Get_by_or_load(byte[] key) {return Get_by_or_new(key).Init_by_load_assert();}
|
||||
public Xol_lang_itm Get_by_or_new(byte[] key) {
|
||||
Xol_lang_itm rv = Get_by(key);
|
||||
if (rv == null) {
|
||||
rv = new Xol_lang(this, key);
|
||||
rv = new Xol_lang_itm(this, key);
|
||||
this.Add(rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Hash_adp_bry Fallback_regy() {return fallback_regy;}
|
||||
public Xol_lang Lang_en() {return lang_en;}
|
||||
public Xobc_utl_make_lang Mw_converter() {return mw_converter;} private Xobc_utl_make_lang mw_converter;
|
||||
public Cfg_nde_root Groups() {return groups;} Cfg_nde_root groups = new Cfg_nde_root().Root_(new Xoac_lang_grp(Bry_.Empty), Xoac_lang_grp.Make_grp, Bry_.Ary_empty);
|
||||
public byte[] Default_lang() {return default_lang;} private byte[] default_lang = Xol_lang_.Key_en;
|
||||
private void Load_lang(byte[] bry) {this.Get_by_key_or_new(bry).Init_by_load();}
|
||||
public void Local_set_bulk(byte[] src) { // NOTE: setting local lang names/grps on app level; may need to move to user level or wiki level (for groups) later
|
||||
int len = src.length;
|
||||
int pos = 0, fld_bgn = 0, fld_idx = 0;
|
||||
byte[] code = Bry_.Empty, name = Bry_.Empty;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
while (true) {
|
||||
boolean last = pos == len;
|
||||
byte b = last ? Byte_ascii.Nl : src[pos];
|
||||
switch (b) {
|
||||
case Byte_ascii.Pipe:
|
||||
switch (fld_idx) {
|
||||
case 0: code = csv_parser.Load(src, fld_bgn, pos); break;
|
||||
case 1: name = csv_parser.Load(src, fld_bgn, pos); break;
|
||||
default: throw Err_.new_unhandled(fld_idx);
|
||||
}
|
||||
fld_bgn = pos + 1;
|
||||
++fld_idx;
|
||||
break;
|
||||
case Byte_ascii.Nl:
|
||||
byte[] grp = csv_parser.Load(src, fld_bgn, pos);
|
||||
Xol_lang_itm itm = Xol_lang_itm_.Get_by_key(code);
|
||||
itm.Localized_name_(name, grp);
|
||||
fld_bgn = pos + 1;
|
||||
fld_idx = 0;
|
||||
break;
|
||||
}
|
||||
if (last) break;
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
public void Bld_xowa() {
|
||||
Xol_mw_lang_parser lang_parser = new Xol_mw_lang_parser(msg_log);
|
||||
lang_parser.Bld_all(this, fsys_mgr);
|
||||
}
|
||||
public Ordered_hash Xto_hash(byte[] raw) {
|
||||
byte[][] keys = Bry_split_.Split(raw, Byte_ascii.Tilde);
|
||||
int len = keys.length;
|
||||
Ordered_hash langs = Ordered_hash_.new_();
|
||||
Cfg_nde_root lang_root = groups;
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] key = keys[i];
|
||||
Cfg_nde_obj lang_grp = lang_root.Grps_get(key);
|
||||
if (lang_grp == null) {
|
||||
Xol_lang_itm itm = Xol_lang_itm_.Get_by_key(key);
|
||||
if (itm == null) throw Err_.new_wo_type("unknown lang group or key", "key", String_.new_u8(key));
|
||||
langs.Add(key, Xoac_lang_grp.Regy_get_or_new(key));
|
||||
}
|
||||
else
|
||||
Cfg_nde_obj_.Fill_recurse(langs, lang_grp);
|
||||
}
|
||||
return langs;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get_by_key_or_new(m.ReadBry("key"));
|
||||
else if (ctx.Match(k, Invk_groups)) return groups;
|
||||
else if (ctx.Match(k, Invk_local_set_bulk)) Local_set_bulk(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_load_lang)) Load_lang(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_mediawiki_converter))return mw_converter;
|
||||
if (ctx.Match(k, Invk_get)) return Get_by_or_new(m.ReadBry("key"));
|
||||
else if (ctx.Match(k, Invk_mediawiki_converter)) return mw_converter;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_get = "get", Invk_local_set_bulk = "local_set_bulk", Invk_load_lang = "load_lang", Invk_groups = "groups", Invk_mediawiki_converter = "mediawiki_converter";
|
||||
} private static final String Invk_get = "get", Invk_mediawiki_converter = "mediawiki_converter";
|
||||
public static final byte[] Fallback_false = Bry_.new_a7("false");
|
||||
public static Xol_lang Lang_en_make(Xoa_lang_mgr lang_mgr) {
|
||||
Xol_lang rv = new Xol_lang(lang_mgr, Xol_lang_.Key_en);
|
||||
Xol_lang_.Lang_init(rv);
|
||||
rv.Evt_lang_changed();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.gfui.*;
|
||||
public class Xol_font_info implements GfoInvkAble, GfoEvMgrOwner {
|
||||
public Xol_font_info(String name, float size, FontStyleAdp style) {this.name = name; this.size = size; this.style = style;}
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
|
||||
public String Name() {return name;} public Xol_font_info Name_(String v) {name = v; Font_changed_pub(); return this;} private String name;
|
||||
public float Size() {return size;} public Xol_font_info Size_(float v) {size = v; Font_changed_pub(); return this;} private float size;
|
||||
public FontStyleAdp Style() {return style;} public Xol_font_info Style_(FontStyleAdp v) {style = v; Font_changed_pub(); return this;} private FontStyleAdp style;
|
||||
public Xol_font_info CloneNew() {return new Xol_font_info(name, size, style);}
|
||||
public FontAdp XtoFontAdp() {return FontAdp.new_(name, size, style);}
|
||||
public boolean Eq(FontAdp font) {return String_.Eq(name, font.Name()) && size == font.Size() && style.Val() == font.Style().Val();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_name)) return name;
|
||||
else if (ctx.Match(k, Invk_name_)) Name_(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_size)) return size;
|
||||
else if (ctx.Match(k, Invk_size_)) Size_(m.ReadFloat("v"));
|
||||
else if (ctx.Match(k, Invk_style_)) Style_(FontStyleAdp_.parse(m.ReadStr("v")));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_name = "name", Invk_name_ = "name_", Invk_size = "size", Invk_size_ = "size_", Invk_style_ = "style_";
|
||||
public static final String Font_changed = "font_changed";
|
||||
private void Font_changed_pub() {GfoEvMgr_.PubObj(this, Font_changed, "font", this);}
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.cases.*; import gplx.xowa.langs.grammars.*; import gplx.xowa.langs.genders.*; import gplx.xowa.langs.plurals.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.langs.vnts.converts.*; import gplx.xowa.langs.numbers.*; import gplx.xowa.langs.durations.*;
|
||||
import gplx.xowa.apps.gfss.*; import gplx.xowa.apps.fsys.*; import gplx.core.intls.*; import gplx.xowa.nss.*; import gplx.xowa.xtns.lst.*; import gplx.xowa.wikis.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xol_lang implements GfoInvkAble {
|
||||
private boolean loaded = false;
|
||||
public Xol_lang(Xoa_lang_mgr lang_mgr, byte[] key_bry) {
|
||||
this.lang_mgr = lang_mgr; this.key_bry = key_bry; this.key_str = String_.new_u8(key_bry);
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key(key_bry); if (lang_itm == null) throw Err_.new_wo_type("unknown lang_key", "key", String_.new_u8(key_bry));
|
||||
this.lang_id = lang_itm.Id();
|
||||
this.func_regy = new Xol_func_name_regy(lang_mgr, this);
|
||||
this.ns_names = new Xol_ns_grp(this); this.ns_aliases = new Xol_ns_grp(this);
|
||||
this.kwd_mgr = new Xol_kwd_mgr(this);
|
||||
this.msg_mgr = new Xol_msg_mgr(this, true);
|
||||
this.specials_mgr = new Xol_specials_mgr(this);
|
||||
this.case_mgr = Env_.Mode_testing() ? Xol_case_mgr_.A7() : Xol_case_mgr_.U8(); // NOTE: if test load ascii b/c utf8 is large; NOTE: placed here b/c tests do not call load; DATE:2014-07-04
|
||||
this.num_mgr = Xol_num_mgr_.new_by_lang_id(lang_id);
|
||||
this.lnki_trail_mgr = new Xol_lnki_trail_mgr(this);
|
||||
this.vnt_mgr = new Xol_vnt_mgr(this);
|
||||
this.grammar = Xol_grammar_.new_by_lang_id(lang_id);
|
||||
this.gender = Xol_gender_.new_by_lang_id(lang_id);
|
||||
this.plural = Xol_plural_.new_by_lang_id(lang_id);
|
||||
this.duration_mgr = new Xol_duration_mgr(this);
|
||||
if (lang_id != Xol_lang_itm_.Id_en) fallback_bry_ary = Fallback_bry_ary__en; // NOTE: do not set fallback_ary for en to en, else recursive loop
|
||||
}
|
||||
public Xoa_lang_mgr Lang_mgr() {return lang_mgr;} private final Xoa_lang_mgr lang_mgr;
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry;
|
||||
public String Key_str() {return key_str;} private final String key_str;
|
||||
public int Lang_id() {return lang_id;} private final int lang_id;
|
||||
public Xol_ns_grp Ns_names() {return ns_names;} private final Xol_ns_grp ns_names;
|
||||
public Xol_ns_grp Ns_aliases() {return ns_aliases;} private final Xol_ns_grp ns_aliases;
|
||||
public Xol_kwd_mgr Kwd_mgr() {return kwd_mgr;} private final Xol_kwd_mgr kwd_mgr;
|
||||
public boolean Kwd_mgr__strx() {return kwd_mgr__strx;} public Xol_lang Kwd_mgr__strx_(boolean v) {kwd_mgr__strx = v; return this;} private boolean kwd_mgr__strx;
|
||||
public Xol_msg_mgr Msg_mgr() {return msg_mgr;} private final Xol_msg_mgr msg_mgr;
|
||||
public Xol_specials_mgr Specials_mgr() {return specials_mgr;} private final Xol_specials_mgr specials_mgr;
|
||||
public Xol_case_mgr Case_mgr() {return case_mgr;} private Xol_case_mgr case_mgr;
|
||||
public void Case_mgr_u8_() {case_mgr = Xol_case_mgr_.U8();} // TEST:
|
||||
public Xol_font_info Gui_font() {return gui_font;} private final Xol_font_info gui_font = new Xol_font_info(null, 0, gplx.gfui.FontStyleAdp_.Plain);
|
||||
public byte[] Fallback_bry() {return fallback_bry;}
|
||||
public Xol_lang Fallback_bry_(byte[] v) {
|
||||
fallback_bry = v;
|
||||
fallback_bry_ary = Fallbacy_bry_ary__bld(v);
|
||||
return this;
|
||||
} private byte[] fallback_bry;
|
||||
public byte[][] Fallback_bry_ary() {return fallback_bry_ary;} private byte[][] fallback_bry_ary = Bry_.Ary_empty;
|
||||
public boolean Dir_ltr() {return dir_ltr;} private boolean dir_ltr = true;
|
||||
public void Dir_ltr_(boolean v) {
|
||||
dir_ltr = v;
|
||||
img_thumb_halign_default = dir_ltr ? Xop_lnki_align_h.Right : Xop_lnki_align_h.Left;
|
||||
}
|
||||
public byte[] Dir_ltr_bry() {return dir_ltr ? Dir_bry_ltr : Dir_bry_rtl;}
|
||||
public Xol_num_mgr Num_mgr() {return num_mgr;} private final Xol_num_mgr num_mgr;
|
||||
public Xol_vnt_mgr Vnt_mgr() {return vnt_mgr;} private final Xol_vnt_mgr vnt_mgr;
|
||||
public Xol_grammar Grammar() {return grammar;} private final Xol_grammar grammar;
|
||||
public Xol_gender Gender() {return gender;} private final Xol_gender gender;
|
||||
public Xol_plural Plural() {return plural;} private final Xol_plural plural;
|
||||
public Xol_duration_mgr Duration_mgr() {return duration_mgr;} private final Xol_duration_mgr duration_mgr;
|
||||
public Xol_lnki_trail_mgr Lnki_trail_mgr() {return lnki_trail_mgr;} private final Xol_lnki_trail_mgr lnki_trail_mgr;
|
||||
public Xop_lnki_arg_parser Lnki_arg_parser() {return lnki_arg_parser;} private Xop_lnki_arg_parser lnki_arg_parser = new Xop_lnki_arg_parser();
|
||||
public Xol_func_name_regy Func_regy() {return func_regy;} private final Xol_func_name_regy func_regy;
|
||||
public byte Img_thumb_halign_default() {return img_thumb_halign_default;} private byte img_thumb_halign_default = Xop_lnki_align_h.Right;
|
||||
public Hash_adp_bry Xatrs_section() {if (xatrs_section == null) xatrs_section = Lst_section_nde.new_xatrs_(this); return xatrs_section;} private Hash_adp_bry xatrs_section;
|
||||
public void Evt_lang_changed() {
|
||||
lnki_arg_parser.Evt_lang_changed(this);
|
||||
func_regy.Evt_lang_changed(this);
|
||||
}
|
||||
private byte[] X_axis_end() {return dir_ltr ? X_axis_end_right : X_axis_end_left;}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_ns_names)) return ns_names;
|
||||
else if (ctx.Match(k, Invk_ns_aliases)) return ns_aliases;
|
||||
else if (ctx.Match(k, Invk_keywords)) return kwd_mgr;
|
||||
else if (ctx.Match(k, Invk_messages)) return msg_mgr;
|
||||
else if (ctx.Match(k, Invk_specials)) return specials_mgr;
|
||||
else if (ctx.Match(k, Invk_casings)) return case_mgr;
|
||||
else if (ctx.Match(k, Invk_converts)) return vnt_mgr.Convert_mgr().Converter_regy();
|
||||
else if (ctx.Match(k, Invk_variants)) return vnt_mgr;
|
||||
else if (ctx.Match(k, Invk_dir_rtl_)) Dir_ltr_(!m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Invk_dir_str)) return Dir_ltr_bry();
|
||||
else if (ctx.Match(k, Invk_gui_font_)) gui_font.Name_(m.ReadStr("name")).Size_(m.ReadFloatOr("size", 8));
|
||||
else if (ctx.Match(k, Invk_fallback_load)) Exec_fallback_load(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_numbers)) return num_mgr;
|
||||
else if (ctx.Match(k, Invk_link_trail)) return lnki_trail_mgr;
|
||||
else if (ctx.Match(k, Invk_x_axis_end)) return String_.new_u8(X_axis_end());
|
||||
else if (ctx.Match(k, Invk_this)) return this;
|
||||
else if (ctx.Match(k, Xoae_app.Invk_app)) return Xoa_app_.Gfs_mgr().Root_invk();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_ns_names = "ns_names", Invk_ns_aliases = "ns_aliases"
|
||||
, Invk_keywords = "keywords", Invk_messages = "messages", Invk_specials = "specials", Invk_casings = "casings", Invk_converts = "converts", Invk_variants = "variants"
|
||||
, Invk_numbers = "numbers"
|
||||
, Invk_dir_rtl_ = "dir_rtl_", Invk_gui_font_ = "gui_font_"
|
||||
, Invk_fallback_load = "fallback_load", Invk_this = "this", Invk_dir_str = "dir_str", Invk_link_trail = "link_trail"
|
||||
, Invk_x_axis_end = "x_axis_end"
|
||||
;
|
||||
public Xol_lang Init_by_load_assert() {if (!loaded) Init_by_load(); return this;}
|
||||
public boolean Init_by_load() {
|
||||
if (this.loaded) return false;
|
||||
lang_mgr.Fallback_regy().Clear();
|
||||
this.loaded = true;
|
||||
boolean lang_is_en = lang_id == Xol_lang_itm_.Id_en;
|
||||
if (!lang_is_en) Xol_lang_.Lang_init(this);
|
||||
msg_mgr.Itm_by_key_or_new(Bry_.new_a7("Lang")).Atrs_set(key_bry, false, false); // set "Lang" keyword; EX: for "fr", "{{int:Lang}}" -> "fr"
|
||||
Load_lang(key_bry);
|
||||
ns_aliases.Ary_add_(Xow_ns_.Canonical); // NOTE: always add English canonical as aliases to all languages
|
||||
this.Evt_lang_changed();
|
||||
return true;
|
||||
}
|
||||
private void Exec_fallback_load(byte[] fallback_lang) {
|
||||
Fallback_bry_(fallback_lang);
|
||||
if (lang_mgr.Fallback_regy().Has(fallback_lang)) return; // fallback_lang loaded; avoid recursive loop; EX: zh with fallback of zh-hans which has fallback of zh
|
||||
if (Bry_.Eq(fallback_lang, Xoa_lang_mgr.Fallback_false)) return; // fallback_lang is "none" exit
|
||||
lang_mgr.Fallback_regy().Add(fallback_lang, fallback_lang);
|
||||
Load_lang(fallback_lang);
|
||||
lang_mgr.Fallback_regy().Del(fallback_lang);
|
||||
}
|
||||
private void Load_lang(byte[] v) {
|
||||
Xoa_gfs_mgr gfs_mgr = Xoa_app_.Gfs_mgr(); Xoa_fsys_mgr app_fsys_mgr = gfs_mgr.App_fsys_mgr();
|
||||
gfs_mgr.Run_url_for(this, Xol_lang_.xo_lang_fil_(app_fsys_mgr, String_.new_a7(v)));
|
||||
gfs_mgr.Run_url_for(gfs_mgr.Root_invk(), Xol_convert_regy.Bld_url(app_fsys_mgr, key_str));
|
||||
}
|
||||
private static final byte[]
|
||||
Dir_bry_ltr = Bry_.new_a7("ltr"), Dir_bry_rtl = Bry_.new_a7("rtl")
|
||||
, X_axis_end_right = Bry_.new_a7("right"), X_axis_end_left = Bry_.new_a7("left")
|
||||
;
|
||||
public static final int Tid_lower = 1, Tid_upper = 2;
|
||||
private static byte[][] Fallbacy_bry_ary__bld(byte[] v) {
|
||||
byte[][] rv = Bry_split_.Split(v, Byte_ascii.Comma, true); // gan -> 'gan-hant, zh-hant, zh-hans'
|
||||
boolean en_needed = true;
|
||||
int rv_len = rv.length;
|
||||
for (int i = 0; i < rv_len; i++) {
|
||||
byte[] itm = rv[i];
|
||||
if (Bry_.Eq(itm, Xol_lang_.Key_en)) {
|
||||
en_needed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (en_needed) {
|
||||
int new_len = rv_len + 1;
|
||||
byte[][] new_ary = new byte[new_len][];
|
||||
for (int i = 0; i < rv_len; i++)
|
||||
new_ary[i] = rv[i];
|
||||
new_ary[rv_len] = Xol_lang_.Key_en;
|
||||
rv = new_ary;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static final byte[][] Fallback_bry_ary__en = new byte[][] {Xol_lang_.Key_en};
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.intls.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.gallery.*; import gplx.xowa.bldrs.langs.*; import gplx.xowa.langs.numbers.*;
|
||||
import gplx.xowa.apps.fsys.*;
|
||||
public class Xol_lang_ {
|
||||
public static Io_url xo_lang_fil_(Xoa_fsys_mgr app_fsys_mgr, String lang_key) {return app_fsys_mgr.Cfg_lang_core_dir().GenSubFil(lang_key + ".gfs");}
|
||||
public static final byte Char_tid_ltr_l = 0, Char_tid_ltr_u = 1, Char_tid_num = 2, Char_tid_ws = 3, Char_tid_sym = 4, Char_tid_misc = 5;
|
||||
public static byte Char_tid(byte b) {
|
||||
switch (b) {
|
||||
case Byte_ascii.Ltr_A: case Byte_ascii.Ltr_B: case Byte_ascii.Ltr_C: case Byte_ascii.Ltr_D: case Byte_ascii.Ltr_E:
|
||||
case Byte_ascii.Ltr_F: case Byte_ascii.Ltr_G: case Byte_ascii.Ltr_H: case Byte_ascii.Ltr_I: case Byte_ascii.Ltr_J:
|
||||
case Byte_ascii.Ltr_K: case Byte_ascii.Ltr_L: case Byte_ascii.Ltr_M: case Byte_ascii.Ltr_N: case Byte_ascii.Ltr_O:
|
||||
case Byte_ascii.Ltr_P: case Byte_ascii.Ltr_Q: case Byte_ascii.Ltr_R: case Byte_ascii.Ltr_S: case Byte_ascii.Ltr_T:
|
||||
case Byte_ascii.Ltr_U: case Byte_ascii.Ltr_V: case Byte_ascii.Ltr_W: case Byte_ascii.Ltr_X: case Byte_ascii.Ltr_Y: case Byte_ascii.Ltr_Z:
|
||||
return Char_tid_ltr_u;
|
||||
case Byte_ascii.Ltr_a: case Byte_ascii.Ltr_b: case Byte_ascii.Ltr_c: case Byte_ascii.Ltr_d: case Byte_ascii.Ltr_e:
|
||||
case Byte_ascii.Ltr_f: case Byte_ascii.Ltr_g: case Byte_ascii.Ltr_h: case Byte_ascii.Ltr_i: case Byte_ascii.Ltr_j:
|
||||
case Byte_ascii.Ltr_k: case Byte_ascii.Ltr_l: case Byte_ascii.Ltr_m: case Byte_ascii.Ltr_n: case Byte_ascii.Ltr_o:
|
||||
case Byte_ascii.Ltr_p: case Byte_ascii.Ltr_q: case Byte_ascii.Ltr_r: case Byte_ascii.Ltr_s: case Byte_ascii.Ltr_t:
|
||||
case Byte_ascii.Ltr_u: case Byte_ascii.Ltr_v: case Byte_ascii.Ltr_w: case Byte_ascii.Ltr_x: case Byte_ascii.Ltr_y: case Byte_ascii.Ltr_z:
|
||||
return Char_tid_ltr_l;
|
||||
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
|
||||
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
|
||||
return Char_tid_num;
|
||||
case Byte_ascii.Space: case Byte_ascii.Nl: case Byte_ascii.Tab: case Byte_ascii.Cr:
|
||||
return Char_tid_ws;
|
||||
default:
|
||||
return Char_tid_misc;
|
||||
}
|
||||
}
|
||||
public static final byte[] Key_en = Bry_.new_a7("en");
|
||||
public static void Lang_init(Xol_lang lang) {
|
||||
lang.Num_mgr().Separators_mgr().Set(Xol_num_mgr.Separators_key__grp, Xol_num_mgr.Separators_key__grp);
|
||||
lang.Num_mgr().Separators_mgr().Set(Xol_num_mgr.Separators_key__dec, Xol_num_mgr.Separators_key__dec);
|
||||
lang.Lnki_trail_mgr().Add_range(Byte_ascii.Ltr_a, Byte_ascii.Ltr_z);// REF.MW:MessagesEn.php|$linkTrail = '/^([a-z]+)(.*)$/sD';
|
||||
Xol_kwd_mgr kwd_mgr = lang.Kwd_mgr();
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_redirect, "#REDIRECT");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_notoc, "__NOTOC__");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_nogallery, "__NOGALLERY__");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_forcetoc, "__FORCETOC__");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_toc, "__TOC__");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_noeditsection, "__NOEDITSECTION__");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_noheader, "__NOHEADER__");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_month_int_len2, "CURRENTMONTH", "CURRENTMONTH2");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_month_int, "CURRENTMONTH1");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_month_name, "CURRENTMONTHNAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_month_gen, "CURRENTMONTHNAMEGEN");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_month_abrv, "CURRENTMONTHABBREV");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_day_int, "CURRENTDAY");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_day_int_len2, "CURRENTDAY2");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_day_name, "CURRENTDAYNAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_year, "CURRENTYEAR");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_time, "CURRENTTIME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_hour, "CURRENTHOUR");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_month_int_len2, "LOCALMONTH", "LOCALMONTH2");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_month_int, "LOCALMONTH1");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_month_name, "LOCALMONTHNAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_month_gen, "LOCALMONTHNAMEGEN");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_month_abrv, "LOCALMONTHABBREV");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_day_int, "LOCALDAY");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_day_int_len2, "LOCALDAY2");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_day_name, "LOCALDAYNAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_year, "LOCALYEAR");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_time, "LOCALTIME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_hour, "LOCALHOUR");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_num_pages, "NUMBEROFPAGES");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_num_articles, "NUMBEROFARTICLES");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_num_files, "NUMBEROFFILES");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_num_users, "NUMBEROFUSERS");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_num_users_active, "NUMBEROFACTIVEUSERS");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_num_edits, "NUMBEROFEDITS");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_num_views, "NUMBEROFVIEWS");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_page_txt, "PAGENAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_page_url, "PAGENAMEE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ns_txt, "NAME"+"SPACE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ns_url, "NAME"+"SPACEE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ns_talk_txt, "TALKSPACE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ns_talk_url, "TALKSPACEE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ns_subj_txt, "SUBJECTSPACE", "ARTICLESPACE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ns_subj_url, "SUBJECTSPACEE", "ARTICLESPACEE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_full_txt, "FULLPAGENAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_full_url, "FULLPAGENAMEE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_leaf_txt, "SUBPAGENAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_leaf_url, "SUBPAGENAMEE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_base_txt, "BASEPAGENAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_base_url, "BASEPAGENAMEE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_talk_txt, "TALKPAGENAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_talk_url, "TALKPAGENAMEE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_subj_txt, "SUBJECTPAGENAME", "ARTICLEPAGENAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ttl_subj_url, "SUBJECTPAGENAMEE", "ARTICLEPAGENAMEE");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_msg, "msg");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_subst, "subst:");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_safesubst, "safesubst:");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_msgnw, "msgnw");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_thumbnail, "thumbnail", "thumb");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_manualthumb, "thumbnail", "thumb");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_framed, "framed", "enframed", "frame");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_frameless, "frameless");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_upright, "upright");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_upright_factor, "upright_factor");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_border, "border");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_align, "align");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_valign, "valign");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_alt, "alt");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_class, "class");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_caption, "caption");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_link_url, "link-url");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_link_title, "link-title");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_link_target, "link-target");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_link_none, "no-link");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_width, "px");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_page, "page");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_none, "none");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_right, "right");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_center, "center", "centre");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_left, "left");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_baseline, "baseline");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_sub, "sub");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_super, "super", "sup");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_top, "top");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_text_top, "text-top");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_middle, "middle");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_bottom, "bottom");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_text_bottom, "text-bottom");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_img_link, "link");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_i18n_int, "int");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_sitename, "SITENAME");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_ns, "ns");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_nse, "nse");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_localurl, "localurl");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_localurle, "localurle");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_articlepath, "ARTICLEPATH");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_server, "SERVER");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_servername, "SERVERNAME");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_scriptpath, "SCRIPTPATH");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_stylepath, "STYLEPATH");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_i18n_grammar, "grammar");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_i18n_gender, "gender");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_notitleconvert, "__NOTITLECONVERT__", "__NOTC__");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_nocontentconvert, "__NOCONTENTCONVERT__", "__NOCC__");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_week, "CURRENTWEEK");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_dow, "CURRENTDOW");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_week, "LOCALWEEK");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_dow, "LOCALDOW");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_id, "REVISIONID");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_day_int, "REVISIONDAY");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_day_int_len2, "REVISIONDAY2");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_month_int_len2, "REVISIONMONTH");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_month_int, "REVISIONMONTH1");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_year, "REVISIONYEAR");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_timestamp, "REVISIONTIMESTAMP");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_user, "REVISIONUSER");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_i18n_plural, "plural");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_fullurl, "fullurl");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_fullurle, "fullurle");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_str_lcfirst, "lcfirst");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_str_ucfirst, "ucfirst");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_str_lc, "lc");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_str_uc, "uc");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_raw, "raw");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_page_displaytitle, "DISPLAYTITLE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_str_rawsuffix, "R");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_newsectionlink, "__NEWSECTIONLINK__");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_nonewsectionlink, "__NONEWSECTIONLINK__");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_currentversion, "CURRENTVERSION");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_urlencode, "urlencode");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_anchorencode, "anchorencode");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_timestamp, "CURRENTTIMESTAMP");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_lcl_timestamp, "LOCALTIMESTAMP");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_directionmark, "DIRECTIONMARK", "DIRMARK");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_i18n_language, "#language");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_contentlanguage, "CONTENTLANGUAGE", "CONTENTLANG");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_pagesinnamespace, "PAGESINNAMESPACE", "PAGESINNS");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_num_admins, "NUMBEROFADMINS");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_str_formatnum, "formatnum");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_str_padleft, "padleft");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_str_padright, "padright");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_misc_special, "#special");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_page_defaultsort, "DEFAULTSORT", "DEFAULTSORTKEY", "DEFAULTCATEGORYSORT");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_filepath, "filepath");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_misc_tag, "#tag");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_hiddencat, "__HIDDENCAT__");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_pagesincategory, "PAGESINCATEGORY", "PAGESINCAT");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_pagesize, "PAGESIZE");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_index, "__INDEX__");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_noindex, "__NOINDEX__");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_site_numberingroup, "NUMBERINGROUP", "NUMINGROUP");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_staticredirect, "__STATICREDIRECT__");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_rev_protectionlevel, "PROTECTIONLEVEL");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_str_formatdate, "#formatdate", "#dateformat");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_path, "path");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_wiki, "wiki");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_query, "query");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_expr, "#expr");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_if, "#if");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_ifeq, "#ifeq");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_ifexpr, "#ifexpr");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_iferror, "#iferror");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_switch, "#switch");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_default, "#default");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_ifexist, "#ifexist");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_time, "#time");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_timel, "#timel");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_rel2abs, "#rel2abs");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_titleparts, "#titleparts");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xowa_dbg, "#xowa_dbg");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ogg_noplayer, "noplayer");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ogg_noicon, "noicon");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_ogg_thumbtime, "thumbtime");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xtn_geodata_coordinates, "#coordinates");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_canonicalurl, "canonicalurl");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_url_canonicalurle, "canonicalurle");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_lst, "#lst", "#section");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_lstx, "#lstx", "#section-x");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_invoke, "#invoke");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_property, "#property");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_noexternallanglinks, "noexternallanglinks");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_ns_num, "namespacenumber");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_page_id, "pageid");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_disambig, "__DISAMBIG__");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_nocommafysuffix, "NOSEP");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_xowa, "#xowa");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_mapSources_deg2dd, "#deg2dd");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_mapSources_dd2dms, "#dd2dms");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_mapSources_geoLink, "#geolink");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_geoCrumbs_isin, "#isin");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_relatedArticles, "#related");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_insider, "#insider");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_massMessage_target, "#target");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_cascadingSources, "CASCADINGSOURCES");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_pendingChangeLevel, "PENDINGCHANGELEVEL");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_pagesUsingPendingChanges, "PAGESUSINGPENDINGCHANGES");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_bang, "!");
|
||||
kwd_mgr.New(Bool_.N, Xol_kwd_grp_.Id_wbreponame, "wbreponame");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_strx_len, "#len");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_strx_pos, "#pos");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_strx_rpos, "#rpos");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_strx_sub, "#sub");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_strx_count, "#count");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_strx_replace, "#replace");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_strx_explode, "#explode");
|
||||
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_strx_urldecode, "#urldecode");
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,153 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
public class Xol_lang_itm {
|
||||
public Xol_lang_itm(int id, byte[] key, byte[] canonical_name) {this.id = id; this.key = key; this.canonical_name = canonical_name; this.localized_name = canonical_name;}
|
||||
public int Id() {return id;} private final int id; // EX: 1
|
||||
public byte[] Key() {return key;} private final byte[] key; // EX: de
|
||||
public byte[] Canonical_name() {return canonical_name;} private final byte[] canonical_name; // EX: Deutsch
|
||||
public byte[] Localized_name() {return localized_name;} private byte[] localized_name; // EX: German if usr.lang == English
|
||||
public void Localized_name_(byte[] v, byte[] localized_grp) {// NOTE: localized_grp preserved for historical reasons; should be removed; WHEN: refactor Xol_lang_itm_parser
|
||||
if (Bry_.Len_gt_0(v)) this.localized_name = v;
|
||||
import gplx.xowa.langs.cases.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.grammars.*; import gplx.xowa.langs.genders.*; import gplx.xowa.langs.plurals.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.langs.vnts.converts.*; import gplx.xowa.langs.numbers.*; import gplx.xowa.langs.durations.*; import gplx.xowa.langs.lnki_trails.*; import gplx.xowa.langs.funcs.*; import gplx.xowa.langs.specials.*; import gplx.xowa.langs.bldrs.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.apps.fsys.*; import gplx.core.intls.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.xtns.lst.*; import gplx.xowa.wikis.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.guis.langs.*;
|
||||
public class Xol_lang_itm implements GfoInvkAble {
|
||||
private boolean loaded = false;
|
||||
public Xol_lang_itm(Xoa_lang_mgr lang_mgr, byte[] key_bry) {
|
||||
this.lang_mgr = lang_mgr; this.key_bry = key_bry; this.key_str = String_.new_u8(key_bry);
|
||||
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_null(key_bry); if (lang_itm == null) throw Err_.new_wo_type("unknown lang_key", "key", String_.new_u8(key_bry));
|
||||
this.lang_id = lang_itm.Id();
|
||||
this.func_regy = new Xol_func_regy(lang_mgr, this);
|
||||
this.ns_names = new Xol_ns_grp(this); this.ns_aliases = new Xol_ns_grp(this);
|
||||
this.kwd_mgr = new Xol_kwd_mgr(this);
|
||||
this.msg_mgr = new Xol_msg_mgr(this, true);
|
||||
this.specials_mgr = new Xol_specials_mgr(this);
|
||||
this.case_mgr = Env_.Mode_testing() ? Xol_case_mgr_.A7() : Xol_case_mgr_.U8(); // NOTE: if test load ascii b/c utf8 is large; NOTE: placed here b/c tests do not call load; DATE:2014-07-04
|
||||
this.num_mgr = Xol_num_mgr_.new_by_lang_id(lang_id);
|
||||
this.lnki_trail_mgr = new Xol_lnki_trail_mgr(this);
|
||||
this.vnt_mgr = new Xol_vnt_mgr(this);
|
||||
this.grammar = Xol_grammar_.new_by_lang_id(lang_id);
|
||||
this.gender = Xol_gender_.new_by_lang_id(lang_id);
|
||||
this.plural = Xol_plural_.new_by_lang_id(lang_id);
|
||||
this.duration_mgr = new Xol_duration_mgr(this);
|
||||
if (lang_id != Xol_lang_stub_.Id_en) fallback_bry_ary = Fallback_bry_ary__en; // NOTE: do not set fallback_ary for en to en, else recursive loop
|
||||
}
|
||||
public Xoa_lang_mgr Lang_mgr() {return lang_mgr;} private final Xoa_lang_mgr lang_mgr;
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry;
|
||||
public String Key_str() {return key_str;} private final String key_str;
|
||||
public int Lang_id() {return lang_id;} private final int lang_id;
|
||||
public Xol_ns_grp Ns_names() {return ns_names;} private final Xol_ns_grp ns_names;
|
||||
public Xol_ns_grp Ns_aliases() {return ns_aliases;} private final Xol_ns_grp ns_aliases;
|
||||
public Xol_kwd_mgr Kwd_mgr() {return kwd_mgr;} private final Xol_kwd_mgr kwd_mgr;
|
||||
public boolean Kwd_mgr__strx() {return kwd_mgr__strx;} public Xol_lang_itm Kwd_mgr__strx_(boolean v) {kwd_mgr__strx = v; return this;} private boolean kwd_mgr__strx;
|
||||
public Xol_msg_mgr Msg_mgr() {return msg_mgr;} private final Xol_msg_mgr msg_mgr;
|
||||
public Xol_specials_mgr Specials_mgr() {return specials_mgr;} private final Xol_specials_mgr specials_mgr;
|
||||
public Xol_case_mgr Case_mgr() {return case_mgr;} private Xol_case_mgr case_mgr;
|
||||
public void Case_mgr_u8_() {case_mgr = Xol_case_mgr_.U8();} // TEST:
|
||||
public Xol_font_info Gui_font() {return gui_font;} private final Xol_font_info gui_font = new Xol_font_info(null, 0, gplx.gfui.FontStyleAdp_.Plain);
|
||||
public byte[] Fallback_bry() {return fallback_bry;}
|
||||
public Xol_lang_itm Fallback_bry_(byte[] v) {
|
||||
fallback_bry = v;
|
||||
fallback_bry_ary = Fallbacy_bry_ary__bld(v);
|
||||
return this;
|
||||
} private byte[] fallback_bry;
|
||||
public byte[][] Fallback_bry_ary() {return fallback_bry_ary;} private byte[][] fallback_bry_ary = Bry_.Ary_empty;
|
||||
public boolean Dir_ltr() {return dir_ltr;} private boolean dir_ltr = true;
|
||||
public void Dir_ltr_(boolean v) {
|
||||
dir_ltr = v;
|
||||
img_thumb_halign_default = dir_ltr ? Xop_lnki_align_h.Right : Xop_lnki_align_h.Left;
|
||||
}
|
||||
public byte[] Dir_ltr_bry() {return dir_ltr ? Dir_bry_ltr : Dir_bry_rtl;}
|
||||
public Xol_num_mgr Num_mgr() {return num_mgr;} private final Xol_num_mgr num_mgr;
|
||||
public Xol_vnt_mgr Vnt_mgr() {return vnt_mgr;} private final Xol_vnt_mgr vnt_mgr;
|
||||
public Xol_grammar Grammar() {return grammar;} private final Xol_grammar grammar;
|
||||
public Xol_gender Gender() {return gender;} private final Xol_gender gender;
|
||||
public Xol_plural Plural() {return plural;} private final Xol_plural plural;
|
||||
public Xol_duration_mgr Duration_mgr() {return duration_mgr;} private final Xol_duration_mgr duration_mgr;
|
||||
public Xol_lnki_trail_mgr Lnki_trail_mgr() {return lnki_trail_mgr;} private final Xol_lnki_trail_mgr lnki_trail_mgr;
|
||||
public Xop_lnki_arg_parser Lnki_arg_parser() {return lnki_arg_parser;} private Xop_lnki_arg_parser lnki_arg_parser = new Xop_lnki_arg_parser();
|
||||
public Xol_func_regy Func_regy() {return func_regy;} private final Xol_func_regy func_regy;
|
||||
public byte Img_thumb_halign_default() {return img_thumb_halign_default;} private byte img_thumb_halign_default = Xop_lnki_align_h.Right;
|
||||
public Hash_adp_bry Xatrs_section() {if (xatrs_section == null) xatrs_section = Lst_section_nde.new_xatrs_(this); return xatrs_section;} private Hash_adp_bry xatrs_section;
|
||||
public void Evt_lang_changed() {
|
||||
lnki_arg_parser.Evt_lang_changed(this);
|
||||
func_regy.Evt_lang_changed(this);
|
||||
}
|
||||
private byte[] X_axis_end() {return dir_ltr ? X_axis_end_right : X_axis_end_left;}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_ns_names)) return ns_names;
|
||||
else if (ctx.Match(k, Invk_ns_aliases)) return ns_aliases;
|
||||
else if (ctx.Match(k, Invk_keywords)) return kwd_mgr;
|
||||
else if (ctx.Match(k, Invk_messages)) return msg_mgr;
|
||||
else if (ctx.Match(k, Invk_specials)) return specials_mgr;
|
||||
else if (ctx.Match(k, Invk_casings)) return case_mgr;
|
||||
else if (ctx.Match(k, Invk_converts)) return vnt_mgr.Convert_mgr().Converter_regy();
|
||||
else if (ctx.Match(k, Invk_variants)) return vnt_mgr;
|
||||
else if (ctx.Match(k, Invk_dir_rtl_)) Dir_ltr_(!m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Invk_dir_str)) return Dir_ltr_bry();
|
||||
else if (ctx.Match(k, Invk_gui_font_)) gui_font.Name_(m.ReadStr("name")).Size_(m.ReadFloatOr("size", 8));
|
||||
else if (ctx.Match(k, Invk_fallback_load)) Exec_fallback_load(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_numbers)) return num_mgr;
|
||||
else if (ctx.Match(k, Invk_link_trail)) return lnki_trail_mgr;
|
||||
else if (ctx.Match(k, Invk_x_axis_end)) return String_.new_u8(X_axis_end());
|
||||
else if (ctx.Match(k, Invk_this)) return this;
|
||||
else if (ctx.Match(k, Xoae_app.Invk_app)) return Xoa_app_.Gfs_mgr().Root_invk();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_ns_names = "ns_names", Invk_ns_aliases = "ns_aliases"
|
||||
, Invk_keywords = "keywords", Invk_messages = "messages", Invk_specials = "specials", Invk_casings = "casings", Invk_converts = "converts", Invk_variants = "variants"
|
||||
, Invk_numbers = "numbers"
|
||||
, Invk_dir_rtl_ = "dir_rtl_", Invk_gui_font_ = "gui_font_"
|
||||
, Invk_fallback_load = "fallback_load", Invk_this = "this", Invk_dir_str = "dir_str", Invk_link_trail = "link_trail"
|
||||
, Invk_x_axis_end = "x_axis_end"
|
||||
;
|
||||
|
||||
private static final Hash_adp_bry fallback_dupes_regy = Hash_adp_bry.cs(); // to prevent cyclical loops during loading
|
||||
public Xol_lang_itm Init_by_load_assert() {if (!loaded) Init_by_load(); return this;}
|
||||
public boolean Init_by_load() {
|
||||
if (this.loaded) return false;
|
||||
fallback_dupes_regy.Clear();
|
||||
this.loaded = true;
|
||||
boolean lang_is_en = lang_id == Xol_lang_stub_.Id_en;
|
||||
if (!lang_is_en) Xol_lang_itm_.Lang_init(this);
|
||||
msg_mgr.Itm_by_key_or_new(Bry_.new_a7("Lang")).Atrs_set(key_bry, false, false); // set "Lang" keyword; EX: for "fr", "{{int:Lang}}" -> "fr"
|
||||
Load_lang(key_bry);
|
||||
ns_aliases.Ary_add_(Xow_ns_.Canonical); // NOTE: always add English canonical as aliases to all languages
|
||||
this.Evt_lang_changed();
|
||||
return true;
|
||||
}
|
||||
private void Exec_fallback_load(byte[] fallback_lang) {
|
||||
Fallback_bry_(fallback_lang);
|
||||
if (fallback_dupes_regy.Has(fallback_lang)) return; // fallback_lang loaded; avoid recursive loop; EX: zh with fallback of zh-hans which has fallback of zh
|
||||
if (Bry_.Eq(fallback_lang, Xoa_lang_mgr.Fallback_false)) return; // fallback_lang is "none" exit
|
||||
fallback_dupes_regy.Add(fallback_lang, fallback_lang);
|
||||
Load_lang(fallback_lang);
|
||||
fallback_dupes_regy.Del(fallback_lang);
|
||||
}
|
||||
private void Load_lang(byte[] v) {
|
||||
Xoa_gfs_mgr gfs_mgr = Xoa_app_.Gfs_mgr(); Xoa_fsys_mgr app_fsys_mgr = gfs_mgr.App_fsys_mgr();
|
||||
gfs_mgr.Run_url_for(this, Xol_lang_itm_.xo_lang_fil_(app_fsys_mgr, String_.new_a7(v)));
|
||||
gfs_mgr.Run_url_for(gfs_mgr.Root_invk(), Xol_convert_regy.Bld_url(app_fsys_mgr, key_str));
|
||||
}
|
||||
private static final byte[]
|
||||
Dir_bry_ltr = Bry_.new_a7("ltr"), Dir_bry_rtl = Bry_.new_a7("rtl")
|
||||
, X_axis_end_right = Bry_.new_a7("right"), X_axis_end_left = Bry_.new_a7("left")
|
||||
;
|
||||
public static final int Tid_lower = 1, Tid_upper = 2;
|
||||
private static byte[][] Fallbacy_bry_ary__bld(byte[] v) {
|
||||
byte[][] rv = Bry_split_.Split(v, Byte_ascii.Comma, true); // gan -> 'gan-hant, zh-hant, zh-hans'
|
||||
boolean en_needed = true;
|
||||
int rv_len = rv.length;
|
||||
for (int i = 0; i < rv_len; i++) {
|
||||
byte[] itm = rv[i];
|
||||
if (Bry_.Eq(itm, Xol_lang_itm_.Key_en)) {
|
||||
en_needed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (en_needed) {
|
||||
int new_len = rv_len + 1;
|
||||
byte[][] new_ary = new byte[new_len][];
|
||||
for (int i = 0; i < rv_len; i++)
|
||||
new_ary[i] = rv[i];
|
||||
new_ary[rv_len] = Xol_lang_itm_.Key_en;
|
||||
rv = new_ary;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static final byte[][] Fallback_bry_ary__en = new byte[][] {Xol_lang_itm_.Key_en};
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,17 +15,10 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Cfg_nde_obj_ {
|
||||
public static void Fill_recurse(Ordered_hash rv, Cfg_nde_obj peer_grp) {
|
||||
int subs_len = peer_grp.Nde_subs_len();
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
Cfg_nde_obj sub_obj = (Cfg_nde_obj)peer_grp.Nde_subs_get_at(i);
|
||||
if (sub_obj.Nde_typ_is_grp())
|
||||
Cfg_nde_obj_.Fill_recurse(rv, (Cfg_nde_obj)sub_obj);
|
||||
else {
|
||||
rv.Add_if_dupe_use_nth(sub_obj.Nde_key(), sub_obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
public class Xol_lang_stub {
|
||||
public Xol_lang_stub(int id, byte[] key, byte[] canonical_name) {this.id = id; this.key = key; this.canonical_name = canonical_name;}
|
||||
public int Id() {return id;} private final int id; // EX: 1
|
||||
public byte[] Key() {return key;} private final byte[] key; // EX: de
|
||||
public byte[] Canonical_name() {return canonical_name;} private final byte[] canonical_name; // EX: Deutsch
|
||||
}
|
||||
942
400_xowa/src/gplx/xowa/langs/Xol_lang_stub_.java
Normal file
942
400_xowa/src/gplx/xowa/langs/Xol_lang_stub_.java
Normal file
@@ -0,0 +1,942 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.lists.*;
|
||||
public class Xol_lang_stub_ { // lists all known stub_ary supported by MW
|
||||
public static final byte[] Key__unknown = Bry_.Empty;
|
||||
public static final ComparerAble Comparer_key = new Xol_sub_itm_comparer();
|
||||
public static final int
|
||||
Id__intl = -2
|
||||
, Id__unknown = -1
|
||||
, Id_en = 0
|
||||
, Id_aa = 1
|
||||
, Id_ab = 2
|
||||
, Id_ace = 3
|
||||
, Id_ady_cyrl = 4
|
||||
, Id_aeb = 5
|
||||
, Id_af = 6
|
||||
, Id_ak = 7
|
||||
, Id_akz = 8
|
||||
, Id_aln = 9
|
||||
, Id_als = 10
|
||||
, Id_am = 11
|
||||
, Id_an = 12
|
||||
, Id_ang = 13
|
||||
, Id_anp = 14
|
||||
, Id_ar = 15
|
||||
, Id_arc = 16
|
||||
, Id_arn = 17
|
||||
, Id_aro = 18
|
||||
, Id_arq = 19
|
||||
, Id_ary = 20
|
||||
, Id_arz = 21
|
||||
, Id_as = 22
|
||||
, Id_ase = 23
|
||||
, Id_ast = 24
|
||||
, Id_av = 25
|
||||
, Id_avk = 26
|
||||
, Id_awa = 27
|
||||
, Id_ay = 28
|
||||
, Id_az = 29
|
||||
, Id_azb = 30
|
||||
, Id_ba = 31
|
||||
, Id_ban = 32
|
||||
, Id_bar = 33
|
||||
, Id_bat_smg = 34
|
||||
, Id_bbc = 35
|
||||
, Id_bbc_latn = 36
|
||||
, Id_bcc = 37
|
||||
, Id_bcl = 38
|
||||
, Id_be = 39
|
||||
, Id_be_tarask = 40
|
||||
, Id_be_x_old = 41
|
||||
, Id_bew = 42
|
||||
, Id_bg = 43
|
||||
, Id_bgn = 44
|
||||
, Id_bh = 45
|
||||
, Id_bho = 46
|
||||
, Id_bi = 47
|
||||
, Id_bjn = 48
|
||||
, Id_bm = 49
|
||||
, Id_bn = 50
|
||||
, Id_bo = 51
|
||||
, Id_bpy = 52
|
||||
, Id_bqi = 53
|
||||
, Id_br = 54
|
||||
, Id_brh = 55
|
||||
, Id_bs = 56
|
||||
, Id_bto = 57
|
||||
, Id_bug = 58
|
||||
, Id_bxr = 59
|
||||
, Id_ca = 60
|
||||
, Id_cbk_zam = 61
|
||||
, Id_cdo = 62
|
||||
, Id_ce = 63
|
||||
, Id_ceb = 64
|
||||
, Id_ch = 65
|
||||
, Id_chm = 66
|
||||
, Id_cho = 67
|
||||
, Id_chr = 68
|
||||
, Id_chy = 69
|
||||
, Id_ckb = 70
|
||||
, Id_co = 71
|
||||
, Id_cps = 72
|
||||
, Id_cr = 73
|
||||
, Id_crh = 74
|
||||
, Id_crh_cyrl = 75
|
||||
, Id_crh_latn = 76
|
||||
, Id_cs = 77
|
||||
, Id_csb = 78
|
||||
, Id_cu = 79
|
||||
, Id_cv = 80
|
||||
, Id_cy = 81
|
||||
, Id_da = 82
|
||||
, Id_de = 83
|
||||
, Id_de_at = 84
|
||||
, Id_de_ch = 85
|
||||
, Id_de_formal = 86
|
||||
, Id_diq = 87
|
||||
, Id_dsb = 88
|
||||
, Id_dtp = 89
|
||||
, Id_dv = 90
|
||||
, Id_dz = 91
|
||||
, Id_ee = 92
|
||||
, Id_egl = 93
|
||||
, Id_el = 94
|
||||
, Id_eml = 95
|
||||
, Id_en_ca = 96
|
||||
, Id_en_gb = 97
|
||||
, Id_en_rtl = 98
|
||||
, Id_enrtl = 99
|
||||
, Id_eo = 100
|
||||
, Id_es = 101
|
||||
, Id_es_formal = 102
|
||||
, Id_esu = 103
|
||||
, Id_et = 104
|
||||
, Id_eu = 105
|
||||
, Id_ext = 106
|
||||
, Id_fa = 107
|
||||
, Id_ff = 108
|
||||
, Id_fi = 109
|
||||
, Id_fit = 110
|
||||
, Id_fiu_vro = 111
|
||||
, Id_fj = 112
|
||||
, Id_fo = 113
|
||||
, Id_fr = 114
|
||||
, Id_frc = 115
|
||||
, Id_frp = 116
|
||||
, Id_frr = 117
|
||||
, Id_fur = 118
|
||||
, Id_fy = 119
|
||||
, Id_ga = 120
|
||||
, Id_gag = 121
|
||||
, Id_gan = 122
|
||||
, Id_gan_hans = 123
|
||||
, Id_gan_hant = 124
|
||||
, Id_gd = 125
|
||||
, Id_gl = 126
|
||||
, Id_glk = 127
|
||||
, Id_gn = 128
|
||||
, Id_gom = 129
|
||||
, Id_gom_deva = 130
|
||||
, Id_gom_latn = 131
|
||||
, Id_got = 132
|
||||
, Id_grc = 133
|
||||
, Id_gsw = 134
|
||||
, Id_gu = 135
|
||||
, Id_guc = 136
|
||||
, Id_gv = 137
|
||||
, Id_ha = 138
|
||||
, Id_hak = 139
|
||||
, Id_haw = 140
|
||||
, Id_he = 141
|
||||
, Id_hi = 142
|
||||
, Id_hif = 143
|
||||
, Id_hif_latn = 144
|
||||
, Id_hil = 145
|
||||
, Id_ho = 146
|
||||
, Id_hr = 147
|
||||
, Id_hrx = 148
|
||||
, Id_hsb = 149
|
||||
, Id_hsn = 150
|
||||
, Id_ht = 151
|
||||
, Id_hu = 152
|
||||
, Id_hu_formal = 153
|
||||
, Id_hy = 154
|
||||
, Id_hz = 155
|
||||
, Id_ia = 156
|
||||
, Id_id = 157
|
||||
, Id_ie = 158
|
||||
, Id_ig = 159
|
||||
, Id_ii = 160
|
||||
, Id_ik = 161
|
||||
, Id_ike_cans = 162
|
||||
, Id_ike_latn = 163
|
||||
, Id_ilo = 164
|
||||
, Id_inh = 165
|
||||
, Id_io = 166
|
||||
, Id_is = 167
|
||||
, Id_it = 168
|
||||
, Id_iu = 169
|
||||
, Id_izh = 170
|
||||
, Id_ja = 171
|
||||
, Id_jam = 172
|
||||
, Id_jbo = 173
|
||||
, Id_jut = 174
|
||||
, Id_jv = 175
|
||||
, Id_ka = 176
|
||||
, Id_kaa = 177
|
||||
, Id_kab = 178
|
||||
, Id_kbd = 179
|
||||
, Id_kbd_cyrl = 180
|
||||
, Id_kg = 181
|
||||
, Id_khw = 182
|
||||
, Id_ki = 183
|
||||
, Id_kiu = 184
|
||||
, Id_kj = 185
|
||||
, Id_kk = 186
|
||||
, Id_kk_arab = 187
|
||||
, Id_kk_cn = 188
|
||||
, Id_kk_cyrl = 189
|
||||
, Id_kk_kz = 190
|
||||
, Id_kk_latn = 191
|
||||
, Id_kk_tr = 192
|
||||
, Id_kl = 193
|
||||
, Id_km = 194
|
||||
, Id_kn = 195
|
||||
, Id_ko = 196
|
||||
, Id_ko_kp = 197
|
||||
, Id_koi = 198
|
||||
, Id_kr = 199
|
||||
, Id_krc = 200
|
||||
, Id_kri = 201
|
||||
, Id_krj = 202
|
||||
, Id_krl = 203
|
||||
, Id_ks = 204
|
||||
, Id_ks_arab = 205
|
||||
, Id_ks_deva = 206
|
||||
, Id_ksh = 207
|
||||
, Id_ku = 208
|
||||
, Id_ku_arab = 209
|
||||
, Id_ku_latn = 210
|
||||
, Id_kv = 211
|
||||
, Id_kw = 212
|
||||
, Id_ky = 213
|
||||
, Id_la = 214
|
||||
, Id_lad = 215
|
||||
, Id_lb = 216
|
||||
, Id_lbe = 217
|
||||
, Id_lez = 218
|
||||
, Id_lfn = 219
|
||||
, Id_lg = 220
|
||||
, Id_li = 221
|
||||
, Id_lij = 222
|
||||
, Id_liv = 223
|
||||
, Id_lmo = 224
|
||||
, Id_ln = 225
|
||||
, Id_lo = 226
|
||||
, Id_loz = 227
|
||||
, Id_lrc = 228
|
||||
, Id_lt = 229
|
||||
, Id_ltg = 230
|
||||
, Id_lus = 231
|
||||
, Id_luz = 232
|
||||
, Id_lv = 233
|
||||
, Id_lzh = 234
|
||||
, Id_lzz = 235
|
||||
, Id_mai = 236
|
||||
, Id_map_bms = 237
|
||||
, Id_mdf = 238
|
||||
, Id_mg = 239
|
||||
, Id_mh = 240
|
||||
, Id_mhr = 241
|
||||
, Id_mi = 242
|
||||
, Id_mic = 243
|
||||
, Id_min = 244
|
||||
, Id_mk = 245
|
||||
, Id_ml = 246
|
||||
, Id_mn = 247
|
||||
, Id_mnc = 248
|
||||
, Id_mo = 249
|
||||
, Id_mr = 250
|
||||
, Id_mrj = 251
|
||||
, Id_ms = 252
|
||||
, Id_mt = 253
|
||||
, Id_mui = 254
|
||||
, Id_mus = 255
|
||||
, Id_mwl = 256
|
||||
, Id_mwv = 257
|
||||
, Id_my = 258
|
||||
, Id_myv = 259
|
||||
, Id_mzn = 260
|
||||
, Id_na = 261
|
||||
, Id_nah = 262
|
||||
, Id_nan = 263
|
||||
, Id_nap = 264
|
||||
, Id_nb = 265
|
||||
, Id_nds = 266
|
||||
, Id_nds_nl = 267
|
||||
, Id_ne = 268
|
||||
, Id_new = 269
|
||||
, Id_ng = 270
|
||||
, Id_niu = 271
|
||||
, Id_nl = 272
|
||||
, Id_nl_informal = 273
|
||||
, Id_nn = 274
|
||||
, Id_no = 275
|
||||
, Id_nov = 276
|
||||
, Id_nrm = 277
|
||||
, Id_nso = 278
|
||||
, Id_nv = 279
|
||||
, Id_ny = 280
|
||||
, Id_oc = 281
|
||||
, Id_om = 282
|
||||
, Id_or = 283
|
||||
, Id_os = 284
|
||||
, Id_pa = 285
|
||||
, Id_pag = 286
|
||||
, Id_pam = 287
|
||||
, Id_pap = 288
|
||||
, Id_pbb = 289
|
||||
, Id_pcd = 290
|
||||
, Id_pdc = 291
|
||||
, Id_pdt = 292
|
||||
, Id_pfl = 293
|
||||
, Id_pi = 294
|
||||
, Id_pih = 295
|
||||
, Id_pl = 296
|
||||
, Id_pms = 297
|
||||
, Id_pnb = 298
|
||||
, Id_pnt = 299
|
||||
, Id_ppl = 300
|
||||
, Id_prg = 301
|
||||
, Id_ps = 302
|
||||
, Id_pt = 303
|
||||
, Id_pt_br = 304
|
||||
, Id_qqq = 305
|
||||
, Id_qu = 306
|
||||
, Id_qug = 307
|
||||
, Id_rap = 308
|
||||
, Id_rgn = 309
|
||||
, Id_rif = 310
|
||||
, Id_rm = 311
|
||||
, Id_rmf = 312
|
||||
, Id_rmy = 313
|
||||
, Id_rn = 314
|
||||
, Id_ro = 315
|
||||
, Id_roa_rup = 316
|
||||
, Id_roa_tara = 317
|
||||
, Id_ru = 318
|
||||
, Id_rue = 319
|
||||
, Id_rup = 320
|
||||
, Id_ruq = 321
|
||||
, Id_ruq_cyrl = 322
|
||||
, Id_ruq_latn = 323
|
||||
, Id_rw = 324
|
||||
, Id_ryu = 325
|
||||
, Id_sa = 326
|
||||
, Id_sah = 327
|
||||
, Id_sat = 328
|
||||
, Id_saz = 329
|
||||
, Id_sc = 330
|
||||
, Id_scn = 331
|
||||
, Id_sco = 332
|
||||
, Id_sd = 333
|
||||
, Id_sdc = 334
|
||||
, Id_sdh = 335
|
||||
, Id_se = 336
|
||||
, Id_sei = 337
|
||||
, Id_ses = 338
|
||||
, Id_sg = 339
|
||||
, Id_sgs = 340
|
||||
, Id_sh = 341
|
||||
, Id_shi = 342
|
||||
, Id_shn = 343
|
||||
, Id_si = 344
|
||||
, Id_simple = 345
|
||||
, Id_sk = 346
|
||||
, Id_sl = 347
|
||||
, Id_sli = 348
|
||||
, Id_sly = 349
|
||||
, Id_sm = 350
|
||||
, Id_sma = 351
|
||||
, Id_sn = 352
|
||||
, Id_so = 353
|
||||
, Id_sq = 354
|
||||
, Id_sr = 355
|
||||
, Id_sr_ec = 356
|
||||
, Id_sr_el = 357
|
||||
, Id_srn = 358
|
||||
, Id_ss = 359
|
||||
, Id_st = 360
|
||||
, Id_stq = 361
|
||||
, Id_su = 362
|
||||
, Id_sv = 363
|
||||
, Id_sw = 364
|
||||
, Id_sxu = 365
|
||||
, Id_szl = 366
|
||||
, Id_ta = 367
|
||||
, Id_tcy = 368
|
||||
, Id_te = 369
|
||||
, Id_test = 370
|
||||
, Id_tet = 371
|
||||
, Id_tg = 372
|
||||
, Id_tg_cyrl = 373
|
||||
, Id_tg_latn = 374
|
||||
, Id_th = 375
|
||||
, Id_ti = 376
|
||||
, Id_tk = 377
|
||||
, Id_tl = 378
|
||||
, Id_tly = 379
|
||||
, Id_tn = 380
|
||||
, Id_to = 381
|
||||
, Id_tokipona = 382
|
||||
, Id_tp = 383
|
||||
, Id_tpi = 384
|
||||
, Id_tr = 385
|
||||
, Id_tru = 386
|
||||
, Id_ts = 387
|
||||
, Id_tt = 388
|
||||
, Id_tt_cyrl = 389
|
||||
, Id_tt_latn = 390
|
||||
, Id_ttt = 391
|
||||
, Id_tum = 392
|
||||
, Id_tw = 393
|
||||
, Id_ty = 394
|
||||
, Id_tyv = 395
|
||||
, Id_tzm = 396
|
||||
, Id_udm = 397
|
||||
, Id_ug = 398
|
||||
, Id_ug_arab = 399
|
||||
, Id_ug_latn = 400
|
||||
, Id_uk = 401
|
||||
, Id_ur = 402
|
||||
, Id_uz = 403
|
||||
, Id_ve = 404
|
||||
, Id_vec = 405
|
||||
, Id_vep = 406
|
||||
, Id_vi = 407
|
||||
, Id_vls = 408
|
||||
, Id_vmf = 409
|
||||
, Id_vo = 410
|
||||
, Id_vot = 411
|
||||
, Id_vro = 412
|
||||
, Id_wa = 413
|
||||
, Id_war = 414
|
||||
, Id_wo = 415
|
||||
, Id_wuu = 416
|
||||
, Id_xal = 417
|
||||
, Id_xh = 418
|
||||
, Id_xmf = 419
|
||||
, Id_yi = 420
|
||||
, Id_yo = 421
|
||||
, Id_yue = 422
|
||||
, Id_za = 423
|
||||
, Id_zea = 424
|
||||
, Id_zh = 425
|
||||
, Id_zh_classical = 426
|
||||
, Id_zh_cn = 427
|
||||
, Id_zh_hans = 428
|
||||
, Id_zh_hant = 429
|
||||
, Id_zh_hk = 430
|
||||
, Id_zh_min_nan = 431
|
||||
, Id_zh_mo = 432
|
||||
, Id_zh_my = 433
|
||||
, Id_zh_sg = 434
|
||||
, Id_zh_tw = 435
|
||||
, Id_zh_yue = 436
|
||||
, Id_zu = 437
|
||||
;
|
||||
public static final int Id__max = 438;
|
||||
public static Hash_adp_bry Regy() {
|
||||
if (stub_hash == null) { // NOTE: any parenthetical String below will have an "unseen" character of "\xE2\x80\xAA" at the begining and "\xE2\x80\xAC" at the end. They are responsible for parentheses-orientation in RTL stub_ary.
|
||||
stub_hash = Hash_adp_bry.ci_a7(); // ASCII:lang_code; NOTE: must be ci; EX: {{#languages:FR}}
|
||||
Regy_add(stub_hash, Id_en, "en", "English");
|
||||
Regy_add(stub_hash, Id_aa, "aa", "Qafár af");
|
||||
Regy_add(stub_hash, Id_ab, "ab", "Аҧсуа");
|
||||
Regy_add(stub_hash, Id_ace, "ace", "Acèh");
|
||||
Regy_add(stub_hash, Id_ady_cyrl, "ady-cyrl", "West Circassian (Cyrillic)");
|
||||
Regy_add(stub_hash, Id_aeb, "aeb", "زَوُن");
|
||||
Regy_add(stub_hash, Id_af, "af", "Afrikaans");
|
||||
Regy_add(stub_hash, Id_ak, "ak", "Akan");
|
||||
Regy_add(stub_hash, Id_akz, "akz", "Alibamu");
|
||||
Regy_add(stub_hash, Id_aln, "aln", "Gegë");
|
||||
Regy_add(stub_hash, Id_als, "als", "Alemannisch");
|
||||
Regy_add(stub_hash, Id_am, "am", "አማርኛ");
|
||||
Regy_add(stub_hash, Id_an, "an", "Aragonés");
|
||||
Regy_add(stub_hash, Id_ang, "ang", "Ænglisc");
|
||||
Regy_add(stub_hash, Id_anp, "anp", "अङ्गिका");
|
||||
Regy_add(stub_hash, Id_ar, "ar", "العربية");
|
||||
Regy_add(stub_hash, Id_arc, "arc", "ܐܪܡܝܐ");
|
||||
Regy_add(stub_hash, Id_arn, "arn", "Mapudungun");
|
||||
Regy_add(stub_hash, Id_aro, "aro", "Araona");
|
||||
Regy_add(stub_hash, Id_arq, "arq", "Algerian Arabic");
|
||||
Regy_add(stub_hash, Id_ary, "ary", "Maġribi");
|
||||
Regy_add(stub_hash, Id_arz, "arz", "مصرى");
|
||||
Regy_add(stub_hash, Id_as, "as", "অসমীয়া");
|
||||
Regy_add(stub_hash, Id_ase, "ase", "American Sign Language");
|
||||
Regy_add(stub_hash, Id_ast, "ast", "Asturianu");
|
||||
Regy_add(stub_hash, Id_av, "av", "Авар");
|
||||
Regy_add(stub_hash, Id_avk, "avk", "Kotava");
|
||||
Regy_add(stub_hash, Id_awa, "awa", "Awadhi");
|
||||
Regy_add(stub_hash, Id_ay, "ay", "Aymar aru");
|
||||
Regy_add(stub_hash, Id_az, "az", "Azərbaycanca");
|
||||
Regy_add(stub_hash, Id_azb, "azb", "South Azerbaijani");
|
||||
Regy_add(stub_hash, Id_ba, "ba", "Башҡортса");
|
||||
Regy_add(stub_hash, Id_ban, "ban", "ᬩᬲᬩᬮᬶ");
|
||||
Regy_add(stub_hash, Id_bar, "bar", "Boarisch");
|
||||
Regy_add(stub_hash, Id_bat_smg, "bat-smg", "Žemaitėška");
|
||||
Regy_add(stub_hash, Id_bbc, "bbc", "Batak Toba");
|
||||
Regy_add(stub_hash, Id_bbc_latn, "bbc-latn", "Batak Toba (Latin)");
|
||||
Regy_add(stub_hash, Id_bcc, "bcc", "بلوچی مکرانی");
|
||||
Regy_add(stub_hash, Id_bcl, "bcl", "Bikol Central");
|
||||
Regy_add(stub_hash, Id_be, "be", "Беларуская");
|
||||
Regy_add(stub_hash, Id_be_tarask, "be-tarask", "Беларуская (тарашкевіца)");
|
||||
Regy_add(stub_hash, Id_be_x_old, "be-x-old", "Беларуская (тарашкевіца)");
|
||||
Regy_add(stub_hash, Id_bew, "bew", "Betawi");
|
||||
Regy_add(stub_hash, Id_bg, "bg", "Български");
|
||||
Regy_add(stub_hash, Id_bgn, "bgn", "Balochi");
|
||||
Regy_add(stub_hash, Id_bh, "bh", "भोजपुरी");
|
||||
Regy_add(stub_hash, Id_bho, "bho", "भोजपुरी");
|
||||
Regy_add(stub_hash, Id_bi, "bi", "Bislama");
|
||||
Regy_add(stub_hash, Id_bjn, "bjn", "Bahasa Banjar");
|
||||
Regy_add(stub_hash, Id_bm, "bm", "Bamanankan");
|
||||
Regy_add(stub_hash, Id_bn, "bn", "বাংলা");
|
||||
Regy_add(stub_hash, Id_bo, "bo", "བོད་ཡིག");
|
||||
Regy_add(stub_hash, Id_bpy, "bpy", "ইমার ঠার/বিষ্ণুপ্রিয়া মণিপুরী");
|
||||
Regy_add(stub_hash, Id_bqi, "bqi", "بختياري");
|
||||
Regy_add(stub_hash, Id_br, "br", "Brezhoneg");
|
||||
Regy_add(stub_hash, Id_brh, "brh", "Bráhuí");
|
||||
Regy_add(stub_hash, Id_bs, "bs", "Bosanski");
|
||||
Regy_add(stub_hash, Id_bto, "bto", "Rinconada Bikol");
|
||||
Regy_add(stub_hash, Id_bug, "bug", "ᨅᨔ ᨕᨘᨁᨗ");
|
||||
Regy_add(stub_hash, Id_bxr, "bxr", "Буряад");
|
||||
Regy_add(stub_hash, Id_ca, "ca", "Català");
|
||||
Regy_add(stub_hash, Id_cbk_zam, "cbk-zam", "Chavacano de Zamboanga");
|
||||
Regy_add(stub_hash, Id_cdo, "cdo", "Mìng-dĕ̤ng-ngṳ̄");
|
||||
Regy_add(stub_hash, Id_ce, "ce", "Нохчийн");
|
||||
Regy_add(stub_hash, Id_ceb, "ceb", "Cebuano");
|
||||
Regy_add(stub_hash, Id_ch, "ch", "Chamoru");
|
||||
Regy_add(stub_hash, Id_chm, "chm", "Mari");
|
||||
Regy_add(stub_hash, Id_cho, "cho", "Choctaw");
|
||||
Regy_add(stub_hash, Id_chr, "chr", "ᏣᎳᎩ");
|
||||
Regy_add(stub_hash, Id_chy, "chy", "Tsetsêhestâhese");
|
||||
Regy_add(stub_hash, Id_ckb, "ckb", "کوردی");
|
||||
Regy_add(stub_hash, Id_co, "co", "Corsu");
|
||||
Regy_add(stub_hash, Id_cps, "cps", "Capiceño");
|
||||
Regy_add(stub_hash, Id_cr, "cr", "Nēhiyawēwin / ᓀᐦᐃᔭᐍᐏᐣ");
|
||||
Regy_add(stub_hash, Id_crh, "crh", "Qırımtatarca");
|
||||
Regy_add(stub_hash, Id_crh_cyrl, "crh-cyrl", "Къырымтатарджа (Кирилл)");
|
||||
Regy_add(stub_hash, Id_crh_latn, "crh-latn", "Qırımtatarca (Latin)");
|
||||
Regy_add(stub_hash, Id_cs, "cs", "Česky");
|
||||
Regy_add(stub_hash, Id_csb, "csb", "Kaszëbsczi");
|
||||
Regy_add(stub_hash, Id_cu, "cu", "Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ");
|
||||
Regy_add(stub_hash, Id_cv, "cv", "Чӑвашла");
|
||||
Regy_add(stub_hash, Id_cy, "cy", "Cymraeg");
|
||||
Regy_add(stub_hash, Id_da, "da", "Dansk");
|
||||
Regy_add(stub_hash, Id_de, "de", "Deutsch");
|
||||
Regy_add(stub_hash, Id_de_at, "de-at", "Österreichisches Deutsch");
|
||||
Regy_add(stub_hash, Id_de_ch, "de-ch", "Schweizer Hochdeutsch");
|
||||
Regy_add(stub_hash, Id_de_formal, "de-formal", "Deutsch (Sie-Form)");
|
||||
Regy_add(stub_hash, Id_diq, "diq", "Zazaki");
|
||||
Regy_add(stub_hash, Id_dsb, "dsb", "Dolnoserbski");
|
||||
Regy_add(stub_hash, Id_dtp, "dtp", "Dusun Bundu-liwan");
|
||||
Regy_add(stub_hash, Id_dv, "dv", "ދިވެހިބަސް");
|
||||
Regy_add(stub_hash, Id_dz, "dz", "ཇོང་ཁ");
|
||||
Regy_add(stub_hash, Id_ee, "ee", "Eʋegbe");
|
||||
Regy_add(stub_hash, Id_egl, "egl", "Emiliàn");
|
||||
Regy_add(stub_hash, Id_el, "el", "Ελληνικά");
|
||||
Regy_add(stub_hash, Id_eml, "eml", "Emiliàn e rumagnòl");
|
||||
Regy_add(stub_hash, Id_en_ca, "en-ca", "Canadian English");
|
||||
Regy_add(stub_hash, Id_en_gb, "en-gb", "British English");
|
||||
Regy_add(stub_hash, Id_en_rtl, "en-rtl", "English rtl");
|
||||
Regy_add(stub_hash, Id_enrtl, "enrtl", "English (right to left)");
|
||||
Regy_add(stub_hash, Id_eo, "eo", "Esperanto");
|
||||
Regy_add(stub_hash, Id_es, "es", "Español");
|
||||
Regy_add(stub_hash, Id_es_formal, "es-formal", "Spanish (formal)");
|
||||
Regy_add(stub_hash, Id_esu, "esu", "Yuk'ip");
|
||||
Regy_add(stub_hash, Id_et, "et", "Eesti");
|
||||
Regy_add(stub_hash, Id_eu, "eu", "Euskara");
|
||||
Regy_add(stub_hash, Id_ext, "ext", "Estremeñu");
|
||||
Regy_add(stub_hash, Id_fa, "fa", "فارسی");
|
||||
Regy_add(stub_hash, Id_ff, "ff", "Fulfulde");
|
||||
Regy_add(stub_hash, Id_fi, "fi", "Suomi");
|
||||
Regy_add(stub_hash, Id_fit, "fit", "meänkieli");
|
||||
Regy_add(stub_hash, Id_fiu_vro, "fiu-vro", "Võro");
|
||||
Regy_add(stub_hash, Id_fj, "fj", "Na Vosa Vakaviti");
|
||||
Regy_add(stub_hash, Id_fo, "fo", "Føroyskt");
|
||||
Regy_add(stub_hash, Id_fr, "fr", "Français");
|
||||
Regy_add(stub_hash, Id_frc, "frc", "Français cadien");
|
||||
Regy_add(stub_hash, Id_frp, "frp", "Arpetan");
|
||||
Regy_add(stub_hash, Id_frr, "frr", "Nordfriisk");
|
||||
Regy_add(stub_hash, Id_fur, "fur", "Furlan");
|
||||
Regy_add(stub_hash, Id_fy, "fy", "Frysk");
|
||||
Regy_add(stub_hash, Id_ga, "ga", "Gaeilge");
|
||||
Regy_add(stub_hash, Id_gag, "gag", "Gagauz");
|
||||
Regy_add(stub_hash, Id_gan, "gan", "贛語");
|
||||
Regy_add(stub_hash, Id_gan_hans, "gan-hans", "赣语(简体)");
|
||||
Regy_add(stub_hash, Id_gan_hant, "gan-hant", "贛語(繁體)");
|
||||
Regy_add(stub_hash, Id_gd, "gd", "Gàidhlig");
|
||||
Regy_add(stub_hash, Id_gl, "gl", "Galego");
|
||||
Regy_add(stub_hash, Id_glk, "glk", "گیلکی");
|
||||
Regy_add(stub_hash, Id_gn, "gn", "Avañe'ẽ");
|
||||
Regy_add(stub_hash, Id_gom, "gom", "कोंकणी");
|
||||
Regy_add(stub_hash, Id_gom_deva, "gom-deva", "Konkani");
|
||||
Regy_add(stub_hash, Id_gom_latn, "gom-latn", "कोंकणी (Latin)");
|
||||
Regy_add(stub_hash, Id_got, "got", "𐌲𐌿𐍄𐌹𐍃𐌺");
|
||||
Regy_add(stub_hash, Id_grc, "grc", "Ἀρχαία ἑλληνικὴ");
|
||||
Regy_add(stub_hash, Id_gsw, "gsw", "Alemannisch");
|
||||
Regy_add(stub_hash, Id_gu, "gu", "ગુજરાતી");
|
||||
Regy_add(stub_hash, Id_guc, "guc", "Wayuu");
|
||||
Regy_add(stub_hash, Id_gv, "gv", "Gaelg");
|
||||
Regy_add(stub_hash, Id_ha, "ha", "هَوُسَ");
|
||||
Regy_add(stub_hash, Id_hak, "hak", "Hak-kâ-fa");
|
||||
Regy_add(stub_hash, Id_haw, "haw", "Hawai`i");
|
||||
Regy_add(stub_hash, Id_he, "he", "עברית");
|
||||
Regy_add(stub_hash, Id_hi, "hi", "हिन्दी");
|
||||
Regy_add(stub_hash, Id_hif, "hif", "Fiji Hindi");
|
||||
Regy_add(stub_hash, Id_hif_latn, "hif-latn", "Fiji Hindi");
|
||||
Regy_add(stub_hash, Id_hil, "hil", "Ilonggo");
|
||||
Regy_add(stub_hash, Id_ho, "ho", "Hiri Motu");
|
||||
Regy_add(stub_hash, Id_hr, "hr", "Hrvatski");
|
||||
Regy_add(stub_hash, Id_hrx, "hrx", "Hunsriker");
|
||||
Regy_add(stub_hash, Id_hsb, "hsb", "Hornjoserbsce");
|
||||
Regy_add(stub_hash, Id_hsn, "hsn", "Xiang");
|
||||
Regy_add(stub_hash, Id_ht, "ht", "Kreyòl ayisyen");
|
||||
Regy_add(stub_hash, Id_hu, "hu", "Magyar");
|
||||
Regy_add(stub_hash, Id_hu_formal, "hu-formal", "Magyar (formal)");
|
||||
Regy_add(stub_hash, Id_hy, "hy", "Հայերեն");
|
||||
Regy_add(stub_hash, Id_hz, "hz", "Otsiherero");
|
||||
Regy_add(stub_hash, Id_ia, "ia", "Interlingua");
|
||||
Regy_add(stub_hash, Id_id, "id", "Bahasa Indonesia");
|
||||
Regy_add(stub_hash, Id_ie, "ie", "Interlingue");
|
||||
Regy_add(stub_hash, Id_ig, "ig", "Igbo");
|
||||
Regy_add(stub_hash, Id_ii, "ii", "ꆇꉙ");
|
||||
Regy_add(stub_hash, Id_ik, "ik", "Iñupiak");
|
||||
Regy_add(stub_hash, Id_ike_cans, "ike-cans", "ᐃᓄᒃᑎᑐᑦ");
|
||||
Regy_add(stub_hash, Id_ike_latn, "ike-latn", "inuktitut");
|
||||
Regy_add(stub_hash, Id_ilo, "ilo", "Ilokano");
|
||||
Regy_add(stub_hash, Id_inh, "inh", "ГІалгІай Ğalğaj");
|
||||
Regy_add(stub_hash, Id_io, "io", "Ido");
|
||||
Regy_add(stub_hash, Id_is, "is", "Íslenska");
|
||||
Regy_add(stub_hash, Id_it, "it", "Italiano");
|
||||
Regy_add(stub_hash, Id_iu, "iu", "ᐃᓄᒃᑎᑐᑦ/inuktitut");
|
||||
Regy_add(stub_hash, Id_izh, "izh", "Ingrian");
|
||||
Regy_add(stub_hash, Id_ja, "ja", "日本語");
|
||||
Regy_add(stub_hash, Id_jam, "jam", "Patois");
|
||||
Regy_add(stub_hash, Id_jbo, "jbo", "Lojban");
|
||||
Regy_add(stub_hash, Id_jut, "jut", "Jysk");
|
||||
Regy_add(stub_hash, Id_jv, "jv", "Basa Jawa");
|
||||
Regy_add(stub_hash, Id_ka, "ka", "ქართული");
|
||||
Regy_add(stub_hash, Id_kaa, "kaa", "Qaraqalpaqsha");
|
||||
Regy_add(stub_hash, Id_kab, "kab", "Taqbaylit");
|
||||
Regy_add(stub_hash, Id_kbd, "kbd", "Къэбэрдеибзэ / Qabardjajəbza");
|
||||
Regy_add(stub_hash, Id_kbd_cyrl, "kbd-cyrl", "къэбэрдеибзэ");
|
||||
Regy_add(stub_hash, Id_kg, "kg", "Kongo");
|
||||
Regy_add(stub_hash, Id_khw, "khw", "کھوار");
|
||||
Regy_add(stub_hash, Id_ki, "ki", "Gĩkũyũ");
|
||||
Regy_add(stub_hash, Id_kiu, "kiu", "Kırmancki");
|
||||
Regy_add(stub_hash, Id_kj, "kj", "Kwanyama");
|
||||
Regy_add(stub_hash, Id_kk, "kk", "Қазақша");
|
||||
Regy_add(stub_hash, Id_kk_arab, "kk-arab", "قازاقشا (تٴوتە)");
|
||||
Regy_add(stub_hash, Id_kk_cn, "kk-cn", "قازاقشا (جۇنگو)");
|
||||
Regy_add(stub_hash, Id_kk_cyrl, "kk-cyrl", "Қазақша (кирил)");
|
||||
Regy_add(stub_hash, Id_kk_kz, "kk-kz", "Қазақша (Қазақстан)");
|
||||
Regy_add(stub_hash, Id_kk_latn, "kk-latn", "Qazaqşa (latın)");
|
||||
Regy_add(stub_hash, Id_kk_tr, "kk-tr", "Qazaqşa (Türkïya)");
|
||||
Regy_add(stub_hash, Id_kl, "kl", "Kalaallisut");
|
||||
Regy_add(stub_hash, Id_km, "km", "ភាសាខ្មែរ");
|
||||
Regy_add(stub_hash, Id_kn, "kn", "ಕನ್ನಡ");
|
||||
Regy_add(stub_hash, Id_ko, "ko", "한국어");
|
||||
Regy_add(stub_hash, Id_ko_kp, "ko-kp", "한국어 (조선)");
|
||||
Regy_add(stub_hash, Id_koi, "koi", "Перем Коми");
|
||||
Regy_add(stub_hash, Id_kr, "kr", "Kanuri");
|
||||
Regy_add(stub_hash, Id_krc, "krc", "Къарачай-Малкъар");
|
||||
Regy_add(stub_hash, Id_kri, "kri", "Krio");
|
||||
Regy_add(stub_hash, Id_krj, "krj", "Kinaray-a");
|
||||
Regy_add(stub_hash, Id_krl, "krl", "Karelian");
|
||||
Regy_add(stub_hash, Id_ks, "ks", "कश्मीरी - (كشميري)");
|
||||
Regy_add(stub_hash, Id_ks_arab, "ks-arab", "کٲشُر");
|
||||
Regy_add(stub_hash, Id_ks_deva, "ks-deva", "कॉशुर");
|
||||
Regy_add(stub_hash, Id_ksh, "ksh", "Ripoarisch");
|
||||
Regy_add(stub_hash, Id_ku, "ku", "Kurdî");
|
||||
Regy_add(stub_hash, Id_ku_arab, "ku-arab", "كوردي (عەرەبی)");
|
||||
Regy_add(stub_hash, Id_ku_latn, "ku-latn", "Kurdî (latînî)");
|
||||
Regy_add(stub_hash, Id_kv, "kv", "Коми");
|
||||
Regy_add(stub_hash, Id_kw, "kw", "Kernowek");
|
||||
Regy_add(stub_hash, Id_ky, "ky", "Кыргызча");
|
||||
Regy_add(stub_hash, Id_la, "la", "Latina");
|
||||
Regy_add(stub_hash, Id_lad, "lad", "Ladino");
|
||||
Regy_add(stub_hash, Id_lb, "lb", "Lëtzebuergesch");
|
||||
Regy_add(stub_hash, Id_lbe, "lbe", "Лакку");
|
||||
Regy_add(stub_hash, Id_lez, "lez", "Лезги");
|
||||
Regy_add(stub_hash, Id_lfn, "lfn", "Lingua Franca Nova");
|
||||
Regy_add(stub_hash, Id_lg, "lg", "Luganda");
|
||||
Regy_add(stub_hash, Id_li, "li", "Limburgs");
|
||||
Regy_add(stub_hash, Id_lij, "lij", "Líguru");
|
||||
Regy_add(stub_hash, Id_liv, "liv", "Līvõ kēļ");
|
||||
Regy_add(stub_hash, Id_lmo, "lmo", "Lumbaart");
|
||||
Regy_add(stub_hash, Id_ln, "ln", "Lingála");
|
||||
Regy_add(stub_hash, Id_lo, "lo", "ລາວ");
|
||||
Regy_add(stub_hash, Id_loz, "loz", "Silozi");
|
||||
Regy_add(stub_hash, Id_lrc, "lrc", "لوری");
|
||||
Regy_add(stub_hash, Id_lt, "lt", "Lietuvių");
|
||||
Regy_add(stub_hash, Id_ltg, "ltg", "Latgaļu");
|
||||
Regy_add(stub_hash, Id_lus, "lus", "Mizo ţawng");
|
||||
Regy_add(stub_hash, Id_luz, "luz", "Luri");
|
||||
Regy_add(stub_hash, Id_lv, "lv", "Latviešu");
|
||||
Regy_add(stub_hash, Id_lzh, "lzh", "文言");
|
||||
Regy_add(stub_hash, Id_lzz, "lzz", "Lazuri");
|
||||
Regy_add(stub_hash, Id_mai, "mai", "मैथिली");
|
||||
Regy_add(stub_hash, Id_map_bms, "map-bms", "Basa Banyumasan");
|
||||
Regy_add(stub_hash, Id_mdf, "mdf", "Мокшень");
|
||||
Regy_add(stub_hash, Id_mg, "mg", "Malagasy");
|
||||
Regy_add(stub_hash, Id_mh, "mh", "Ebon");
|
||||
Regy_add(stub_hash, Id_mhr, "mhr", "Олык Марий");
|
||||
Regy_add(stub_hash, Id_mi, "mi", "Māori");
|
||||
Regy_add(stub_hash, Id_mic, "mic", "Mi'kmaq");
|
||||
Regy_add(stub_hash, Id_min, "min", "Baso Minangkabau");
|
||||
Regy_add(stub_hash, Id_mk, "mk", "Македонски");
|
||||
Regy_add(stub_hash, Id_ml, "ml", "മലയാളം");
|
||||
Regy_add(stub_hash, Id_mn, "mn", "Монгол");
|
||||
Regy_add(stub_hash, Id_mnc, "mnc", "Manchu");
|
||||
Regy_add(stub_hash, Id_mo, "mo", "Молдовеняскэ");
|
||||
Regy_add(stub_hash, Id_mr, "mr", "मराठी");
|
||||
Regy_add(stub_hash, Id_mrj, "mrj", "Кырык мары");
|
||||
Regy_add(stub_hash, Id_ms, "ms", "Bahasa Melayu");
|
||||
Regy_add(stub_hash, Id_mt, "mt", "Malti");
|
||||
Regy_add(stub_hash, Id_mui, "mui", "Musi");
|
||||
Regy_add(stub_hash, Id_mus, "mus", "Mvskoke");
|
||||
Regy_add(stub_hash, Id_mwl, "mwl", "Mirandés");
|
||||
Regy_add(stub_hash, Id_mwv, "mwv", "Behase Mentawei");
|
||||
Regy_add(stub_hash, Id_my, "my", "Burmese");
|
||||
Regy_add(stub_hash, Id_myv, "myv", "Эрзянь");
|
||||
Regy_add(stub_hash, Id_mzn, "mzn", "مازِرونی");
|
||||
Regy_add(stub_hash, Id_na, "na", "Dorerin Naoero");
|
||||
Regy_add(stub_hash, Id_nah, "nah", "Nāhuatl");
|
||||
Regy_add(stub_hash, Id_nan, "nan", "Bân-lâm-gú");
|
||||
Regy_add(stub_hash, Id_nap, "nap", "Nnapulitano");
|
||||
Regy_add(stub_hash, Id_nb, "nb", "Norsk (bokmål)");
|
||||
Regy_add(stub_hash, Id_nds, "nds", "Plattdüütsch");
|
||||
Regy_add(stub_hash, Id_nds_nl, "nds-nl", "Nedersaksisch");
|
||||
Regy_add(stub_hash, Id_ne, "ne", "नेपाली");
|
||||
Regy_add(stub_hash, Id_new, "new", "नेपाल भाषा");
|
||||
Regy_add(stub_hash, Id_ng, "ng", "Oshiwambo");
|
||||
Regy_add(stub_hash, Id_niu, "niu", "Niuē");
|
||||
Regy_add(stub_hash, Id_nl, "nl", "Nederlands");
|
||||
Regy_add(stub_hash, Id_nl_informal, "nl-informal", "Nederlands (informeel)");
|
||||
Regy_add(stub_hash, Id_nn, "nn", "Norsk (nynorsk)");
|
||||
Regy_add(stub_hash, Id_no, "no", "Norsk (bokmål)");
|
||||
Regy_add(stub_hash, Id_nov, "nov", "Novial");
|
||||
Regy_add(stub_hash, Id_nrm, "nrm", "Nouormand");
|
||||
Regy_add(stub_hash, Id_nso, "nso", "Sesotho sa Leboa");
|
||||
Regy_add(stub_hash, Id_nv, "nv", "Diné bizaad");
|
||||
Regy_add(stub_hash, Id_ny, "ny", "Chi-Chewa");
|
||||
Regy_add(stub_hash, Id_oc, "oc", "Occitan");
|
||||
Regy_add(stub_hash, Id_om, "om", "Oromoo");
|
||||
Regy_add(stub_hash, Id_or, "or", "ଓଡ଼ିଆ");
|
||||
Regy_add(stub_hash, Id_os, "os", "Иронау");
|
||||
Regy_add(stub_hash, Id_pa, "pa", "ਪੰਜਾਬੀ");
|
||||
Regy_add(stub_hash, Id_pag, "pag", "Pangasinan");
|
||||
Regy_add(stub_hash, Id_pam, "pam", "Kapampangan");
|
||||
Regy_add(stub_hash, Id_pap, "pap", "Papiamentu");
|
||||
Regy_add(stub_hash, Id_pbb, "pbb", "Páez");
|
||||
Regy_add(stub_hash, Id_pcd, "pcd", "Picard");
|
||||
Regy_add(stub_hash, Id_pdc, "pdc", "Deitsch");
|
||||
Regy_add(stub_hash, Id_pdt, "pdt", "Plautdietsch");
|
||||
Regy_add(stub_hash, Id_pfl, "pfl", "Pälzisch");
|
||||
Regy_add(stub_hash, Id_pi, "pi", "पािऴ");
|
||||
Regy_add(stub_hash, Id_pih, "pih", "Norfuk / Pitkern");
|
||||
Regy_add(stub_hash, Id_pl, "pl", "Polski");
|
||||
Regy_add(stub_hash, Id_pms, "pms", "Piemontèis");
|
||||
Regy_add(stub_hash, Id_pnb, "pnb", "پنجابی");
|
||||
Regy_add(stub_hash, Id_pnt, "pnt", "Ποντιακά");
|
||||
Regy_add(stub_hash, Id_ppl, "ppl", "Pipil");
|
||||
Regy_add(stub_hash, Id_prg, "prg", "Prūsiskan");
|
||||
Regy_add(stub_hash, Id_ps, "ps", "پښتو");
|
||||
Regy_add(stub_hash, Id_pt, "pt", "Português");
|
||||
Regy_add(stub_hash, Id_pt_br, "pt-br", "Português do Brasil");
|
||||
Regy_add(stub_hash, Id_qqq, "qqq", "MediaWiki sample");
|
||||
Regy_add(stub_hash, Id_qu, "qu", "Runa Simi");
|
||||
Regy_add(stub_hash, Id_qug, "qug", "Runa shimi");
|
||||
Regy_add(stub_hash, Id_rap, "rap", "Rapa Nui");
|
||||
Regy_add(stub_hash, Id_rgn, "rgn", "Rumagnôl");
|
||||
Regy_add(stub_hash, Id_rif, "rif", "Tarifit");
|
||||
Regy_add(stub_hash, Id_rm, "rm", "Rumantsch");
|
||||
Regy_add(stub_hash, Id_rmf, "rmf", "Finnish Kalo");
|
||||
Regy_add(stub_hash, Id_rmy, "rmy", "Romani");
|
||||
Regy_add(stub_hash, Id_rn, "rn", "Kirundi");
|
||||
Regy_add(stub_hash, Id_ro, "ro", "Română");
|
||||
Regy_add(stub_hash, Id_roa_rup, "roa-rup", "Armãneashce");
|
||||
Regy_add(stub_hash, Id_roa_tara, "roa-tara", "Tarandíne");
|
||||
Regy_add(stub_hash, Id_ru, "ru", "Русский");
|
||||
Regy_add(stub_hash, Id_rue, "rue", "Русиньскый");
|
||||
Regy_add(stub_hash, Id_rup, "rup", "Armãneașce");
|
||||
Regy_add(stub_hash, Id_ruq, "ruq", "Vlăheşte");
|
||||
Regy_add(stub_hash, Id_ruq_cyrl, "ruq-cyrl", "Влахесте");
|
||||
Regy_add(stub_hash, Id_ruq_latn, "ruq-latn", "Vlăheşte");
|
||||
Regy_add(stub_hash, Id_rw, "rw", "Kinyarwanda");
|
||||
Regy_add(stub_hash, Id_ryu, "ryu", "Okinawan");
|
||||
Regy_add(stub_hash, Id_sa, "sa", "संस्कृत");
|
||||
Regy_add(stub_hash, Id_sah, "sah", "Саха тыла");
|
||||
Regy_add(stub_hash, Id_sat, "sat", "Santali");
|
||||
Regy_add(stub_hash, Id_saz, "saz", "Saurashtra");
|
||||
Regy_add(stub_hash, Id_sc, "sc", "Sardu");
|
||||
Regy_add(stub_hash, Id_scn, "scn", "Sicilianu");
|
||||
Regy_add(stub_hash, Id_sco, "sco", "Scots");
|
||||
Regy_add(stub_hash, Id_sd, "sd", "سنڌي");
|
||||
Regy_add(stub_hash, Id_sdc, "sdc", "Sassaresu");
|
||||
Regy_add(stub_hash, Id_sdh, "sdh", "Southern Kurdish");
|
||||
Regy_add(stub_hash, Id_se, "se", "Sámegiella");
|
||||
Regy_add(stub_hash, Id_sei, "sei", "Cmique Itom");
|
||||
Regy_add(stub_hash, Id_ses, "ses", "Songhay");
|
||||
Regy_add(stub_hash, Id_sg, "sg", "Sängö");
|
||||
Regy_add(stub_hash, Id_sgs, "sgs", "Žemaitėška");
|
||||
Regy_add(stub_hash, Id_sh, "sh", "Srpskohrvatski / Српскохрватски");
|
||||
Regy_add(stub_hash, Id_shi, "shi", "Tašlḥiyt");
|
||||
Regy_add(stub_hash, Id_shn, "shn", "Shan");
|
||||
Regy_add(stub_hash, Id_si, "si", "Sinhalese");
|
||||
Regy_add(stub_hash, Id_simple, "simple", "Simple English");
|
||||
Regy_add(stub_hash, Id_sk, "sk", "Slovenčina");
|
||||
Regy_add(stub_hash, Id_sl, "sl", "Slovenščina");
|
||||
Regy_add(stub_hash, Id_sli, "sli", "Schläsch");
|
||||
Regy_add(stub_hash, Id_sly, "sly", "Selayar");
|
||||
Regy_add(stub_hash, Id_sm, "sm", "Gagana Samoa");
|
||||
Regy_add(stub_hash, Id_sma, "sma", "Åarjelsaemien");
|
||||
Regy_add(stub_hash, Id_sn, "sn", "chiShona");
|
||||
Regy_add(stub_hash, Id_so, "so", "Soomaaliga");
|
||||
Regy_add(stub_hash, Id_sq, "sq", "Shqip");
|
||||
Regy_add(stub_hash, Id_sr, "sr", "Српски / Srpski");
|
||||
Regy_add(stub_hash, Id_sr_ec, "sr-ec", "Српски (ћирилица)");
|
||||
Regy_add(stub_hash, Id_sr_el, "sr-el", "Srpski (latinica)");
|
||||
Regy_add(stub_hash, Id_srn, "srn", "Sranantongo");
|
||||
Regy_add(stub_hash, Id_ss, "ss", "SiSwati");
|
||||
Regy_add(stub_hash, Id_st, "st", "Sesotho");
|
||||
Regy_add(stub_hash, Id_stq, "stq", "Seeltersk");
|
||||
Regy_add(stub_hash, Id_su, "su", "Basa Sunda");
|
||||
Regy_add(stub_hash, Id_sv, "sv", "Svenska");
|
||||
Regy_add(stub_hash, Id_sw, "sw", "Kiswahili");
|
||||
Regy_add(stub_hash, Id_sxu, "sxu", "Saxon, Upper");
|
||||
Regy_add(stub_hash, Id_szl, "szl", "Ślůnski");
|
||||
Regy_add(stub_hash, Id_ta, "ta", "தமிழ்");
|
||||
Regy_add(stub_hash, Id_tcy, "tcy", "ತುಳು");
|
||||
Regy_add(stub_hash, Id_te, "te", "తెలుగు");
|
||||
Regy_add(stub_hash, Id_test, "test", "MediaWiki test");
|
||||
Regy_add(stub_hash, Id_tet, "tet", "Tetun");
|
||||
Regy_add(stub_hash, Id_tg, "tg", "Тоҷикӣ");
|
||||
Regy_add(stub_hash, Id_tg_cyrl, "tg-cyrl", "Тоҷикӣ");
|
||||
Regy_add(stub_hash, Id_tg_latn, "tg-latn", "tojikī");
|
||||
Regy_add(stub_hash, Id_th, "th", "ไทย");
|
||||
Regy_add(stub_hash, Id_ti, "ti", "ትግርኛ");
|
||||
Regy_add(stub_hash, Id_tk, "tk", "Türkmençe");
|
||||
Regy_add(stub_hash, Id_tl, "tl", "Tagalog");
|
||||
Regy_add(stub_hash, Id_tly, "tly", "толышә зывон");
|
||||
Regy_add(stub_hash, Id_tn, "tn", "Setswana");
|
||||
Regy_add(stub_hash, Id_to, "to", "lea faka-Tonga");
|
||||
Regy_add(stub_hash, Id_tokipona, "tokipona", "Toki Pona");
|
||||
Regy_add(stub_hash, Id_tp, "tp", "Toki Pona (deprecated:tokipona)");
|
||||
Regy_add(stub_hash, Id_tpi, "tpi", "Tok Pisin");
|
||||
Regy_add(stub_hash, Id_tr, "tr", "Türkçe");
|
||||
Regy_add(stub_hash, Id_tru, "tru", "Ṫuroyo");
|
||||
Regy_add(stub_hash, Id_ts, "ts", "Xitsonga");
|
||||
Regy_add(stub_hash, Id_tt, "tt", "Татарча/Tatarça");
|
||||
Regy_add(stub_hash, Id_tt_cyrl, "tt-cyrl", "Татарча");
|
||||
Regy_add(stub_hash, Id_tt_latn, "tt-latn", "Tatarça");
|
||||
Regy_add(stub_hash, Id_ttt, "ttt", "Tat, Muslim");
|
||||
Regy_add(stub_hash, Id_tum, "tum", "chiTumbuka");
|
||||
Regy_add(stub_hash, Id_tw, "tw", "Twi");
|
||||
Regy_add(stub_hash, Id_ty, "ty", "Reo Mā`ohi");
|
||||
Regy_add(stub_hash, Id_tyv, "tyv", "Тыва дыл");
|
||||
Regy_add(stub_hash, Id_tzm, "tzm", "ⵜⴰⵎⴰⵣⵉⵖⵜ");
|
||||
Regy_add(stub_hash, Id_udm, "udm", "Удмурт");
|
||||
Regy_add(stub_hash, Id_ug, "ug", "ئۇيغۇرچە / Uyghurche");
|
||||
Regy_add(stub_hash, Id_ug_arab, "ug-arab", "ئۇيغۇرچە");
|
||||
Regy_add(stub_hash, Id_ug_latn, "ug-latn", "Uyghurche");
|
||||
Regy_add(stub_hash, Id_uk, "uk", "Українська");
|
||||
Regy_add(stub_hash, Id_ur, "ur", "اردو");
|
||||
Regy_add(stub_hash, Id_uz, "uz", "O'zbek");
|
||||
Regy_add(stub_hash, Id_ve, "ve", "Tshivenda");
|
||||
Regy_add(stub_hash, Id_vec, "vec", "Vèneto");
|
||||
Regy_add(stub_hash, Id_vep, "vep", "Vepsan kel'");
|
||||
Regy_add(stub_hash, Id_vi, "vi", "Tiếng Việt");
|
||||
Regy_add(stub_hash, Id_vls, "vls", "West-Vlams");
|
||||
Regy_add(stub_hash, Id_vmf, "vmf", "Mainfränkisch");
|
||||
Regy_add(stub_hash, Id_vo, "vo", "Volapük");
|
||||
Regy_add(stub_hash, Id_vot, "vot", "Vaďďa");
|
||||
Regy_add(stub_hash, Id_vro, "vro", "Võro");
|
||||
Regy_add(stub_hash, Id_wa, "wa", "Walon");
|
||||
Regy_add(stub_hash, Id_war, "war", "Winaray");
|
||||
Regy_add(stub_hash, Id_wo, "wo", "Wolof");
|
||||
Regy_add(stub_hash, Id_wuu, "wuu", "吴语");
|
||||
Regy_add(stub_hash, Id_xal, "xal", "Хальмг");
|
||||
Regy_add(stub_hash, Id_xh, "xh", "isiXhosa");
|
||||
Regy_add(stub_hash, Id_xmf, "xmf", "მარგალური");
|
||||
Regy_add(stub_hash, Id_yi, "yi", "ייִדיש");
|
||||
Regy_add(stub_hash, Id_yo, "yo", "Yorùbá");
|
||||
Regy_add(stub_hash, Id_yue, "yue", "粵語");
|
||||
Regy_add(stub_hash, Id_za, "za", "Vahcuengh");
|
||||
Regy_add(stub_hash, Id_zea, "zea", "Zeêuws");
|
||||
Regy_add(stub_hash, Id_zh, "zh", "中文");
|
||||
Regy_add(stub_hash, Id_zh_classical, "zh-classical", "文言");
|
||||
Regy_add(stub_hash, Id_zh_cn, "zh-cn", "中文(中国大陆)");
|
||||
Regy_add(stub_hash, Id_zh_hans, "zh-hans", "中文(简体)");
|
||||
Regy_add(stub_hash, Id_zh_hant, "zh-hant", "中文(繁體)");
|
||||
Regy_add(stub_hash, Id_zh_hk, "zh-hk", "中文(香港)");
|
||||
Regy_add(stub_hash, Id_zh_min_nan, "zh-min-nan", "Bân-lâm-gú");
|
||||
Regy_add(stub_hash, Id_zh_mo, "zh-mo", "中文(澳門)");
|
||||
Regy_add(stub_hash, Id_zh_my, "zh-my", "中文(马来西亚)");
|
||||
Regy_add(stub_hash, Id_zh_sg, "zh-sg", "中文(新加坡)");
|
||||
Regy_add(stub_hash, Id_zh_tw, "zh-tw", "中文(台灣)");
|
||||
Regy_add(stub_hash, Id_zh_yue, "zh-yue", "粵語");
|
||||
Regy_add(stub_hash, Id_zu, "zu", "isiZulu");
|
||||
}
|
||||
return stub_hash;
|
||||
}
|
||||
private static Hash_adp_bry stub_hash; private static final Xol_lang_stub[] stub_ary = new Xol_lang_stub[Id__max];
|
||||
public static Xol_lang_stub[] Ary() {return stub_ary;}
|
||||
private static void Regy_add(Hash_adp_bry stub_hash, int uid, String code_str, String canonical) {
|
||||
byte[] code = Bry_.new_a7(code_str);// ASCII:lang_code should always be ASCII
|
||||
Xol_lang_stub itm = new Xol_lang_stub(uid, code, Bry_.new_u8(canonical));
|
||||
stub_ary[uid] = itm;
|
||||
stub_hash.Add(code, itm);
|
||||
}
|
||||
public static boolean Exists(byte[] key) {return Get_by_key_or_null(key) != null;} // Language.php!isSupportedLanguage
|
||||
public static Xol_lang_stub Get_by_id(int id) {if (stub_hash == null) Regy(); return stub_ary[id];}
|
||||
public static Xol_lang_stub Get_by_key_or_null(byte[] key) {return Get_by_key_or_null(key, 0, key.length);}
|
||||
public static Xol_lang_stub Get_by_key_or_null(byte[] key, int bgn, int end) {
|
||||
if (stub_hash == null) Regy();
|
||||
return (Xol_lang_stub)stub_hash.Get_by_mid(key, bgn, end);
|
||||
}
|
||||
public static Xol_lang_stub Get_by_key_or_en(byte[] key) {
|
||||
Xol_lang_stub rv = Get_by_key_or_null(key);
|
||||
return (rv == null) ? (Xol_lang_stub)stub_hash.Get_by_bry(Xol_lang_itm_.Key_en) : rv;
|
||||
}
|
||||
public static Xol_lang_stub Get_by_key_or_intl(byte[] key) {return Get_by_key_or_intl(key, 0, key.length);}
|
||||
public static Xol_lang_stub Get_by_key_or_intl(byte[] key, int bgn, int end) {
|
||||
Xol_lang_stub rv = Get_by_key_or_null(key, bgn, end);
|
||||
return rv == null ? Intl : rv;
|
||||
}
|
||||
public static final Xol_lang_stub Intl = new Xol_lang_stub(Xol_lang_stub_.Id__intl, Bry_.Empty, Bry_.Empty); // intended for international wikis like commons, wikidata, etc..
|
||||
}
|
||||
class Xol_sub_itm_comparer implements ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xol_lang_stub lhs = (Xol_lang_stub)lhsObj;
|
||||
Xol_lang_stub rhs = (Xol_lang_stub)rhsObj;
|
||||
return Bry_.Compare(lhs.Key(), rhs.Key());
|
||||
}
|
||||
}
|
||||
83
400_xowa/src/gplx/xowa/langs/bldrs/Json_itm_wkr__base.java
Normal file
83
400_xowa/src/gplx/xowa/langs/bldrs/Json_itm_wkr__base.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.primitives.*; import gplx.langs.jsons.*; import gplx.langs.phps.*; import gplx.langs.gfs.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.parsers.*;
|
||||
interface Json_itm_wkr {
|
||||
void Read_kv_sub(byte[] key, byte[] val);
|
||||
}
|
||||
abstract class Json_itm_wkr__base implements Json_itm_wkr {
|
||||
private Json_parser json_parser = new Json_parser();
|
||||
private Php_text_itm_parser php_quote_parser = new Php_text_itm_parser().Quote_is_single_(true); // assume values are equivalent to php single quote; DATE:2014-08-06
|
||||
public void Exec(byte[] src) {
|
||||
List_adp tmp_list = List_adp_.new_(); Byte_obj_ref tmp_result = Byte_obj_ref.zero_(); Bry_bfr tmp_bfr = Bry_bfr.reset_(16);
|
||||
Json_doc jdoc = json_parser.Parse(src);
|
||||
this.Exec_bgn();
|
||||
Json_nde root = jdoc.Root_nde();
|
||||
int subs_len = root.Len();
|
||||
for (int i = 0; i < subs_len; ++i) {
|
||||
Json_itm itm = root.Get_at(i);
|
||||
switch (itm.Tid()) {
|
||||
case Json_itm_.Tid__kv:
|
||||
Json_kv kv = (Json_kv)itm;
|
||||
if (kv.Key().Data_eq(Name_metadata)) continue; // ignore @metadata node
|
||||
byte[] kv_key = kv.Key().Data_bry();
|
||||
byte[] kv_val = kv.Val().Data_bry();
|
||||
kv_val = php_quote_parser.Parse_as_bry(tmp_list, kv_val, tmp_result, tmp_bfr);
|
||||
Read_kv_sub(kv_key, kv_val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.Exec_end();
|
||||
}
|
||||
@gplx.Virtual public void Exec_bgn() {}
|
||||
@gplx.Virtual public void Exec_end() {}
|
||||
public abstract void Read_kv_sub(byte[] key, byte[] val);
|
||||
private static final byte[] Name_metadata = Bry_.new_a7("@metadata");
|
||||
}
|
||||
class Json_itm_wkr__gfs extends Json_itm_wkr__base {
|
||||
private Xoa_gfs_bldr gfs_bldr = new Xoa_gfs_bldr();
|
||||
private Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
private Bry_bfr bfr;
|
||||
public byte[] Xto_bry() {return gfs_bldr.Xto_bry();}
|
||||
@Override public void Exec_bgn() {
|
||||
bfr = gfs_bldr.Bfr();
|
||||
gfs_bldr.Add_proc_init_many("this", "messages", "load_text").Add_paren_bgn().Add_nl();
|
||||
gfs_bldr.Add_quote_xtn_bgn();
|
||||
}
|
||||
@Override public void Exec_end() {
|
||||
gfs_bldr.Add_quote_xtn_end().Add_paren_end().Add_term_nl();
|
||||
}
|
||||
@Override public void Read_kv_sub(byte[] key, byte[] val) {
|
||||
csv_parser.Save(bfr, key); // key
|
||||
bfr.Add_byte_pipe(); // |
|
||||
csv_parser.Save(bfr, val); // val
|
||||
bfr.Add_byte_nl(); // \n
|
||||
}
|
||||
}
|
||||
class Json_itm_wkr__msgs extends Json_itm_wkr__base {
|
||||
private Xol_msg_mgr msg_mgr; private boolean dirty;
|
||||
public void Ctor(boolean dirty, Xol_msg_mgr msg_mgr) {this.dirty = dirty; this.msg_mgr = msg_mgr;}
|
||||
@Override public void Read_kv_sub(byte[] key, byte[] val) {
|
||||
Xol_msg_itm msg_itm = msg_mgr.Itm_by_key_or_new(key);
|
||||
Xol_msg_itm_.update_val_(msg_itm, val);
|
||||
if (dirty) // bldr needs to dirty message to generate lang.gfs; DATE:2014-08-05
|
||||
msg_itm.Dirty_(true);
|
||||
}
|
||||
}
|
||||
32
400_xowa/src/gplx/xowa/langs/bldrs/Xob_i18n_parser.java
Normal file
32
400_xowa/src/gplx/xowa/langs/bldrs/Xob_i18n_parser.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xob_i18n_parser {
|
||||
public static void Load_msgs(boolean dirty, Xol_lang_itm lang, Io_url i18n_fil) {
|
||||
String i18n_str = Io_mgr.Instance.LoadFilStr_args(i18n_fil).MissingIgnored_().Exec(); if (String_.Len_eq_0(i18n_str)) return;
|
||||
Json_itm_wkr__msgs wkr = new Json_itm_wkr__msgs();
|
||||
wkr.Ctor(dirty, lang.Msg_mgr());
|
||||
wkr.Exec(Bry_.new_u8(i18n_str));
|
||||
}
|
||||
public static byte[] Xto_gfs(byte[] raw) {
|
||||
Json_itm_wkr__gfs wkr = new Json_itm_wkr__gfs();
|
||||
wkr.Exec(raw);
|
||||
return wkr.Xto_bry();
|
||||
}
|
||||
}
|
||||
64
400_xowa/src/gplx/xowa/langs/bldrs/Xob_i18n_parser_tst.java
Normal file
64
400_xowa/src/gplx/xowa/langs/bldrs/Xob_i18n_parser_tst.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.intls.*;
|
||||
public class Xob_i18n_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xob_i18n_parser_fxt fxt = new Xob_i18n_parser_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_xto_gfs(String_.Concat_lines_nl_skip_last
|
||||
( "{"
|
||||
, " \"@metadata\": {"
|
||||
, " \"authors\": []"
|
||||
, " },"
|
||||
, "\"key_1\": \"val_1\","
|
||||
, "\"key_2\": \"val_2\","
|
||||
, "\"key_3\": \"val $1\","
|
||||
, "}"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "this.messages.load_text("
|
||||
, "<:['"
|
||||
, "key_1|val_1"
|
||||
, "key_2|val_2"
|
||||
, "key_3|val ~{0}"
|
||||
, "']:>"
|
||||
, ");"
|
||||
));
|
||||
}
|
||||
// @Test public void Load_msgs_validate() {
|
||||
// fxt.Test_load_msgs_dir("C:\\xowa\\bin\\any\\xowa\\xtns\\Insider\\i18n\\");
|
||||
// }
|
||||
}
|
||||
class Xob_i18n_parser_fxt {
|
||||
public void Clear() {
|
||||
}
|
||||
public void Test_xto_gfs(String raw, String expd) {
|
||||
byte[] actl = Xob_i18n_parser.Xto_gfs(Bry_.new_u8(raw));
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
public void Test_load_msgs_dir(String dir_str) {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
Io_url dir_url = Io_url_.new_dir_(dir_str);
|
||||
Io_url[] fil_urls = Io_mgr.Instance.QueryDir_fils(dir_url);
|
||||
int len = fil_urls.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xob_i18n_parser.Load_msgs(false, wiki.Lang(), fil_urls[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
400_xowa/src/gplx/xowa/langs/bldrs/Xobc_utl_make_lang.java
Normal file
49
400_xowa/src/gplx/xowa/langs/bldrs/Xobc_utl_make_lang.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xobc_utl_make_lang implements GfoInvkAble {
|
||||
private final Xoa_lang_mgr lang_mgr; private final Xoa_fsys_mgr fsys_mgr; Xol_mw_lang_parser lang_parser;
|
||||
public Xobc_utl_make_lang(Xoa_lang_mgr lang_mgr, Xoa_fsys_mgr fsys_mgr, Gfo_msg_log msg_log) {
|
||||
this.lang_mgr = lang_mgr; this.fsys_mgr = fsys_mgr;
|
||||
kwd_mgr = new Xobc_utl_make_lang_kwds(lang_mgr);
|
||||
lang_parser = new Xol_mw_lang_parser(msg_log);
|
||||
}
|
||||
public Xobc_utl_make_lang_kwds Kwd_mgr() {return kwd_mgr;} private Xobc_utl_make_lang_kwds kwd_mgr;
|
||||
public Ordered_hash Manual_text_bgn_hash() {return manual_text_bgn_hash;} private final Ordered_hash manual_text_bgn_hash = Ordered_hash_.New_bry();
|
||||
public Ordered_hash Manual_text_end_hash() {return manual_text_end_hash;} private final Ordered_hash manual_text_end_hash = Ordered_hash_.New_bry();
|
||||
public void Bld_all() {
|
||||
Io_url lang_root = fsys_mgr.Cfg_lang_core_dir().OwnerDir(); // OwnerDir to get "/lang/" in "/cfg/lang/core/"
|
||||
lang_parser.Parse_mediawiki(lang_mgr, lang_root.GenSubDir("mediawiki"), kwd_mgr);
|
||||
kwd_mgr.Add_words();
|
||||
lang_parser.Save_langs(lang_mgr, lang_root.GenSubDir(Xol_mw_lang_parser.Dir_name_core), manual_text_bgn_hash, manual_text_end_hash);
|
||||
Gfo_usr_dlg_.Instance.Prog_many("", "", "done");
|
||||
}
|
||||
public void Parse_manual_text(byte[] key, byte[] text, Ordered_hash manual_text) {
|
||||
manual_text.Add(key, new byte[][] {key, text});
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_kwds)) return kwd_mgr;
|
||||
else if (ctx.Match(k, Invk_build_all)) Bld_all();
|
||||
else if (ctx.Match(k, Invk_manual_text_bgn)) Parse_manual_text(m.ReadBry("langs"), m.ReadBry("text"), manual_text_bgn_hash);
|
||||
else if (ctx.Match(k, Invk_manual_text_end)) Parse_manual_text(m.ReadBry("langs"), m.ReadBry("text"), manual_text_end_hash);
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_kwds = "keywords", Invk_manual_text_bgn = "manual_text_bgn", Invk_manual_text_end = "manual_text_end", Invk_build_all = "build_all";
|
||||
}
|
||||
149
400_xowa/src/gplx/xowa/langs/bldrs/Xobc_utl_make_lang_kwds.java
Normal file
149
400_xowa/src/gplx/xowa/langs/bldrs/Xobc_utl_make_lang_kwds.java
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.parsers.*;
|
||||
public class Xobc_utl_make_lang_kwds implements GfoInvkAble, Xol_lang_transform {
|
||||
private final Xoa_lang_mgr lang_mgr;
|
||||
public Xobc_utl_make_lang_kwds(Xoa_lang_mgr lang_mgr) {this.lang_mgr = lang_mgr;}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_keep_trailing_colon)) Parse_keep_trailing_colon(m.ReadBry("langs"), m.ReadBry("text"));
|
||||
else if (ctx.Match(k, Invk_prepend_hash)) Parse_prepend_hash(m.ReadBry("langs"), m.ReadBry("text"));
|
||||
else if (ctx.Match(k, Invk_add_words)) Parse_add_words(m.ReadBry("langs"), m.ReadBry("text"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_keep_trailing_colon = "keep_trailing_colon", Invk_prepend_hash = "prepend_hash", Invk_add_words = "add_words";
|
||||
|
||||
public byte[] Kwd_transform(byte[] lang_key, byte[] kwd_key, byte[] kwd_word) {
|
||||
byte[] rv = kwd_word;
|
||||
if (!Hash_itm_applies(trailing_colons, lang_key, kwd_key, kwd_word)) {
|
||||
int kwd_last = rv.length - 1;
|
||||
if (kwd_last > 0 && rv[kwd_last] == Byte_ascii.Colon)
|
||||
rv = Bry_.Mid(rv, 0, rv.length - 1);
|
||||
}
|
||||
if (Hash_itm_applies(prepend_hash, lang_key, kwd_key, kwd_word)) {
|
||||
if (rv.length > 0 && rv[0] != Byte_ascii.Hash)
|
||||
rv = Bry_.Add(Byte_ascii.Hash, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Add_words() {
|
||||
Ordered_hash hash = add_words_hash;
|
||||
Ordered_hash tmp = Ordered_hash_.New_bry();
|
||||
int hash_len = hash.Count();
|
||||
for (int i = 0; i < hash_len; i++) {
|
||||
Xobcl_kwd_lang cfg_lang = (Xobcl_kwd_lang)hash.Get_at(i);
|
||||
Xol_lang_itm lang = lang_mgr.Get_by(cfg_lang.Key_bry()); if (lang == null) continue;
|
||||
int cfg_grp_len = cfg_lang.Grps().length;
|
||||
for (int j = 0; j < cfg_grp_len; j++) {
|
||||
Xobcl_kwd_row cfg_grp = cfg_lang.Grps()[j];
|
||||
int kwd_id = Xol_kwd_grp_.Id_by_bry(cfg_grp.Key());
|
||||
if (kwd_id == -1) throw Err_.new_wo_type("could not find kwd for key", "key", String_.new_u8(cfg_grp.Key()));
|
||||
Xol_kwd_grp kwd_grp = lang.Kwd_mgr().Get_at(kwd_id);
|
||||
tmp.Clear();
|
||||
if (kwd_grp == null) {
|
||||
kwd_grp = lang.Kwd_mgr().Get_or_new(kwd_id);
|
||||
kwd_grp.Srl_load(Bool_.N, Bry_.Ary_empty); // ASSUME: kwd explicitly added, but does not exist in language; default to !case_match
|
||||
}
|
||||
|
||||
for (Xol_kwd_itm itm : kwd_grp.Itms())
|
||||
tmp.Add(itm.Val(), itm.Val());
|
||||
if (cfg_grp.Itms().length == 0) {
|
||||
if (!tmp.Has(cfg_grp.Key())) tmp.Add(cfg_grp.Key(), cfg_grp.Key());
|
||||
}
|
||||
else {
|
||||
for (byte[] itm : cfg_grp.Itms()) {
|
||||
if (!tmp.Has(itm)) tmp.Add(itm, itm);
|
||||
}
|
||||
}
|
||||
byte[][] words = (byte[][])tmp.To_ary(byte[].class);
|
||||
kwd_grp.Srl_load(kwd_grp.Case_match(), words);
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean Hash_itm_applies(Ordered_hash hash, byte[] lang_key, byte[] kwd_key, byte[] kwd_word) {
|
||||
Xobcl_kwd_lang cfg_lang = (Xobcl_kwd_lang)hash.Get_by(lang_key); if (cfg_lang == null) return false;
|
||||
Xobcl_kwd_row cfg_grp = cfg_lang.Grps_get_by_key(kwd_key); if (cfg_grp == null) return false;
|
||||
return cfg_grp.Itms().length == 0 || cfg_grp.Itms_has(kwd_word);
|
||||
}
|
||||
public void Parse_add_words(byte[] langs_bry, byte[] kwds) {Parse(langs_bry, kwds, add_words_hash);} private Ordered_hash add_words_hash = Ordered_hash_.New_bry();
|
||||
public void Parse_prepend_hash(byte[] langs_bry, byte[] kwds) {Parse(langs_bry, kwds, prepend_hash);} private Ordered_hash prepend_hash = Ordered_hash_.New_bry();
|
||||
public void Parse_keep_trailing_colon(byte[] langs_bry, byte[] kwds) {Parse(langs_bry, kwds, trailing_colons);} private Ordered_hash trailing_colons = Ordered_hash_.New_bry();
|
||||
private void Parse(byte[] langs_bry, byte[] kwds, Ordered_hash hash) {
|
||||
Xobcl_kwd_row[] itms = Parse(kwds);
|
||||
Xol_lang_stub[] stub_ary = Xol_lang_stub_.Ary(); // NOTE: was "lang_mgr.To_hash(langs_bry);" which was effectively "wiki_types" -> all langs; DATE:2015-10-07
|
||||
int len = stub_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xol_lang_stub stub_itm = stub_ary[i];
|
||||
byte[] key = stub_itm.Key();
|
||||
Xobcl_kwd_lang grp = (Xobcl_kwd_lang)hash.Get_by(key);
|
||||
if (grp == null) {
|
||||
grp = new Xobcl_kwd_lang(key, itms);
|
||||
hash.Add(key, grp);
|
||||
}
|
||||
else
|
||||
grp.Merge(itms);
|
||||
}
|
||||
}
|
||||
@gplx.Internal protected static Xobcl_kwd_row[] Parse(byte[] src) {
|
||||
int src_len = src.length, pos = 0, fld_bgn = 0;
|
||||
byte[] cur_key = Bry_.Empty;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
List_adp rv = List_adp_.new_(); int fld_idx = 0;
|
||||
while (true) {
|
||||
boolean last = pos == src_len; // NOTE: logic occurs b/c of \n}~-> dlm which gobbles up last \n
|
||||
byte b = last ? Byte_ascii.Nl : src[pos];
|
||||
switch (b) {
|
||||
case Byte_ascii.Pipe:
|
||||
cur_key = csv_parser.Load(src, fld_bgn, pos);
|
||||
fld_bgn = pos + 1;
|
||||
++fld_idx;
|
||||
break;
|
||||
case Byte_ascii.Nl:
|
||||
if (pos - fld_bgn > 0 || fld_idx == 1) {
|
||||
byte[] cur_val = csv_parser.Load(src, fld_bgn, pos);
|
||||
Xobcl_kwd_row row = new Xobcl_kwd_row(cur_key, Bry_split_.Split(cur_val, Byte_ascii.Tilde));
|
||||
rv.Add(row);
|
||||
}
|
||||
fld_bgn = pos + 1;
|
||||
fld_idx = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (last) break;
|
||||
++pos;
|
||||
}
|
||||
return (Xobcl_kwd_row[])rv.To_ary(Xobcl_kwd_row.class);
|
||||
}
|
||||
}
|
||||
class Xobcl_kwd_lang {
|
||||
public Xobcl_kwd_lang(byte[] key_bry, Xobcl_kwd_row[] grps) {
|
||||
this.key_bry = key_bry; this.grps = grps;
|
||||
for (Xobcl_kwd_row grp : grps)
|
||||
grps_hash.Add(grp.Key(), grp);
|
||||
}
|
||||
public void Merge(Xobcl_kwd_row[] v) {
|
||||
grps = (Xobcl_kwd_row[])Array_.Resize_add(grps, v);
|
||||
for (Xobcl_kwd_row grp : v) {
|
||||
grps_hash.Add_if_dupe_use_nth(grp.Key(), grp); // NOTE: Add_if_dupe_use_nth instead of Add b/c kwds may be expanded; EX: lst is added to all langs but de requires #lst~#section~Abschnitt~; DATE:2013-06-02
|
||||
}
|
||||
}
|
||||
public Xobcl_kwd_row Grps_get_by_key(byte[] key) {return (Xobcl_kwd_row)grps_hash.Get_by(key);} private Ordered_hash grps_hash = Ordered_hash_.New_bry();
|
||||
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
|
||||
public Xobcl_kwd_row[] Grps() {return grps;} private Xobcl_kwd_row[] grps;
|
||||
}
|
||||
180
400_xowa/src/gplx/xowa/langs/bldrs/Xobc_utl_make_lang_tst.java
Normal file
180
400_xowa/src/gplx/xowa/langs/bldrs/Xobc_utl_make_lang_tst.java
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xobc_utl_make_lang_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xobc_utl_make_lang_fxt fxt = new Xobc_utl_make_lang_fxt();
|
||||
@Test public void Parse() {
|
||||
fxt.Parse_rows(String_.Concat_lines_nl
|
||||
( ""
|
||||
, "if|#if~#si~"
|
||||
, ""
|
||||
, "ifeq|#ifeq~#sieq"
|
||||
, ""
|
||||
, "expr|"
|
||||
)
|
||||
, fxt.row_("if", "#if", "#si")
|
||||
, fxt.row_("ifeq", "#ifeq", "#sieq")
|
||||
, fxt.row_("expr")
|
||||
);
|
||||
}
|
||||
@Test public void Trailing_colon() {
|
||||
fxt.Kwd_mgr().Parse_keep_trailing_colon(Bry_.new_a7("fr"), Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "if|if:~si:~"
|
||||
, "ifeq|"
|
||||
)));
|
||||
fxt.Ini_file_mw_core("fr", String_.Concat_lines_nl
|
||||
( "$magicWords = array("
|
||||
, " 'expr' => array(0, 'expr:'),"
|
||||
, " 'if' => array(0, 'if:', 'si:', 'if_unchanged:'),"
|
||||
, " 'ifeq' => array(0, 'ifeq:', 'sieq:'),"
|
||||
, ");"
|
||||
)
|
||||
);
|
||||
fxt.Mgr().Bld_all();
|
||||
fxt.Tst_file_xo("fr", String_.Concat_lines_nl
|
||||
( "this"
|
||||
, ".keywords"
|
||||
, " .load_text("
|
||||
, "<:['"
|
||||
, "expr|0|expr~"
|
||||
, "if|0|if:~si:~if_unchanged~"
|
||||
, "ifeq|0|ifeq:~sieq:~"
|
||||
, "']:>"
|
||||
, ").lang"
|
||||
, ";"
|
||||
));
|
||||
}
|
||||
@Test public void Prepend_hash() {
|
||||
fxt.Kwd_mgr().Parse_prepend_hash(Bry_.new_a7("fr"), Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "if|if:~si:~"
|
||||
, "ifeq|"
|
||||
, "tag|tag~"
|
||||
)));
|
||||
fxt.Ini_file_mw_core("fr", String_.Concat_lines_nl
|
||||
( "$magicWords = array("
|
||||
, " 'tag' => array( '0', 'etiqueta', 'ETIQUETA', 'tag' ),"
|
||||
, " 'expr' => array(0, 'expr:'),"
|
||||
, " 'if' => array(0, 'if:', 'si:', 'if_unchanged:'),"
|
||||
, " 'ifeq' => array(0, 'ifeq:', 'sieq:'),"
|
||||
, ");"
|
||||
)
|
||||
);
|
||||
fxt.Mgr().Bld_all();
|
||||
fxt.Tst_file_xo("fr", String_.Concat_lines_nl
|
||||
( "this"
|
||||
, ".keywords"
|
||||
, " .load_text("
|
||||
, "<:['"
|
||||
, "tag|0|etiqueta~ETIQUETA~#tag~"
|
||||
, "expr|0|expr~"
|
||||
, "if|0|#if~#si~if_unchanged~"
|
||||
, "ifeq|0|#ifeq~#sieq~"
|
||||
, "']:>"
|
||||
, ").lang"
|
||||
, ";"
|
||||
));
|
||||
}
|
||||
@Test public void Add_words_hash() {
|
||||
fxt.Kwd_mgr().Parse_add_words(Bry_.new_a7("fr"), Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "if|if_new:~if~"
|
||||
, "ifeq|"
|
||||
)));
|
||||
fxt.Ini_file_mw_core("fr", String_.Concat_lines_nl
|
||||
( "$magicWords = array("
|
||||
, " 'if' => array(0, 'if:', 'si:'),"
|
||||
, " 'ifeq' => array(0, 'sieq:'),"
|
||||
, ");"
|
||||
)
|
||||
);
|
||||
fxt.Mgr().Bld_all();
|
||||
fxt.Tst_file_xo("fr", String_.Concat_lines_nl
|
||||
( "this"
|
||||
, ".keywords"
|
||||
, " .load_text("
|
||||
, "<:['"
|
||||
, "if|0|if~si~if_new:~"
|
||||
, "ifeq|0|sieq~ifeq~"
|
||||
, "']:>"
|
||||
, ").lang"
|
||||
, ";"
|
||||
));
|
||||
}
|
||||
@Test public void Manual_text() {
|
||||
fxt.Mgr().Parse_manual_text(Bry_.new_a7("fr"), Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "app;"
|
||||
))
|
||||
, fxt.Mgr().Manual_text_end_hash());
|
||||
fxt.Ini_file_mw_core("fr", String_.Concat_lines_nl
|
||||
( "$magicWords = array("
|
||||
, " 'if' => array(0, 'if:', 'si:'),"
|
||||
, ");"
|
||||
)
|
||||
);
|
||||
fxt.Mgr().Bld_all();
|
||||
fxt.Tst_file_xo("fr", String_.Concat_lines_nl
|
||||
( "this"
|
||||
, ".keywords"
|
||||
, " .load_text("
|
||||
, "<:['"
|
||||
, "if|0|if~si~"
|
||||
, "']:>"
|
||||
, ").lang"
|
||||
, ";"
|
||||
, "app;"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xobc_utl_make_lang_fxt {
|
||||
public Xobc_utl_make_lang Mgr() {return mgr;} private Xobc_utl_make_lang mgr;
|
||||
public Xobc_utl_make_lang_kwds Kwd_mgr() {return mgr.Kwd_mgr();}
|
||||
public Xobc_utl_make_lang_fxt Clear() {
|
||||
app = Xoa_app_fxt.app_();
|
||||
mgr = new Xobc_utl_make_lang(app.Lang_mgr(), app.Fsys_mgr(), app.Msg_log());
|
||||
return this;
|
||||
} private String_bldr sb = String_bldr_.new_(); private Xoae_app app;
|
||||
public Xobcl_kwd_row row_(String key, String... itms) {return new Xobcl_kwd_row(Bry_.new_a7(key), Bry_.Ary(itms));}
|
||||
public void Parse_rows(String raw, Xobcl_kwd_row... expd) {Tfds.Eq_str_lines(Xto_str(expd), Xto_str(Xobc_utl_make_lang_kwds.Parse(Bry_.new_a7(raw))));}
|
||||
public void Ini_file_mw_core(String lang, String raw) {
|
||||
Io_url fil = app.Fsys_mgr().Cfg_lang_core_dir().OwnerDir().GenSubFil_nest("mediawiki", "core_php", "Messages" + String_.UpperFirst(lang) + ".php");
|
||||
Io_mgr.Instance.SaveFilStr(fil, raw);
|
||||
}
|
||||
public void Tst_file_xo(String lang, String expd) {
|
||||
Io_url fil = Xol_lang_itm_.xo_lang_fil_(app.Fsys_mgr(), lang);
|
||||
Tfds.Eq_str_lines(expd, Io_mgr.Instance.LoadFilStr(fil));
|
||||
}
|
||||
private String Xto_str(Xobcl_kwd_row[] expd) {
|
||||
int len = expd.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xobcl_kwd_row row = expd[i];
|
||||
sb.Add(row.Key());
|
||||
byte[][] itms = row.Itms();
|
||||
int itms_len = itms.length;
|
||||
if (itms_len > 0) {
|
||||
sb.Add_char_pipe();
|
||||
for (int j = 0; j < itms_len; j++) {
|
||||
byte[] itm = itms[j];
|
||||
sb.Add(itm).Add_char_pipe();
|
||||
}
|
||||
}
|
||||
sb.Add_char_nl();
|
||||
}
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xobcl_kwd_row {
|
||||
public Xobcl_kwd_row(byte[] key, byte[][] itms) {
|
||||
this.key = key; this.itms = itms;
|
||||
@@ -24,5 +24,5 @@ public class Xobcl_kwd_row {
|
||||
}
|
||||
public byte[] Key() {return key;} private byte[] key;
|
||||
public byte[][] Itms() {return itms;} private byte[][] itms;
|
||||
public boolean Itms_has(byte[] key) {return itms_hash.Has(key);} private Ordered_hash itms_hash = Ordered_hash_.new_bry_();
|
||||
public boolean Itms_has(byte[] key) {return itms_hash.Has(key);} private Ordered_hash itms_hash = Ordered_hash_.New_bry();
|
||||
}
|
||||
@@ -15,15 +15,11 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public interface Cfg_nde_obj {
|
||||
boolean Nde_typ_is_grp();
|
||||
void Nde_atrs_set(byte[][] ary);
|
||||
Cfg_nde_obj Nde_subs_make(byte[] itm_type, byte[] itm_key, byte[][] itm_atrs);
|
||||
void Nde_subs_add(byte[] itm_key, Cfg_nde_obj itm_obj);
|
||||
Cfg_nde_obj Nde_subs_get(byte[] key);
|
||||
int Nde_subs_len();
|
||||
Cfg_nde_obj Nde_subs_get_at(int i);
|
||||
void Nde_subs_del(byte[] key);
|
||||
byte[] Nde_key();
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public interface Xol_lang_transform {
|
||||
byte[] Kwd_transform(byte[] lang_key, byte[] kwd_key, byte[] kwd_word);
|
||||
}
|
||||
class Xol_lang_transform_null implements Xol_lang_transform {
|
||||
public byte[] Kwd_transform(byte[] lang_key, byte[] kwd_key, byte[] kwd_word) {return kwd_word;}
|
||||
public static final Xol_lang_transform_null Instance = new Xol_lang_transform_null(); Xol_lang_transform_null() {}
|
||||
}
|
||||
370
400_xowa/src/gplx/xowa/langs/bldrs/Xol_mw_lang_parser.java
Normal file
370
400_xowa/src/gplx/xowa/langs/bldrs/Xol_mw_lang_parser.java
Normal file
@@ -0,0 +1,370 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.consoles.*; import gplx.core.intls.*; import gplx.langs.phps.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.numbers.*; import gplx.xowa.langs.parsers.*; import gplx.xowa.langs.specials.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xol_mw_lang_parser {
|
||||
private Php_parser parser = new Php_parser(); private Php_evaluator evaluator;
|
||||
public Xol_mw_lang_parser(Gfo_msg_log msg_log) {evaluator = new Php_evaluator(msg_log);}
|
||||
public void Bld_all(Xoa_lang_mgr lang_mgr, Xoa_fsys_mgr fsys_mgr) {Bld_all(lang_mgr, fsys_mgr, Xol_lang_transform_null.Instance);}
|
||||
public void Bld_all(Xoa_lang_mgr lang_mgr, Xoa_fsys_mgr fsys_mgr, Xol_lang_transform lang_transform) {
|
||||
Io_url lang_root = fsys_mgr.Cfg_lang_core_dir().OwnerDir();
|
||||
Parse_mediawiki(lang_mgr, lang_root.GenSubDir("mediawiki"), lang_transform);
|
||||
Save_langs(lang_mgr, lang_root.GenSubDir(Xol_mw_lang_parser.Dir_name_core), Ordered_hash_.New_bry(), Ordered_hash_.New_bry());
|
||||
}
|
||||
public void Save_langs(Xoa_lang_mgr lang_mgr, Io_url xowa_root, Ordered_hash manual_text_bgn, Ordered_hash manual_text_end) {
|
||||
int len = lang_mgr.Len();
|
||||
Xoa_gfs_bldr bldr = new Xoa_gfs_bldr();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xol_lang_itm lang = lang_mgr.Get_at(i);
|
||||
String lang_key = lang.Key_str();
|
||||
Io_url lang_url = xowa_root.GenSubFil(lang_key + ".gfs");
|
||||
Save_langs_by_manual_text(bldr, manual_text_bgn, lang_key);
|
||||
|
||||
Xol_lang_srl.Save_num_mgr(bldr, lang.Num_mgr());
|
||||
bldr.Add_proc_init_many("this").Add_nl();
|
||||
if (lang.Fallback_bry() != null) // NOTE: fallback will often be null; EX: en
|
||||
bldr.Add_proc_cont_one(Xol_lang_itm.Invk_fallback_load).Add_parens_str(lang.Fallback_bry()).Add_nl();
|
||||
if (!lang.Dir_ltr()) // NOTE: only save dir_ltr if false; EX: en
|
||||
bldr.Add_proc_cont_one(Xol_lang_itm.Invk_dir_rtl_).Add_parens_str(Yn.To_str(!lang.Dir_ltr())).Add_nl();
|
||||
Xol_lang_srl.Save_ns_grps(bldr, lang.Ns_names(), Xol_lang_itm.Invk_ns_names);
|
||||
Xol_lang_srl.Save_ns_grps(bldr, lang.Ns_aliases(), Xol_lang_itm.Invk_ns_aliases);
|
||||
Xol_lang_srl.Save_specials(bldr, lang.Specials_mgr());
|
||||
Xol_lang_srl.Save_keywords(bldr, lang.Kwd_mgr());
|
||||
Xol_lang_srl.Save_messages(bldr, lang.Msg_mgr(), true);
|
||||
bldr.Add_term_nl();
|
||||
|
||||
Save_langs_by_manual_text(bldr, manual_text_end, lang_key);
|
||||
Io_mgr.Instance.SaveFilBfr(lang_url, bldr.Bfr());
|
||||
}
|
||||
}
|
||||
private void Save_langs_by_manual_text(Xoa_gfs_bldr bldr, Ordered_hash manual_text_hash, String lang_key) {
|
||||
byte[][] itm = (byte[][])manual_text_hash.Get_by(Bry_.new_u8(lang_key));
|
||||
if (itm != null) bldr.Bfr().Add(itm[1]);
|
||||
}
|
||||
public void Parse_mediawiki(Xoa_lang_mgr lang_mgr, Io_url mediawiki_root, Xol_lang_transform lang_transform) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Parse_file_core_php(lang_mgr, mediawiki_root, bfr, lang_transform);
|
||||
Parse_file_xtns_php(lang_mgr, mediawiki_root, bfr, lang_transform);
|
||||
Parse_file_json(lang_mgr, bfr, lang_transform, mediawiki_root.GenSubDir("core_json"));
|
||||
Parse_file_json(lang_mgr, bfr, lang_transform, mediawiki_root.GenSubDir("xtns_json"));
|
||||
}
|
||||
private void Parse_file_core_php(Xoa_lang_mgr lang_mgr, Io_url mediawiki_root, Bry_bfr bfr, Xol_lang_transform lang_transform) {
|
||||
Io_url dir = mediawiki_root.GenSubDir("core_php");
|
||||
Io_url[] urls = Io_mgr.Instance.QueryDir_fils(dir);
|
||||
int len = urls.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Io_url url = urls[i];
|
||||
try {
|
||||
String lang_key = String_.Replace(String_.Lower(String_.Mid(url.NameOnly(), 8)), "_", "-"); // 8=Messages.length; lower b/c format is MessagesEn.php (need "en")
|
||||
// if (String_.In(lang_key, "qqq", "enrtl", "bbc", "bbc-latn")) continue;
|
||||
String text = Io_mgr.Instance.LoadFilStr(url);
|
||||
Xol_lang_itm lang = lang_mgr.Get_by_or_new(Bry_.new_u8(lang_key));
|
||||
this.Parse_core(text, lang, bfr, lang_transform);
|
||||
} catch (Exception exc) {Err_.Noop(exc); Console_adp__sys.Instance.Write_str_w_nl("failed to parse " + url.NameOnly() + Err_.Message_gplx_full(exc));}
|
||||
}
|
||||
}
|
||||
private void Parse_file_xtns_php(Xoa_lang_mgr lang_mgr, Io_url mediawiki_root, Bry_bfr bfr, Xol_lang_transform lang_transform) {
|
||||
Io_url dir = mediawiki_root.GenSubDir("xtns_php");
|
||||
Io_url[] urls = Io_mgr.Instance.QueryDir_fils(dir);
|
||||
int len = urls.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Io_url url = urls[i];
|
||||
try {
|
||||
String text = Io_mgr.Instance.LoadFilStr(url);
|
||||
boolean prepend_hash = String_.Eq("ParserFunctions.i18n.magic", url.NameOnly());
|
||||
this.Parse_xtn(text, url, lang_mgr, bfr, prepend_hash, lang_transform);
|
||||
} catch (Exception exc) {Err_.Noop(exc); Console_adp__sys.Instance.Write_str_w_nl("failed to parse " + url.NameOnly() + Err_.Message_gplx_full(exc));}
|
||||
}
|
||||
}
|
||||
private void Parse_file_json(Xoa_lang_mgr lang_mgr, Bry_bfr bfr, Xol_lang_transform lang_transform, Io_url root_dir) {
|
||||
Io_url[] dirs = Io_mgr.Instance.QueryDir_args(root_dir).DirOnly_().ExecAsUrlAry();
|
||||
int dirs_len = dirs.length;
|
||||
for (int i = 0; i < dirs_len; i++) {
|
||||
Io_url dir = dirs[i];
|
||||
Io_url[] fils = Io_mgr.Instance.QueryDir_args(dir).ExecAsUrlAry();
|
||||
int fils_len = fils.length;
|
||||
for (int j = 0; j < fils_len; ++j) {
|
||||
Io_url fil = fils[j];
|
||||
try {
|
||||
Xol_lang_itm lang = lang_mgr.Get_by_or_new(Bry_.new_u8(fil.NameOnly()));
|
||||
Xob_i18n_parser.Load_msgs(true, lang, fil);
|
||||
} catch (Exception exc) {Err_.Noop(exc); Console_adp__sys.Instance.Write_str_w_nl(String_.Format("failed to parse json file; url={0} err={1}\n", fil.Raw(), Err_.Message_gplx_full(exc)));}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Parse_core(String text, Xol_lang_itm lang, Bry_bfr bfr, Xol_lang_transform lang_transform) {
|
||||
evaluator.Clear();
|
||||
parser.Parse_tkns(text, evaluator);
|
||||
Php_line[] lines = (Php_line[])evaluator.List().To_ary(Php_line.class);
|
||||
int lines_len = lines.length;
|
||||
List_adp bry_list = List_adp_.new_();
|
||||
for (int i = 0; i < lines_len; i++) {
|
||||
Php_line_assign line = (Php_line_assign)lines[i];
|
||||
byte[] key = line.Key().Val_obj_bry();
|
||||
Object o = Tid_hash.Get_by_bry(key);
|
||||
if (o != null) {
|
||||
Byte_obj_val stub = (Byte_obj_val)o;
|
||||
switch (stub.Val()) {
|
||||
case Tid_namespaceNames:
|
||||
Parse_array_kv(bry_list, line);
|
||||
lang.Ns_names().Ary_set_(Parse_namespace_strings(bry_list, true));
|
||||
break;
|
||||
case Tid_namespaceAliases:
|
||||
Parse_array_kv(bry_list, line);
|
||||
lang.Ns_aliases().Ary_set_(Parse_namespace_strings(bry_list, false));
|
||||
break;
|
||||
case Tid_specialPageAliases:
|
||||
Parse_specials(line, lang.Key_bry(), lang.Specials_mgr());
|
||||
break;
|
||||
case Tid_magicwords:
|
||||
Parse_magicwords(line, lang.Key_bry(), lang.Kwd_mgr(), false, lang_transform);
|
||||
break;
|
||||
case Tid_messages:
|
||||
Parse_array_kv(bry_list, line);
|
||||
Parse_messages(bry_list, lang, bfr);
|
||||
break;
|
||||
case Tid_fallback:
|
||||
byte[] fallback_bry = Php_itm_.Parse_bry(line.Val());
|
||||
if (!Bry_.Eq(fallback_bry, Bool_.True_bry)) // MessagesEn.php has fallback = false; ignore
|
||||
lang.Fallback_bry_(fallback_bry);
|
||||
break;
|
||||
case Tid_rtl:
|
||||
byte[] rtl_bry = Php_itm_.Parse_bry(line.Val());
|
||||
boolean dir_rtl = Bry_.Eq(rtl_bry, Bool_.True_bry);
|
||||
lang.Dir_ltr_(!dir_rtl);
|
||||
break;
|
||||
case Tid_separatorTransformTable:
|
||||
Parse_separatorTransformTable(line, lang.Num_mgr());
|
||||
break;
|
||||
case Tid_digitTransformTable:
|
||||
Parse_digitTransformTable(line, lang.Num_mgr());
|
||||
break;
|
||||
case Tid_digitGroupingPattern:
|
||||
byte[] digitGroupingPattern = Php_itm_.Parse_bry(line.Val());
|
||||
lang.Num_mgr().Num_grp_fmtr().Digit_grouping_pattern_(digitGroupingPattern);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
lang.Evt_lang_changed();
|
||||
}
|
||||
// public static String[] Lang_skip = new String[] {"qqq", "enrtl", "akz", "sxu", "test", "mwv", "rup", "hu-formal", "tzm", "bbc", "bbc-latn", "lrc", "ttt", "gom", "gom-latn"};
|
||||
public static String[] Lang_skip = String_.Ary_empty;
|
||||
public void Parse_xtn(String text, Io_url url, Xoa_lang_mgr lang_mgr, Bry_bfr bfr, boolean prepend_hash, Xol_lang_transform lang_transform) {
|
||||
evaluator.Clear();
|
||||
parser.Parse_tkns(text, evaluator);
|
||||
List_adp bry_list = List_adp_.new_();
|
||||
Php_line[] lines = (Php_line[])evaluator.List().To_ary(Php_line.class);
|
||||
int lines_len = lines.length;
|
||||
for (int i = 0; i < lines_len; i++) {
|
||||
Php_line_assign line = (Php_line_assign)lines[i];
|
||||
byte[] key = line.Key().Val_obj_bry();
|
||||
Object o = Tid_hash.Get_by_bry(key);
|
||||
if (o != null) {
|
||||
Php_key[] subs = line.Key_subs();
|
||||
if (subs.length == 0) continue; // ignore if no lang_key; EX: ['en']
|
||||
byte[] lang_key = subs[0].Val_obj_bry();
|
||||
try {
|
||||
if (String_.In(String_.new_u8(lang_key), Lang_skip)) continue;
|
||||
Xol_lang_itm lang = lang_mgr.Get_by_or_new(lang_key);
|
||||
Byte_obj_val stub = (Byte_obj_val)o;
|
||||
switch (stub.Val()) {
|
||||
case Tid_messages:
|
||||
Parse_array_kv(bry_list, line);
|
||||
Parse_messages(bry_list, lang, bfr);
|
||||
break;
|
||||
case Tid_magicwords:
|
||||
if (line.Key_subs().length == 0) continue; // ignore lines like $magicWords = array();
|
||||
if (line.Key_subs().length > 1) throw Err_.new_wo_type("magicWords in xtn must have only 1 accessor", "len", line.Key_subs().length);
|
||||
Php_key accessor = line.Key_subs()[0];
|
||||
byte[] accessor_bry = accessor.Val_obj_bry();
|
||||
if (Bry_.Eq(accessor_bry, lang_key)) // accessor must match lang_key
|
||||
Parse_magicwords(line, lang.Key_bry(), lang.Kwd_mgr(), prepend_hash, lang_transform);
|
||||
break;
|
||||
}
|
||||
} catch (Exception exc) {Err_.Noop(exc); Console_adp__sys.Instance.Write_str_w_nl("failed to parse " + url.NameOnly() + Err_.Message_gplx_full(exc));}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Parse_array_kv(List_adp rv, Php_line_assign line) {
|
||||
rv.Clear();
|
||||
Php_itm_ary ary = (Php_itm_ary)line.Val();
|
||||
int subs_len = ary.Subs_len();
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
Php_itm_kv kv = (Php_itm_kv)ary.Subs_get(i);
|
||||
rv.Add(Php_itm_.Parse_bry(kv.Key()));
|
||||
rv.Add(Php_itm_.Parse_bry(kv.Val()));
|
||||
}
|
||||
}
|
||||
public Xow_ns[] Parse_namespace_strings(List_adp list, boolean ns_names) {
|
||||
byte[][] brys = (byte[][])list.To_ary(byte[].class);
|
||||
int brys_len = brys.length;
|
||||
Xow_ns[] rv = new Xow_ns[brys_len / 2];
|
||||
int key_dif = ns_names ? 0 : 1;
|
||||
int val_dif = ns_names ? 1 : 0;
|
||||
for (int i = 0; i < brys_len; i+=2) {
|
||||
byte[] kv_key = brys[i + key_dif];
|
||||
byte[] kv_val = brys[i + val_dif];
|
||||
Bry_.Replace_all_direct(kv_val, Byte_ascii.Underline, Byte_ascii.Space); // NOTE: siteInfo.xml names have " " not "_" (EX: "User talk"). for now, follow that convention
|
||||
int ns_id = Id_by_mw_name(kv_key);
|
||||
// if (ns_id == Xow_ns_.Id_null) throw Err_mgr.Instance.fmt_auto_(GRP_KEY, "namespace_names", String_.new_u8(kv_key));
|
||||
rv[i / 2] = new Xow_ns(ns_id, Xow_ns_case_.Id_1st, kv_val, false); // note that Xow_ns is being used as glorified id-name struct; case_match and alias values do not matter
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private void Parse_messages(List_adp rv, Xol_lang_itm lang, Bry_bfr bfr) {
|
||||
byte[][] brys = (byte[][])rv.To_ary(byte[].class);
|
||||
int brys_len = brys.length;
|
||||
Xol_msg_mgr mgr = lang.Msg_mgr();
|
||||
List_adp quote_itm_list = List_adp_.new_(); Byte_obj_ref quote_parse_result = Byte_obj_ref.zero_();
|
||||
for (int i = 0; i < brys_len; i+=2) {
|
||||
byte[] kv_key = brys[i];
|
||||
Xol_msg_itm itm = mgr.Itm_by_key_or_new(kv_key);
|
||||
if (itm == null) continue;
|
||||
byte[] kv_val = brys[i + 1];
|
||||
kv_val = php_quote_parser.Parse_as_bry(quote_itm_list, kv_val, quote_parse_result, bfr);
|
||||
Xol_msg_itm_.update_val_(itm, kv_val);
|
||||
itm.Dirty_(true);
|
||||
}
|
||||
} private Php_text_itm_parser php_quote_parser = new Php_text_itm_parser();
|
||||
private void Parse_magicwords(Php_line_assign line, byte[] lang_key, Xol_kwd_mgr mgr, boolean prepend_hash, Xol_lang_transform lang_transform) {
|
||||
Php_itm_ary ary = (Php_itm_ary)line.Val();
|
||||
int subs_len = ary.Subs_len();
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
Php_itm_sub sub = ary.Subs_get(i);
|
||||
Php_itm_kv kv = (Php_itm_kv)sub;
|
||||
byte[] kv_key = kv.Key().Val_obj_bry();
|
||||
Php_itm_ary kv_ary = (Php_itm_ary)kv.Val();
|
||||
int kv_ary_len = kv_ary.Subs_len();
|
||||
boolean case_match = false; // if 1 arg, default to false
|
||||
int kv_ary_bgn = 0; int words_len = kv_ary_len; // if 1 arg, default to entire kv_ary; words_len
|
||||
int case_match_int = Php_itm_.Parse_int_or(kv_ary.Subs_get(0), Int_.Min_value);
|
||||
if (case_match_int != Int_.Min_value) {
|
||||
case_match = Parse_int_as_bool(kv_ary.Subs_get(0)); // arg[0] is case_match
|
||||
kv_ary_bgn = 1; // arg[1] is 1st word
|
||||
words_len = kv_ary_len - 1; // words.len = kv_len - 1 (skip case_match
|
||||
}
|
||||
byte[][] words = new byte[words_len][];
|
||||
for (int j = kv_ary_bgn; j < kv_ary_len; j++) {
|
||||
Php_itm_sub kv_sub = kv_ary.Subs_get(j);
|
||||
byte[] word = Php_itm_.Parse_bry(kv_sub);
|
||||
// if (prepend_hash && word[0] != Byte_ascii.Hash) word = Bry_.Add(Byte_ascii.Hash, word);
|
||||
words[j - kv_ary_bgn] = lang_transform.Kwd_transform(lang_key, kv_key, word);
|
||||
}
|
||||
int keyword_id = Xol_kwd_grp_.Id_by_bry(kv_key); if (keyword_id == -1) continue; //throw Err_mgr.Instance.fmt_(Err_scope_keywords, "invalid_key", "key does not have id", String_.new_u8(kv_key));
|
||||
Xol_kwd_grp grp = mgr.Get_or_new(keyword_id);
|
||||
grp.Srl_load(case_match, words);
|
||||
}
|
||||
}
|
||||
private void Parse_specials(Php_line_assign line, byte[] lang_key, Xol_specials_mgr specials_mgr) {
|
||||
specials_mgr.Clear(); // NOTE: always clear, else will try to readd to en.gfs
|
||||
Php_itm_ary ary = (Php_itm_ary)line.Val();
|
||||
int subs_len = ary.Subs_len();
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
Php_itm_sub sub = ary.Subs_get(i);
|
||||
Php_itm_kv kv = (Php_itm_kv)sub;
|
||||
byte[] kv_key = kv.Key().Val_obj_bry();
|
||||
Php_itm_ary kv_ary = (Php_itm_ary)kv.Val();
|
||||
int kv_ary_len = kv_ary.Subs_len();
|
||||
byte[][] aliases = new byte[kv_ary_len][];
|
||||
for (int j = 0; j < kv_ary_len; j++) {
|
||||
Php_itm_sub kv_sub = kv_ary.Subs_get(j);
|
||||
aliases[j] = Php_itm_.Parse_bry(kv_sub);
|
||||
}
|
||||
specials_mgr.Add(kv_key, aliases);
|
||||
}
|
||||
}
|
||||
private boolean Parse_int_as_bool(Php_itm itm) {
|
||||
int rv = Php_itm_.Parse_int_or(itm, Int_.Min_value);
|
||||
if (rv == Int_.Min_value) throw Err_.new_wo_type("value must be 0 or 1", "val", String_.new_u8(itm.Val_obj_bry()));
|
||||
return rv == 1;
|
||||
}
|
||||
private void Parse_separatorTransformTable(Php_line_assign line, Xol_num_mgr num_mgr) {
|
||||
if (line.Val().Itm_tid() == Php_itm_.Tid_null) return;// en is null; $separatorTransformTable = null;
|
||||
Php_itm_ary ary = (Php_itm_ary)line.Val();
|
||||
int subs_len = ary.Subs_len();
|
||||
List_adp tmp_list = List_adp_.new_(); Byte_obj_ref tmp_result = Byte_obj_ref.zero_(); Bry_bfr tmp_bfr = Bry_bfr.reset_(16);
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
Php_itm_kv kv = (Php_itm_kv)ary.Subs_get(i);
|
||||
byte[] key_bry = Php_itm_.Parse_bry(kv.Key()), val_bry = Php_itm_.Parse_bry(kv.Val());
|
||||
val_bry = php_quote_parser.Parse_as_bry(tmp_list, val_bry, tmp_result, tmp_bfr);
|
||||
Xol_csv_parser.Instance.Load(tmp_bfr, val_bry);
|
||||
val_bry = tmp_bfr.To_bry_and_clear();
|
||||
if ( Bry_.Eq(key_bry, Bry_separatorTransformTable_dot)
|
||||
|| Bry_.Eq(key_bry, Bry_separatorTransformTable_comma)
|
||||
)
|
||||
num_mgr.Separators_mgr().Set(key_bry, val_bry);
|
||||
else throw Err_.new_unhandled(String_.new_u8(key_bry)); // NOTE: as of v1.22.2, all Messages only have a key of "." or "," DATE:2014-04-15
|
||||
}
|
||||
} private static final byte[] Bry_separatorTransformTable_comma = new byte[] {Byte_ascii.Comma}, Bry_separatorTransformTable_dot = new byte[] {Byte_ascii.Dot};
|
||||
private void Parse_digitTransformTable(Php_line_assign line, Xol_num_mgr num_mgr) {
|
||||
if (line.Val().Itm_tid() == Php_itm_.Tid_null) return;// en is null; $digitTransformTable = null;
|
||||
Php_itm_ary ary = (Php_itm_ary)line.Val();
|
||||
int subs_len = ary.Subs_len();
|
||||
List_adp tmp_list = List_adp_.new_(); Byte_obj_ref tmp_result = Byte_obj_ref.zero_(); Bry_bfr tmp_bfr = Bry_bfr.reset_(16);
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
Php_itm_kv kv = (Php_itm_kv)ary.Subs_get(i);
|
||||
byte[] key_bry = Php_itm_.Parse_bry(kv.Key()), val_bry = Php_itm_.Parse_bry(kv.Val());
|
||||
val_bry = php_quote_parser.Parse_as_bry(tmp_list, val_bry, tmp_result, tmp_bfr);
|
||||
num_mgr.Digits_mgr().Set(key_bry, val_bry);
|
||||
}
|
||||
}
|
||||
private static final byte
|
||||
Tid_namespaceNames = 0, Tid_namespaceAliases = 1, Tid_specialPageAliases = 2
|
||||
, Tid_messages = 3, Tid_magicwords = 4
|
||||
, Tid_fallback = 5, Tid_rtl = 6
|
||||
, Tid_separatorTransformTable = 7, Tid_digitTransformTable = 8, Tid_digitGroupingPattern = 9
|
||||
;
|
||||
private static Hash_adp_bry Tid_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("namespaceNames", Tid_namespaceNames).Add_str_byte("namespaceAliases", Tid_namespaceAliases).Add_str_byte("specialPageAliases", Tid_specialPageAliases)
|
||||
.Add_str_byte("messages", Tid_messages).Add_str_byte("magicWords", Tid_magicwords)
|
||||
.Add_str_byte("fallback", Tid_fallback).Add_str_byte("rtl", Tid_rtl)
|
||||
.Add_str_byte("separatorTransformTable", Tid_separatorTransformTable)
|
||||
.Add_str_byte("digitTransformTable", Tid_digitTransformTable).Add_str_byte("digitGroupingPattern", Tid_digitGroupingPattern)
|
||||
;
|
||||
public static int Id_by_mw_name(byte[] src) {
|
||||
if (mw_names == null) {
|
||||
mw_names = Btrie_slim_mgr.cs();
|
||||
mw_names.Add_obj("NS_MEDIA", Int_obj_val.new_(Xow_ns_.Id_media));
|
||||
mw_names.Add_obj("NS_SPECIAL", Int_obj_val.new_(Xow_ns_.Id_special));
|
||||
mw_names.Add_obj("NS_MAIN", Int_obj_val.new_(Xow_ns_.Id_main));
|
||||
mw_names.Add_obj("NS_TALK", Int_obj_val.new_(Xow_ns_.Id_talk));
|
||||
mw_names.Add_obj("NS_USER", Int_obj_val.new_(Xow_ns_.Id_user));
|
||||
mw_names.Add_obj("NS_USER_TALK", Int_obj_val.new_(Xow_ns_.Id_user_talk));
|
||||
mw_names.Add_obj("NS_PROJECT", Int_obj_val.new_(Xow_ns_.Id_project));
|
||||
mw_names.Add_obj("NS_PROJECT_TALK", Int_obj_val.new_(Xow_ns_.Id_project_talk));
|
||||
mw_names.Add_obj("NS_FILE", Int_obj_val.new_(Xow_ns_.Id_file));
|
||||
mw_names.Add_obj("NS_FILE_TALK", Int_obj_val.new_(Xow_ns_.Id_file_talk));
|
||||
mw_names.Add_obj("NS_MEDIAWIKI", Int_obj_val.new_(Xow_ns_.Id_mediawiki));
|
||||
mw_names.Add_obj("NS_MEDIAWIKI_TALK", Int_obj_val.new_(Xow_ns_.Id_mediaWiki_talk));
|
||||
mw_names.Add_obj("NS_TEMPLATE", Int_obj_val.new_(Xow_ns_.Id_template));
|
||||
mw_names.Add_obj("NS_TEMPLATE_TALK", Int_obj_val.new_(Xow_ns_.Id_template_talk));
|
||||
mw_names.Add_obj("NS_HELP", Int_obj_val.new_(Xow_ns_.Id_help));
|
||||
mw_names.Add_obj("NS_HELP_TALK", Int_obj_val.new_(Xow_ns_.Id_help_talk));
|
||||
mw_names.Add_obj("NS_CATEGORY", Int_obj_val.new_(Xow_ns_.Id_category));
|
||||
mw_names.Add_obj("NS_CATEGORY_TALK", Int_obj_val.new_(Xow_ns_.Id_category_talk));
|
||||
}
|
||||
Object o = mw_names.Match_exact(src, 0, src.length);
|
||||
return o == null ? Xow_ns_.Id_null : ((Int_obj_val)o).Val();
|
||||
} private static Btrie_slim_mgr mw_names;
|
||||
public static final String Dir_name_core = "core";
|
||||
}
|
||||
317
400_xowa/src/gplx/xowa/langs/bldrs/Xol_mw_lang_parser_tst.java
Normal file
317
400_xowa/src/gplx/xowa/langs/bldrs/Xol_mw_lang_parser_tst.java
Normal file
@@ -0,0 +1,317 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.intls.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.specials.*;
|
||||
public class Xol_mw_lang_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xol_mw_lang_parser_fxt fxt = new Xol_mw_lang_parser_fxt();
|
||||
@Test public void Core_keywords() {
|
||||
fxt.Parse_core("$magicWords = array('toc' => array(0, 'a1', 'a2', 'a3'), 'notoc' => array(1, 'b1', 'b2', 'b3'));")
|
||||
.Tst_keyword(Xol_kwd_grp_.Id_toc, false, "a1", "a2", "a3")
|
||||
.Tst_keyword(Xol_kwd_grp_.Id_notoc, true, "b1", "b2", "b3")
|
||||
;
|
||||
}
|
||||
@Test public void Core_keywords_img_thumb() {
|
||||
fxt.Parse_core("$magicWords = array('img_thumbnail' => array(1, 'thumb', 'thmb'));")
|
||||
.Tst_keyword_img("thumb", Xop_lnki_arg_parser.Tid_thumb)
|
||||
.Tst_keyword_img("thmb" , Xop_lnki_arg_parser.Tid_thumb)
|
||||
.Tst_keyword_img("thum" , Xop_lnki_arg_parser.Tid_caption)
|
||||
;
|
||||
}
|
||||
@Test public void Core_keywords_img_upright() {
|
||||
fxt.Parse_core("$magicWords = array('img_upright' => array(1, 'upright', 'upright=$1', 'upright $1'));")
|
||||
.Tst_keyword_img("upright" , Xop_lnki_arg_parser.Tid_upright)
|
||||
.Tst_keyword_img("upright " , Xop_lnki_arg_parser.Tid_upright)
|
||||
;
|
||||
}
|
||||
@Test public void Core_keywords_func_currentmonth() {
|
||||
Tfds.Now_enabled_y_();
|
||||
fxt.Parse_core("$magicWords = array('currentmonth' => array(0, 'MOISACTUEL'));")
|
||||
.Tst_parse("{{MOISACTUEL}}", "01")
|
||||
;
|
||||
Tfds.Now_enabled_n_();
|
||||
}
|
||||
@Test public void Core_keywords_func_ns() {
|
||||
fxt.Parse_core("$magicWords = array('ns' => array(0, 'ESPACEN'));")
|
||||
.Tst_parse("{{ESPACEN:6}}", "File")
|
||||
;
|
||||
}
|
||||
@Test public void Keywords_img_dim() {
|
||||
fxt.Parse_core("$magicWords = array('img_width' => array(1, '$1pxl'));")
|
||||
.Tst_keyword_img("50pxl", Xop_lnki_arg_parser.Tid_dim)
|
||||
.Tst_keyword_img("50pxlpxl", Xop_lnki_arg_parser.Tid_dim)
|
||||
.Tst_keyword_img("50xl", Xop_lnki_arg_parser.Tid_caption)
|
||||
;
|
||||
}
|
||||
@Test public void Core_namespaces_names() {
|
||||
fxt.Parse_core("$namespaceNames = array(NS_FILE => 'Fichier');")
|
||||
.Sync_ns()
|
||||
.Tst_ns_lkp("Fichier", Xow_ns_.Id_file)
|
||||
.Tst_ns_lkp("File" , Xow_ns_.Id_null)
|
||||
;
|
||||
}
|
||||
@Test public void Core_namespaces_aliases() {
|
||||
fxt.Parse_core("$namespaceAliases = array('Discussion_Fichier' => NS_FILE_TALK);")
|
||||
.Sync_ns()
|
||||
.Tst_ns_lkp("Discussion Fichier", Xow_ns_.Id_file_talk)
|
||||
.Tst_ns_lkp("Discussion Fichierx", Xow_ns_.Id_null)
|
||||
;
|
||||
}
|
||||
@Test public void Core_specialPageAliases() {
|
||||
fxt.Parse_core("$specialPageAliases = array('Randompage' => array('PageAuHasard', 'Page_au_hasard'));")
|
||||
.Test_specialPageAliases("Randompage", "PageAuHasard", "Page_au_hasard")
|
||||
;
|
||||
}
|
||||
@Test public void Xtn_keywords_fr() {fxt.Parse_xtn("$magicWords['fr'] = array('if' => array(0, 'si' ));").Tst_parse("{{si:|y|n}}", "n");}
|
||||
@Test public void Xtn_keywords_de() {fxt.Parse_xtn("$magicWords['de'] = array('if' => array(0, 'si' ));").Tst_parse("{{si:|y|n}}", "<a href=\"/wiki/Template:Si:\">Template:Si:</a>");} // should be "Si", not "si"; ALSO, should probably be "{{si:|y|n}}" not "[[:Template:si:]]" DATE:2014-07-04
|
||||
@Test public void Core_messages() {
|
||||
fxt.Parse_core("$messages = array('sunday' => 'dimanche');")
|
||||
.Tst_message("sunday", 0, "dimanche", false)
|
||||
;
|
||||
}
|
||||
@Test public void Fallback() {
|
||||
fxt.Parse_core("$fallback = 'zh-hans';");
|
||||
Tfds.Eq("zh-hans", String_.new_u8(fxt.Lang().Fallback_bry()));
|
||||
}
|
||||
@Test public void Separator_transform_table() {
|
||||
fxt.Parse_core("$separatorTransformTable = array( ',' => '.', '.' => ',' );");
|
||||
fxt.Num_fmt_tst("1234,56", "1.234.56"); // NOTE: dot is repeated; confirmed with dewiki and {{formatnum:1234,56}}
|
||||
}
|
||||
@Test public void Separator_transform_table_fr() {
|
||||
fxt.Parse_core("$separatorTransformTable = array( ',' => '\\xc2\\xa0', '.' => ',' );");
|
||||
fxt.Num_fmt_tst("1234,56", "1 234 56"); // NOTE: nbsp here; also, nbsp is repeated. see dewiki and {{formatnum:1234,56}}
|
||||
}
|
||||
@Test public void Digit_transform_table() {
|
||||
fxt.Save_file("mem/xowa/bin/any/xowa/cfg/lang/mediawiki/core_php/MessagesFr.php"
|
||||
, "$digitTransformTable = array("
|
||||
, " '0' => 'nulla',"
|
||||
, " '1' => 'I',"
|
||||
, " '2' => 'II',"
|
||||
, " '3' => 'III',"
|
||||
, " '4' => 'IV',"
|
||||
, " '5' => 'V',"
|
||||
, " '6' => 'VI',"
|
||||
, " '7' => 'VII',"
|
||||
, " '8' => 'VIII',"
|
||||
, " '9' => 'IX',"
|
||||
, ");"
|
||||
);
|
||||
fxt.Run_bld_all();
|
||||
fxt.Tst_file("mem/xowa/bin/any/xowa/cfg/lang/core/fr.gfs", String_.Concat_lines_nl
|
||||
( "numbers {"
|
||||
, " digits {"
|
||||
, " clear;"
|
||||
, " set('0', 'nulla');"
|
||||
, " set('1', 'I');"
|
||||
, " set('2', 'II');"
|
||||
, " set('3', 'III');"
|
||||
, " set('4', 'IV');"
|
||||
, " set('5', 'V');"
|
||||
, " set('6', 'VI');"
|
||||
, " set('7', 'VII');"
|
||||
, " set('8', 'VIII');"
|
||||
, " set('9', 'IX');"
|
||||
, " }"
|
||||
, "}"
|
||||
, "this"
|
||||
, ";"
|
||||
));
|
||||
}
|
||||
@Test public void Digit_grouping_pattern() {
|
||||
fxt.Save_file("mem/xowa/bin/any/xowa/cfg/lang/mediawiki/core_php/MessagesFr.php"
|
||||
, "$digitGroupingPattern = '##,##,###'"
|
||||
, ");"
|
||||
);
|
||||
fxt.Run_bld_all();
|
||||
fxt.Tst_file("mem/xowa/bin/any/xowa/cfg/lang/core/fr.gfs", String_.Concat_lines_nl
|
||||
( "numbers {"
|
||||
, " digit_grouping_pattern = '##,##,###';"
|
||||
, "}"
|
||||
, "this"
|
||||
, ";"
|
||||
));
|
||||
}
|
||||
@Test public void Bld() {
|
||||
fxt.Save_file("mem/xowa/bin/any/xowa/cfg/lang/mediawiki/core_php/MessagesFr.php"
|
||||
, "$fallback = 'zh-hans';"
|
||||
, "$rtl = true;"
|
||||
, "$namespaceNames = array(NS_FILE => 'Filex');"
|
||||
, "$namespaceAliases = array('File Discussion' => NS_FILE_TALK);"
|
||||
, "$magicWords = array('currentmonth' => array(0, 'CUR_MONTH'));"
|
||||
, "$messages = array('sunday' => 'sunday');"
|
||||
);
|
||||
fxt.Save_file("mem/xowa/bin/any/xowa/cfg/lang/mediawiki/xtns_php/Test.il8n.php"
|
||||
, "$magicWords['fr'] = array('currentyear' => array(0, 'CUR_YEAR'));"
|
||||
, "$messages['fr'] = array('monday' => 'monday');"
|
||||
);
|
||||
fxt.Save_file("mem/xowa/bin/any/xowa/cfg/lang/mediawiki/core_json/Messages/fr.json"
|
||||
, "{"
|
||||
, " \"@metadata\": {"
|
||||
, " \"authors\": []"
|
||||
, " },"
|
||||
, "\"key_1\": \"val_1\","
|
||||
, "\"key_2\": \"val $1\","
|
||||
, "}"
|
||||
);
|
||||
fxt.Save_file("mem/xowa/bin/any/xowa/cfg/lang/mediawiki/xtns_json/Test2/fr.json"
|
||||
, "{"
|
||||
, " \"@metadata\": {"
|
||||
, " \"authors\": []"
|
||||
, " },"
|
||||
, "\"key_3\": \"val_3\","
|
||||
, "\"key_4\": \"val $1\","
|
||||
, "}"
|
||||
);
|
||||
fxt.Run_bld_all();
|
||||
fxt.Tst_file("mem/xowa/bin/any/xowa/cfg/lang/core/fr.gfs", String_.Concat_lines_nl
|
||||
( "this"
|
||||
, ".fallback_load('zh-hans')"
|
||||
, ".dir_rtl_('y')"
|
||||
, ".ns_names"
|
||||
, " .load_text("
|
||||
, "<:['"
|
||||
, "6|Filex"
|
||||
, "']:>"
|
||||
, ").lang"
|
||||
, ".ns_aliases"
|
||||
, " .load_text("
|
||||
, "<:['"
|
||||
, "7|File Discussion"
|
||||
, "']:>"
|
||||
, ").lang"
|
||||
, ".keywords"
|
||||
, " .load_text("
|
||||
, "<:['"
|
||||
, "currentmonth|0|CUR_MONTH~"
|
||||
, "currentyear|0|CUR_YEAR~"
|
||||
, "']:>"
|
||||
, ").lang"
|
||||
, ".messages"
|
||||
, " .load_text("
|
||||
, "<:['"
|
||||
, "sunday|sunday"
|
||||
, "monday|monday"
|
||||
, "key_1|val_1"
|
||||
, "key_2|val ~{0}"
|
||||
, "key_3|val_3"
|
||||
, "key_4|val ~{0}"
|
||||
, "']:>"
|
||||
, ").lang"
|
||||
, ";"
|
||||
));
|
||||
}
|
||||
@Test public void Dir_ltr() {
|
||||
fxt.Parse_core("$rtl = 'true';");
|
||||
Tfds.Eq(false, fxt.Lang().Dir_ltr());
|
||||
}
|
||||
@Test public void Core_keywords__only_1() { // PURPOSE: some magic words don't specify case-match; EX: Disambiguator.php; DATE:2013-12-24
|
||||
fxt.Parse_core("$magicWords = array('toc' => array('a1'));")
|
||||
.Tst_keyword(Xol_kwd_grp_.Id_toc, false, "a1")
|
||||
;
|
||||
}
|
||||
@Test public void Core_keywords__skip_case_match__1() { // PURPOSE: some magic words don't specify case-match; EX: Disambiguator.php; DATE:2013-12-24
|
||||
fxt.Parse_core("$magicWords = array('toc' => array('a1'));")
|
||||
.Tst_keyword(Xol_kwd_grp_.Id_toc, false, "a1")
|
||||
;
|
||||
}
|
||||
@Test public void Core_keywords__skip_case_match__2() { // PURPOSE: some magic words don't specify case-match; EX: Disambiguator.php; DATE:2013-12-24
|
||||
fxt.Parse_core("$magicWords = array('toc' => array('a1', 'a2'));")
|
||||
.Tst_keyword(Xol_kwd_grp_.Id_toc, false, "a1", "a2")
|
||||
;
|
||||
}
|
||||
}
|
||||
class Xol_mw_lang_parser_fxt {
|
||||
Xoae_app app; Xowe_wiki wiki; private Xop_fxt fxt;
|
||||
Xol_mw_lang_parser parser = new Xol_mw_lang_parser(Gfo_msg_log.Test()); Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public void Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.app_();
|
||||
}
|
||||
app.Lang_mgr().Clear();// NOTE: always clear the lang
|
||||
lang = app.Lang_mgr().Get_by_or_new(Bry_.new_a7("fr"));
|
||||
wiki = Xoa_app_fxt.wiki_(app, "en.wikipedia.org", lang);
|
||||
fxt = new Xop_fxt(app, wiki);
|
||||
lang.Kwd_mgr().Clear(); lang.Msg_mgr().Clear(); // NOTE: clear kwds and msgs else they will be printed to file; this line must go last b/c various xtns will fill in kwds dynamically
|
||||
}
|
||||
public Xol_lang_itm Lang() {return lang;} private Xol_lang_itm lang;
|
||||
public void Num_fmt_tst(String raw, String expd) {Tfds.Eq(expd, String_.new_u8(lang.Num_mgr().Format_num(Bry_.new_u8(raw))));}
|
||||
public void Run_bld_all() {parser.Bld_all(app.Lang_mgr(), app.Fsys_mgr());}
|
||||
public void Save_file(String path, String... lines) {
|
||||
Io_mgr.Instance.SaveFilStr(Io_url_.mem_fil_(path), String_.Concat_lines_nl(lines));
|
||||
}
|
||||
public void Tst_file(String path, String expd) {
|
||||
Io_url url = Io_url_.mem_fil_(path);
|
||||
String actl = Io_mgr.Instance.LoadFilStr(url);
|
||||
Tfds.Eq_str_lines(expd, actl);
|
||||
}
|
||||
public Xol_mw_lang_parser_fxt Parse_core(String raw) {parser.Parse_core(raw, lang, tmp_bfr, Xol_lang_transform_null.Instance); return this;}
|
||||
public Xol_mw_lang_parser_fxt Parse_xtn (String raw) {parser.Parse_xtn(raw, Io_url_.Empty, app.Lang_mgr(), tmp_bfr, false, Xol_lang_transform_null.Instance); lang.Evt_lang_changed(); return this;}
|
||||
public Xol_mw_lang_parser_fxt Tst_keyword(int id, boolean case_sensitive, String... words) {
|
||||
Xol_kwd_grp lst = lang.Kwd_mgr().Get_at(id); if (lst == null) throw Err_.new_wo_type("list should not be null");
|
||||
Tfds.Eq(case_sensitive, lst.Case_match());
|
||||
int actl_len = lst.Itms().length;
|
||||
String[] actl = new String[actl_len];
|
||||
for (int i = 0; i < actl_len; i++)
|
||||
actl[i] = String_.new_u8(lst.Itms()[i].Val());
|
||||
Tfds.Eq_ary_str(words, actl);
|
||||
return this;
|
||||
}
|
||||
public Xol_mw_lang_parser_fxt Tst_keyword_img(String key_str, byte tid) {
|
||||
byte[] key = Bry_.new_u8(key_str);
|
||||
Tfds.Eq(tid, lang.Lnki_arg_parser().Identify_tid(key, 0, key.length));
|
||||
return this;
|
||||
}
|
||||
public Xol_mw_lang_parser_fxt Tst_parse(String raw, String expd) {
|
||||
fxt.Reset();
|
||||
fxt.Test_parse_page_all_str(raw, expd);
|
||||
return this;
|
||||
}
|
||||
public Xol_mw_lang_parser_fxt Tst_ns_lkp(String key_str, int id) {
|
||||
byte[] key = Bry_.new_u8(key_str);
|
||||
Xow_ns ns = (Xow_ns)wiki.Ns_mgr().Names_get_or_null(key, 0, key.length);
|
||||
int actl = ns == null ? Xow_ns_.Id_null : ns.Id();
|
||||
Tfds.Eq(id, actl);
|
||||
return this;
|
||||
}
|
||||
public Xol_mw_lang_parser_fxt Test_specialPageAliases(String special, String... expd_aliases) {
|
||||
Xol_specials_itm actl_aliases = lang.Specials_mgr().Get_by_key(Bry_.new_u8(special));
|
||||
Tfds.Eq_ary_str(expd_aliases, To_str_ary(actl_aliases));
|
||||
return this;
|
||||
}
|
||||
private String[] To_str_ary(Xol_specials_itm itm) {
|
||||
int len = itm.Aliases().length;
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
rv[i] = String_.new_u8((byte[])itm.Aliases()[i]);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Xol_mw_lang_parser_fxt Sync_ns() {
|
||||
Xow_ns_mgr_.rebuild_(lang, wiki.Ns_mgr());
|
||||
return this;
|
||||
}
|
||||
public Xol_mw_lang_parser_fxt Tst_message(String key, int id, String val, boolean fmt) {
|
||||
Xol_msg_itm itm = lang.Msg_mgr().Itm_by_key_or_new(Bry_.new_a7(key));
|
||||
Tfds.Eq(id, itm.Id());
|
||||
Tfds.Eq(val, String_.new_u8(itm.Val()));
|
||||
Tfds.Eq(fmt, itm.Has_fmt_arg());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,11 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.nss.*;
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.langs.parsers.*;
|
||||
public class Xol_ns_grp implements GfoInvkAble {
|
||||
public Xol_ns_grp(Xol_lang lang) {this.lang = lang;} private Xol_lang lang;
|
||||
public Xol_ns_grp(Xol_lang_itm lang) {this.lang = lang;} private Xol_lang_itm lang;
|
||||
public int Len() {return ary.length;}
|
||||
public Xow_ns Get_at(int i) {return ary[i];} private Xow_ns[] ary = Ary_empty;
|
||||
public void Ary_set_(Xow_ns[] v) {this.ary = v;}
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.cases; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.parsers.*;
|
||||
public class Xol_case_itm_ {
|
||||
public static final byte Tid_both = 0, Tid_upper = 1, Tid_lower = 2;
|
||||
public static Xol_case_itm new_(int tid, String src_str, String trg_str) {return new_((byte)tid, Bry_.new_u8(src_str), Bry_.new_u8(trg_str));}
|
||||
@@ -30,7 +31,7 @@ public class Xol_case_itm_ {
|
||||
int src_len = src.length, src_pos = 0, fld_bgn = 0, fld_idx = 0;
|
||||
byte cur_cmd = Byte_.Zero;
|
||||
byte[] cur_lhs = null;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
while (true) {
|
||||
boolean last = src_pos == src_len;
|
||||
byte b = last ? Byte_ascii.Nl : src[src_pos];
|
||||
@@ -73,7 +74,7 @@ public class Xol_case_itm_ {
|
||||
return (Xol_case_itm[])list.To_ary(Xol_case_itm.class);
|
||||
}
|
||||
public static Xol_case_itm[] parse_mw_(byte[] raw) {
|
||||
Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
int pos = 0;
|
||||
pos = parse_mw_grp(hash, raw, Bool_.Y, pos);
|
||||
pos = parse_mw_grp(hash, raw, Bool_.N, pos);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
itm.Case_build_upper(tmp_bfr);
|
||||
int pos = upper_trie.Match_pos();
|
||||
tmp_bfr.Add_mid(src, pos, src_len);
|
||||
return tmp_bfr.Xto_bry_and_clear();
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
public byte[] Case_build_upper(byte[] src) {return Case_build_upper(src, 0, src.length);}
|
||||
public byte[] Case_build_upper(byte[] src, int bgn, int end) {return Case_build(Bool_.Y, src, bgn, end);}
|
||||
@@ -116,7 +116,7 @@ public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
}
|
||||
pos += b_len;
|
||||
}
|
||||
return tmp_bfr.Xto_bry_and_clear();
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
public byte[] Case_build_1st_upper(Bry_bfr bfr, byte[] src, int bgn, int end) {return Case_build_1st(bfr, Bool_.Y, src, bgn, end);}
|
||||
public byte[] Case_build_1st_lower(Bry_bfr bfr, byte[] src, int bgn, int end) {return Case_build_1st(bfr, Bool_.N, src, bgn, end);}
|
||||
@@ -125,7 +125,7 @@ public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
int b_len = gplx.core.intls.Utf8_.Len_of_char_by_1st_byte(src[bgn]);
|
||||
bfr.Add(Case_build(upper, src, bgn, bgn + b_len));
|
||||
bfr.Add_mid(src, bgn + b_len, end);
|
||||
return bfr.Xto_bry_and_clear();
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_add_bulk)) Add_bulk(m.ReadBry("v"));
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Xol_case_mgr_tst {
|
||||
// bfr.Add_bry_comma(itm.Src_ary()).Add_byte_pipe();
|
||||
// bfr.Add_bry_comma(itm.Trg_ary()).Add_byte_nl();
|
||||
// }
|
||||
// Io_mgr.I.SaveFilStr("C:\\test1.txt", bfr.Xto_str_and_clear());
|
||||
// Io_mgr.Instance.SaveFilStr("C:\\test1.txt", bfr.To_str_and_clear());
|
||||
// }
|
||||
}
|
||||
class Xol_case_mgr_fxt {
|
||||
@@ -102,7 +102,7 @@ class Xol_case_mgr_fxt {
|
||||
Xol_case_itm itm = ary[i];
|
||||
sb.Add(Byte_.To_str(itm.Tid())).Add_char_pipe().Add(String_.new_u8(itm.Src_ary())).Add_char_pipe().Add(String_.new_u8(itm.Trg_ary())).Add_char_nl();
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
public String raw_(Xol_case_itm_bry[] itms) {
|
||||
int itms_len = itms.length;
|
||||
@@ -127,7 +127,7 @@ class Xol_case_mgr_fxt {
|
||||
sb.Add("s:14:\"wikiLowerChars\";a:1038:{");
|
||||
raw_ary(sb, lowers);
|
||||
sb.Add("}}");
|
||||
return sb.Xto_str_and_clear();
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
private void raw_ary(String_bldr sb, String[] ary) {
|
||||
int ary_len = ary.length;
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Cfg_nde_root implements GfoInvkAble {
|
||||
public int Root_len() {return root.Nde_subs_len();}
|
||||
public Cfg_nde_obj Root_get_at(int i) {return (Cfg_nde_obj)root.Nde_subs_get_at(i);} private Ordered_hash grps = Ordered_hash_.new_bry_();
|
||||
public Cfg_nde_obj Root_get(byte[] key) {return (Cfg_nde_obj)root.Nde_subs_get(key);}
|
||||
public Cfg_nde_obj Grps_get(byte[] key) {return (Cfg_nde_obj)grps.Get_by(key);}
|
||||
public Cfg_nde_root Root_(Cfg_nde_obj obj, byte[] typ, byte[][] atrs) {root = obj; grp_type = typ; grp_atrs = atrs; return this;} Cfg_nde_obj root; byte[] grp_type; byte[][] grp_atrs;
|
||||
public void Root_subs_del(byte[] grp_key, byte[] itm_key) {
|
||||
Cfg_nde_obj grp = (Cfg_nde_obj)grps.Get_by(grp_key); if (grp == null) return;
|
||||
grp.Nde_subs_del(itm_key);
|
||||
}
|
||||
public void Root_subs_add(byte[] grp_key, byte[] itm_typ, byte[] itm_key, byte[][] itm_atrs) {
|
||||
Cfg_nde_obj grp = (Cfg_nde_obj)grps.Get_by(grp_key);
|
||||
if (grp == null) {
|
||||
if (Bry_.Len_eq_0(grp_key))
|
||||
grp = root;
|
||||
else {
|
||||
grp = (Cfg_nde_obj)root.Nde_subs_make(grp_type, grp_key, grp_atrs);
|
||||
root.Nde_subs_add(grp_key, grp);
|
||||
grps.Add(grp_key, grp);
|
||||
}
|
||||
}
|
||||
Cfg_nde_obj itm = grp.Nde_subs_get(itm_key);
|
||||
if (itm == null) {
|
||||
itm = (Cfg_nde_obj)grp.Nde_subs_make(itm_typ, itm_key, itm_atrs);
|
||||
grp.Nde_subs_add(itm_key, itm);
|
||||
if (itm.Nde_typ_is_grp()) // created itm is grp; add to root's main registry of grps
|
||||
grps.Add(itm_key, itm);
|
||||
}
|
||||
else
|
||||
if (itm_atrs.length > 0) itm.Nde_atrs_set(itm_atrs);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_set_bulk)) Set_bulk(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_set_bulk = "set_bulk";
|
||||
public void Set_bulk(byte[] src) {
|
||||
int src_len = src.length, src_pos = 0, fld_bgn = 0, fld_idx = 0;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
boolean fail = false;
|
||||
byte cur_cmd = Byte_.Zero;
|
||||
byte[] cur_grp_key = null, cur_itm_typ = null, cur_itm_key = null;
|
||||
List_adp cmds = List_adp_.new_();
|
||||
while (true) {
|
||||
boolean last = src_pos == src_len;
|
||||
byte b = last ? Byte_ascii.Nl : src[src_pos];
|
||||
switch (b) {
|
||||
case Byte_ascii.Pipe:
|
||||
switch (fld_idx) {
|
||||
case 0:
|
||||
fail = true;
|
||||
if (src_pos - fld_bgn == 1) {
|
||||
byte cmd_byte = src[src_pos - 1];
|
||||
cur_cmd = Byte_.Zero;
|
||||
switch (cmd_byte) {
|
||||
case Byte_ascii.Plus: cur_cmd = Cfg_nde_cmd.Cmd_add; fail = false; break;
|
||||
case Byte_ascii.Dash: cur_cmd = Cfg_nde_cmd.Cmd_del; fail = false; break;
|
||||
}
|
||||
}
|
||||
if (fail) throw Err_.new_wo_type("cmd is invalid", "cmd", String_.new_u8(src, fld_bgn, src_pos));
|
||||
break;
|
||||
case 1: cur_grp_key = csv_parser.Load(src, fld_bgn, src_pos); break;
|
||||
case 2: cur_itm_typ = csv_parser.Load(src, fld_bgn, src_pos); break;
|
||||
case 3: cur_itm_key = csv_parser.Load(src, fld_bgn, src_pos); break;
|
||||
}
|
||||
++fld_idx;
|
||||
fld_bgn = src_pos + 1;
|
||||
break;
|
||||
case Byte_ascii.Nl:
|
||||
if (!(fld_idx == 0 && fld_bgn == src_pos)) {
|
||||
Cfg_nde_cmd cmd = null;
|
||||
switch (cur_cmd) {
|
||||
case Cfg_nde_cmd.Cmd_add:
|
||||
byte[][] cur_itm_atrs = Bry_.Ary_empty;
|
||||
if (fld_idx == 4) {
|
||||
byte[] cur_itm_atrs_raw = csv_parser.Load(src, fld_bgn, src_pos);
|
||||
cur_itm_atrs = Bry_split_.Split(cur_itm_atrs_raw, Byte_ascii.Tilde);
|
||||
}
|
||||
else if (fld_idx == 3) {
|
||||
cur_itm_key = csv_parser.Load(src, fld_bgn, src_pos);
|
||||
}
|
||||
cmd = new Cfg_nde_cmd(cur_cmd, cur_grp_key, cur_itm_typ, cur_itm_key, cur_itm_atrs);
|
||||
break;
|
||||
case Cfg_nde_cmd.Cmd_del:
|
||||
cur_itm_key = csv_parser.Load(src, fld_bgn, src_pos);
|
||||
cmd = new Cfg_nde_cmd(cur_cmd, cur_grp_key, Bry_.Empty, cur_itm_key, Bry_.Ary_empty);
|
||||
break;
|
||||
}
|
||||
cmds.Add(cmd);
|
||||
}
|
||||
cur_cmd = Byte_.Zero;
|
||||
cur_grp_key = cur_itm_typ = cur_itm_key = null;
|
||||
fld_idx = 0;
|
||||
fld_bgn = src_pos + 1;
|
||||
break;
|
||||
}
|
||||
if (last) break;
|
||||
++src_pos;
|
||||
}
|
||||
int len = cmds.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Cfg_nde_cmd cmd = (Cfg_nde_cmd)cmds.Get_at(i);
|
||||
switch (cmd.Cmd()) {
|
||||
case Cfg_nde_cmd.Cmd_add: Root_subs_add(cmd.Grp_key(), cmd.Itm_typ(), cmd.Itm_key(), cmd.Itm_atrs()); break;
|
||||
case Cfg_nde_cmd.Cmd_del: Root_subs_del(cmd.Grp_key(), cmd.Itm_key()); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
static final String GRP_KEY = "gplx.cfg.root";
|
||||
}
|
||||
class Cfg_nde_cmd {
|
||||
public Cfg_nde_cmd(byte cmd, byte[] grp_key, byte[] itm_typ, byte[] itm_key, byte[][] itm_atrs) {this.cmd = cmd; this.grp_key = grp_key; this.itm_typ = itm_typ; this.itm_key = itm_key; this.itm_atrs = itm_atrs;}
|
||||
public byte Cmd() {return cmd;} private byte cmd;
|
||||
public byte[] Grp_key() {return grp_key;} private byte[] grp_key;
|
||||
public byte[] Itm_typ() {return itm_typ;} private byte[] itm_typ;
|
||||
public byte[] Itm_key() {return itm_key;} private byte[] itm_key;
|
||||
public byte[][] Itm_atrs() {return itm_atrs;} private byte[][] itm_atrs;
|
||||
public static final byte Cmd_add = 1, Cmd_del = 2;
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
interface Xoac_lang_obj {}
|
||||
public class Xoac_lang_grp implements Cfg_nde_obj, Xoac_lang_obj {
|
||||
public Xoac_lang_grp(byte[] key) {this.key_bry = key; this.name_bry = key_bry;}
|
||||
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
|
||||
public byte[] Name_bry() {return name_bry;} public Xoac_lang_grp Name_bry_(byte[] v) {name_bry = v; return this;} private byte[] name_bry;
|
||||
public int Sort_idx() {return sort_idx;} private int sort_idx;
|
||||
public byte[] Nde_key() {return key_bry;}
|
||||
public boolean Nde_typ_is_grp() {return true;}
|
||||
public Cfg_nde_obj Nde_subs_make(byte[] itm_type, byte[] itm_key, byte[][] itm_atrs) {
|
||||
Cfg_nde_obj rv = null;
|
||||
if (Bry_.Eq(itm_type, Make_grp)) rv = new Xoac_lang_grp(itm_key);
|
||||
else if (Bry_.Eq(itm_type, Make_itm)) rv = new Xoac_lang_itm(itm_key);
|
||||
else throw Err_.new_unhandled(itm_type);
|
||||
rv.Nde_atrs_set(itm_atrs);
|
||||
return rv;
|
||||
}
|
||||
public int Nde_subs_len() {return itms.Count();}
|
||||
public Cfg_nde_obj Nde_subs_get_at(int i) {return (Cfg_nde_obj)itms.Get_at(i);}
|
||||
public Cfg_nde_obj Nde_subs_get(byte[] key) {return (Cfg_nde_obj)itms.Get_by(key);}
|
||||
public void Nde_subs_add(byte[] itm_key, Cfg_nde_obj itm_obj) {
|
||||
if (!itm_obj.Nde_typ_is_grp()) {
|
||||
Xoac_lang_itm itm = (Xoac_lang_itm)itm_obj;
|
||||
if (!regy.Has(itm.Key_bry())) regy.Add(itm.Key_bry(), itm);
|
||||
itm.Grp_(this);
|
||||
}
|
||||
itms.Add(itm_key, itm_obj);
|
||||
}
|
||||
public void Nde_subs_del(byte[] key) {
|
||||
Cfg_nde_obj cur_obj = (Cfg_nde_obj)Nde_subs_get(key);
|
||||
if (!cur_obj.Nde_typ_is_grp()) {
|
||||
Xoac_lang_itm cur_itm = (Xoac_lang_itm)cur_obj;
|
||||
Xoac_lang_itm reg_itm = (Xoac_lang_itm)regy.Get_by(key);
|
||||
if (cur_itm.Uid() == reg_itm.Uid()) regy.Del(cur_itm.Key_bry());
|
||||
}
|
||||
itms.Del(key);
|
||||
}
|
||||
public void Nde_atrs_set(byte[][] ary) {
|
||||
int ary_len = ary.length;
|
||||
if (ary_len > 0) name_bry = ary[0];
|
||||
if (ary_len > 1) sort_idx = Bry_.To_int_or(ary[1], -1);
|
||||
}
|
||||
public static final byte[] Make_grp = Bry_.new_a7("grp"), Make_itm = Bry_.new_a7("itm");
|
||||
public int Itms_len() {return itms.Count();}
|
||||
public Cfg_nde_obj Itms_get_at(int i) {return (Cfg_nde_obj)itms.Get_at(i);}
|
||||
Ordered_hash itms = Ordered_hash_.new_bry_();
|
||||
|
||||
private static Ordered_hash regy = Ordered_hash_.new_bry_();
|
||||
public static Xoac_lang_itm Regy_get_or_null(byte[] key) {return (Xoac_lang_itm)regy.Get_by(key);}
|
||||
public static Xoac_lang_itm Regy_get_or_new (byte[] key) {
|
||||
Xoac_lang_itm rv = Regy_get_or_null(key);
|
||||
if (rv == null) {
|
||||
rv = new Xoac_lang_itm(key);
|
||||
regy.Add(key, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xoac_lang_grp_tst {
|
||||
Xoac_lang_grp_fxt fxt = new Xoac_lang_grp_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Add_itm_new() {
|
||||
fxt.Define_bulk(String_.Concat_lines_nl
|
||||
( "+|euro|itm|fr|French"
|
||||
, "+|euro|itm|de|German"
|
||||
)
|
||||
, fxt.grp_("euro").Itms_
|
||||
( fxt.itm_("fr").Local_name_("French")
|
||||
, fxt.itm_("de").Local_name_("German")
|
||||
));
|
||||
}
|
||||
@Test public void Add_itm_nl() {
|
||||
fxt.Define_bulk(String_.Concat_lines_nl
|
||||
( ""
|
||||
, "+|euro|itm|fr|French"
|
||||
, ""
|
||||
)
|
||||
, fxt.grp_("euro").Itms_
|
||||
( fxt.itm_("fr").Local_name_("French")
|
||||
));
|
||||
}
|
||||
@Test public void Add_grp() {
|
||||
fxt.Define_bulk(String_.Concat_lines_nl
|
||||
( "+||grp|euro|European~1"
|
||||
, "+|euro|itm|fr|French"
|
||||
)
|
||||
, fxt.grp_("euro").Name_("European").Sort_idx_(1).Itms_
|
||||
( fxt.itm_("fr").Local_name_("French")
|
||||
));
|
||||
}
|
||||
@Test public void Set_grp() {
|
||||
fxt.Define_bulk(String_.Concat_lines_nl
|
||||
( "+|euro|itm|fr|French"
|
||||
, "+||grp|euro|European"
|
||||
)
|
||||
, fxt.grp_("euro").Name_("European").Itms_
|
||||
( fxt.itm_("fr").Local_name_("French")
|
||||
));
|
||||
}
|
||||
@Test public void Del() {
|
||||
fxt.Define_bulk(String_.Concat_lines_nl
|
||||
( "+|euro|itm|fr|French"
|
||||
, "+|euro|itm|de|German"
|
||||
, "-|euro|fr"
|
||||
)
|
||||
, fxt.grp_("euro").Itms_
|
||||
( fxt.itm_("de").Local_name_("German")
|
||||
));
|
||||
}
|
||||
@Test public void Add_grp_nest() {
|
||||
fxt.Define_bulk(String_.Concat_lines_nl
|
||||
( "+||grp|wiki"
|
||||
, "+|wiki|grp|euro|European"
|
||||
, "+|euro|itm|de|German"
|
||||
)
|
||||
, fxt.grp_("wiki").Itms_
|
||||
( fxt.grp_("euro").Itms_
|
||||
( fxt.itm_("de").Local_name_("German")
|
||||
)));
|
||||
}
|
||||
}
|
||||
class Xoac_lang_grp_fxt {
|
||||
Xoa_lang_mgr lang_mgr; Tst_mgr tst_mgr = new Tst_mgr();
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
lang_mgr = app.Lang_mgr();
|
||||
}
|
||||
public Xoac_lang_itm_chkr itm_(String key) {return new Xoac_lang_itm_chkr(key);}
|
||||
public Xoac_lang_grp_chkr grp_(String key) {return new Xoac_lang_grp_chkr(key);}
|
||||
public Xoac_lang_grp_fxt Define_bulk(String raw, Xoac_lang_grp_chkr... expd) {
|
||||
lang_mgr.Groups().Set_bulk(Bry_.new_u8(raw));
|
||||
tst_mgr.Tst_ary("", expd, To_ary(lang_mgr.Groups()));
|
||||
return this;
|
||||
}
|
||||
Xoac_lang_grp[] To_ary(Cfg_nde_root root) {
|
||||
int len = root.Root_len();
|
||||
Xoac_lang_grp[] rv = new Xoac_lang_grp[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
rv[i] = (Xoac_lang_grp)root.Root_get_at(i); // ASSUME: root only has grps (no itms)
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
abstract class Xoac_lang_chkr_base implements Tst_chkr {
|
||||
public abstract Class<?> TypeOf();
|
||||
public abstract int Chk(Tst_mgr mgr, String path, Object actl);
|
||||
}
|
||||
class Xoac_lang_itm_chkr extends Xoac_lang_chkr_base {
|
||||
public Xoac_lang_itm_chkr(String key) {this.key = key;}
|
||||
public String Key() {return key;} private String key;
|
||||
public Xoac_lang_itm_chkr Local_name_(String v) {local_name = v; return this;} private String local_name;
|
||||
@Override public Class<?> TypeOf() {return Xoac_lang_itm.class;}
|
||||
@Override public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Xoac_lang_itm actl = (Xoac_lang_itm)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(key == null, path, "key", key, String_.new_u8(actl.Key_bry()));
|
||||
rv += mgr.Tst_val(local_name == null, path, "local_name", local_name, String_.new_u8(actl.Local_name_bry()));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Xoac_lang_grp_chkr extends Xoac_lang_chkr_base {
|
||||
public Xoac_lang_grp_chkr(String key) {this.key = key;}
|
||||
public String Key() {return key;} private String key;
|
||||
public Xoac_lang_grp_chkr Name_(String v) {name = v; return this;} private String name;
|
||||
public Xoac_lang_grp_chkr Sort_idx_(int v) {sort_idx = v; return this;} private int sort_idx = -1;
|
||||
public Xoac_lang_grp_chkr Itms_(Xoac_lang_chkr_base... v) {this.itms = v; return this;} private Xoac_lang_chkr_base[] itms;
|
||||
@Override public Class<?> TypeOf() {return Xoac_lang_grp.class;}
|
||||
@Override public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Xoac_lang_grp actl = (Xoac_lang_grp)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(key == null, path, "key", key, String_.new_u8(actl.Key_bry()));
|
||||
rv += mgr.Tst_val(name == null, path, "name", name, String_.new_u8(actl.Name_bry()));
|
||||
rv += mgr.Tst_val(sort_idx == -1, path, "sort_idx", sort_idx, actl.Sort_idx());
|
||||
rv += mgr.Tst_sub_ary(itms, To_ary(actl), path, rv);
|
||||
return rv;
|
||||
}
|
||||
Xoac_lang_obj[] To_ary(Xoac_lang_grp grp) {
|
||||
int len = grp.Itms_len();
|
||||
Xoac_lang_obj[] rv = new Xoac_lang_obj[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
rv[i] = (Xoac_lang_obj)grp.Itms_get_at(i); // ASSUME: grp only has itms (no grps)
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xoac_lang_itm implements Cfg_nde_obj, Xoac_lang_obj {
|
||||
public Xoac_lang_itm(byte[] key) {this.key_bry = key; local_name_bry = key_bry; uid = uid_next++;} static int uid_next = 0;
|
||||
public Xoac_lang_grp Grp() {return grp;} public Xoac_lang_itm Grp_(Xoac_lang_grp v) {grp = v; return this;} private Xoac_lang_grp grp;
|
||||
public int Uid() {return uid;} private int uid;
|
||||
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
|
||||
public byte[] Local_name_bry() {return local_name_bry;} public Xoac_lang_itm Local_name_bry_(byte[] v) {local_name_bry = v; return this;} private byte[] local_name_bry;
|
||||
public byte[] Nde_key() {return key_bry;}
|
||||
public boolean Nde_typ_is_grp() {return false;}
|
||||
public Cfg_nde_obj Nde_subs_make(byte[] itm_type, byte[] itm_key, byte[][] itm_atrs) {throw Err_.new_wo_type("langs cannot have itms", "type", itm_type, "key", itm_key);}
|
||||
public Cfg_nde_obj Nde_subs_get(byte[] key) {throw Err_.new_wo_type("langs cannot have itms", "key", key);}
|
||||
public int Nde_subs_len() {return 0;}
|
||||
public Cfg_nde_obj Nde_subs_get_at(int i) {throw Err_.new_wo_type("langs cannot have itms", "idx", i);}
|
||||
public void Nde_subs_add(byte[] itm_key, Cfg_nde_obj itm_obj) {throw Err_.new_wo_type("langs cannot have itms", "key", String_.new_u8(itm_key));}
|
||||
public void Nde_subs_del(byte[] key) {throw Err_.new_wo_type("langs cannot delete itms", "key", String_.new_u8(key));}
|
||||
public void Nde_atrs_set(byte[][] ary) {
|
||||
if (ary.length != 1) throw Err_.new_wo_type("expecting name only", "name", String_.AryXtoStr(String_.Ary(ary)));
|
||||
local_name_bry = ary[0];
|
||||
}
|
||||
}
|
||||
@@ -76,5 +76,5 @@ class Xol_duration_itm_sorter implements gplx.lists.ComparerAble {
|
||||
Xol_duration_itm rhs = (Xol_duration_itm)rhsObj;
|
||||
return -Long_.Compare(lhs.Seconds(), rhs.Seconds()); // - to sort from largest to smallest
|
||||
}
|
||||
public static final Xol_duration_itm_sorter _ = new Xol_duration_itm_sorter(); Xol_duration_itm_sorter() {}
|
||||
public static final Xol_duration_itm_sorter Instance = new Xol_duration_itm_sorter(); Xol_duration_itm_sorter() {}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.durations; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.langs.msgs.*;
|
||||
public class Xol_duration_mgr {
|
||||
private Xol_msg_itm[] interval_msgs = null;
|
||||
public Xol_duration_mgr(Xol_lang lang) {this.lang = lang;} private Xol_lang lang;
|
||||
public Xol_duration_mgr(Xol_lang_itm lang) {this.lang = lang;} private Xol_lang_itm lang;
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public Xol_interval_itm[] Get_duration_intervals(long seconds, Xol_duration_itm[] intervals) {
|
||||
if (intervals == null) intervals = Xol_duration_itm_.Ary_default;
|
||||
Array_.Sort(intervals, Xol_duration_itm_sorter._);
|
||||
Array_.Sort(intervals, Xol_duration_itm_sorter.Instance);
|
||||
int intervals_len = intervals.length;
|
||||
long val = seconds;
|
||||
List_adp rv = List_adp_.new_();
|
||||
@@ -85,7 +86,7 @@ public class Xol_duration_mgr {
|
||||
tmp_bfr.Add(segs_ary[i]);
|
||||
}
|
||||
tmp_bfr.Add(Msg_and).Add(Msg_word_separator).Add(segs_ary[last_idx]);
|
||||
return tmp_bfr.Xto_bry_and_clear();
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.funcs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xol_func_name_itm {
|
||||
public class Xol_func_itm {
|
||||
public byte Tid() {return tid;} private byte tid = Xot_defn_.Tid_null;
|
||||
public Xot_defn Func() {return func;} private Xot_defn func = Xot_defn_.Null;
|
||||
public void Func_set(Xot_defn v, int colon_pos) {
|
||||
@@ -15,15 +15,16 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.funcs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*; import gplx.core.intls.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xol_func_name_regy {
|
||||
private final Xoa_lang_mgr lang_mgr; private final Xol_lang lang;
|
||||
private final Xol_func_name_itm finder = new Xol_func_name_itm();
|
||||
import gplx.xowa.langs.kwds.*;
|
||||
public class Xol_func_regy {
|
||||
private final Xoa_lang_mgr lang_mgr; private final Xol_lang_itm lang;
|
||||
private final Xol_func_itm finder = new Xol_func_itm();
|
||||
private final Btrie_slim_mgr cs_trie = Btrie_slim_mgr.cs(), ci_trie = Btrie_slim_mgr.ci_u8();
|
||||
public Xol_func_name_regy(Xoa_lang_mgr lang_mgr, Xol_lang lang) {this.lang_mgr = lang_mgr; this.lang = lang;}
|
||||
public void Evt_lang_changed(Xol_lang lang) {
|
||||
public Xol_func_regy(Xoa_lang_mgr lang_mgr, Xol_lang_itm lang) {this.lang_mgr = lang_mgr; this.lang = lang;}
|
||||
public void Evt_lang_changed(Xol_lang_itm lang) {
|
||||
Xol_kwd_mgr kwd_mgr = lang.Kwd_mgr();
|
||||
ci_trie.Clear(); cs_trie.Clear();
|
||||
int[] kwd_ary = Pf_func_.Ary_get(!lang.Kwd_mgr__strx());
|
||||
@@ -57,7 +58,7 @@ public class Xol_func_name_regy {
|
||||
ci_trie.Add_obj(lower_ary, func);
|
||||
}
|
||||
}
|
||||
public Xol_func_name_itm Find_defn(byte[] src, int txt_bgn, int txt_end) {
|
||||
public Xol_func_itm Find_defn(byte[] src, int txt_bgn, int txt_end) {
|
||||
finder.Clear();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (txt_bgn == txt_end) return finder; // NOTE: true when tmpl_name is either not loaded, or doesn't exist
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.langs.genders; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
public class Xol_gender_ {
|
||||
public static Xol_gender new_by_lang_id(int lang_id) {return Xol_gender__basic.I;}
|
||||
public static Xol_gender new_by_lang_id(int lang_id) {return Xol_gender__basic.Instance;}
|
||||
public static final int Tid_male = 0, Tid_female = 1, Tid_unknown = 2;
|
||||
}
|
||||
class Xol_gender__basic implements Xol_gender {
|
||||
@@ -30,5 +30,5 @@ class Xol_gender__basic implements Xol_gender {
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static final Xol_gender__basic I = new Xol_gender__basic(); Xol_gender__basic() {}
|
||||
public static final Xol_gender__basic Instance = new Xol_gender__basic(); Xol_gender__basic() {}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.grammars; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public interface Xol_grammar {
|
||||
boolean Grammar_eval(Bry_bfr bfr, Xol_lang lang, byte[] word, byte[] type);
|
||||
boolean Grammar_eval(Bry_bfr bfr, Xol_lang_itm lang, byte[] word, byte[] type);
|
||||
}
|
||||
|
||||
@@ -38,18 +38,18 @@ public class Xol_grammar_ {
|
||||
}
|
||||
public static Xol_grammar new_by_lang_id(int lang_id) {
|
||||
switch (lang_id) {
|
||||
case Xol_lang_itm_.Id_fi: return new Xol_grammar_fi();
|
||||
case Xol_lang_itm_.Id_ru: return new Xol_grammar_ru();
|
||||
case Xol_lang_itm_.Id_pl: return Xol_grammar__noop._;
|
||||
default: return Xol_grammar__unimplemented._;
|
||||
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_pl: 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 lang, byte[] word, byte[] type) {return false;}
|
||||
public static final Xol_grammar__unimplemented _ = new Xol_grammar__unimplemented(); Xol_grammar__unimplemented() {}
|
||||
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() {}
|
||||
}
|
||||
class Xol_grammar__noop implements Xol_grammar {
|
||||
public boolean Grammar_eval(Bry_bfr bfr, Xol_lang lang, byte[] word, byte[] type) {bfr.Add(word); return true;}
|
||||
public static final Xol_grammar__noop _ = new Xol_grammar__noop(); Xol_grammar__noop() {}
|
||||
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() {}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.grammars; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.urls.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
public class Xol_grammar_fi implements Xol_grammar {
|
||||
public boolean Vowel_harmony(byte[] word, int word_len) {
|
||||
// $aou = preg_match( '/[aou][^äöy]*$/i', $word );
|
||||
@@ -35,7 +35,7 @@ public class Xol_grammar_fi implements Xol_grammar {
|
||||
}
|
||||
return aou_found;
|
||||
}
|
||||
public boolean Grammar_eval(Bry_bfr bfr, Xol_lang lang, byte[] word, byte[] type) {
|
||||
public boolean Grammar_eval(Bry_bfr bfr, Xol_lang_itm lang, byte[] word, byte[] type) {
|
||||
if (Bry_.Len_eq_0(word)) return true; // empty_string returns ""
|
||||
byte tid = Xol_grammar_.Tid_of_type(type);
|
||||
if (tid == Xol_grammar_.Tid_unknown) {bfr.Add(word); return true;} // unknown type returns word
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Xol_grammar_ru implements Xol_grammar {
|
||||
Xol_grammar_ru_genitive_itm itm = new Xol_grammar_ru_genitive_itm(tid, find_bry, repl_bry);
|
||||
trie.Add(find_bry, itm);
|
||||
}
|
||||
public boolean Grammar_eval(Bry_bfr bfr, Xol_lang lang, byte[] word, byte[] type) {
|
||||
public boolean Grammar_eval(Bry_bfr bfr, Xol_lang_itm lang, byte[] word, byte[] type) {
|
||||
if (Bry_.Len_eq_0(word)) return true; // empty_string returns ""
|
||||
byte tid = Xol_grammar_.Tid_of_type(type);
|
||||
switch (tid) {
|
||||
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.kwds; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_kwd_grp {// REF.MW: Messages_en.php; EX: 'redirect' => array( 0, '#REDIRECT' )
|
||||
public Xol_kwd_grp(byte[] key) {this.key = key;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.kwds; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Xol_kwd_grp_ {
|
||||
public static final int
|
||||
@@ -225,8 +225,11 @@ public static final int
|
||||
, Id_strx_replace = 203
|
||||
, Id_strx_explode = 204
|
||||
, Id_strx_urldecode = 205
|
||||
, Id_pagesincategory_pages = 206
|
||||
, Id_pagesincategory_subcats = 207
|
||||
, Id_pagesincategory_files = 208
|
||||
;
|
||||
public static final int Id__max = 206;
|
||||
public static final int Id__max = 209;
|
||||
|
||||
private static byte[] ary_itm_(int id) {
|
||||
switch (id) {
|
||||
@@ -436,6 +439,9 @@ case Xol_kwd_grp_.Id_strx_count: return Bry_.new_a7("count");
|
||||
case Xol_kwd_grp_.Id_strx_replace: return Bry_.new_a7("replace");
|
||||
case Xol_kwd_grp_.Id_strx_explode: return Bry_.new_a7("explode");
|
||||
case Xol_kwd_grp_.Id_strx_urldecode: return Bry_.new_a7("urldecode");
|
||||
case Xol_kwd_grp_.Id_pagesincategory_pages: return Bry_.new_u8("pagesincategory_pages");
|
||||
case Xol_kwd_grp_.Id_pagesincategory_subcats: return Bry_.new_u8("pagesincategory_subcats");
|
||||
case Xol_kwd_grp_.Id_pagesincategory_files: return Bry_.new_u8("pagesincategory_files");
|
||||
default: throw Err_.new_unhandled(id);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.kwds; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_kwd_itm {// NOTE: keeping as separate class b/c may include fmt props later; EX: thumbnail=$1
|
||||
public Xol_kwd_itm(byte[] val) {this.val = val;}
|
||||
public byte[] Val() {return val;} private byte[] val;
|
||||
@@ -15,10 +15,13 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.kwds; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.parsers.*;
|
||||
public class Xol_kwd_mgr implements GfoInvkAble {
|
||||
public Xol_kwd_mgr(Xol_lang lang) {this.lang = lang;} private Xol_lang lang; Xol_kwd_grp[] grps = new Xol_kwd_grp[Xol_kwd_grp_.Id__max];
|
||||
private final Xol_lang_itm lang; private final Xol_kwd_grp[] grps = new Xol_kwd_grp[Xol_kwd_grp_.Id__max];
|
||||
private Btrie_slim_mgr kwd_default_trie; private byte[] kwd_default_key; private boolean kwd_default_init_needed = true;
|
||||
public Xol_kwd_mgr(Xol_lang_itm lang) {this.lang = lang;}
|
||||
public int Len() {return grps.length;}
|
||||
public void Clear() {
|
||||
int len = grps.length;
|
||||
@@ -51,7 +54,6 @@ public class Xol_kwd_mgr implements GfoInvkAble {
|
||||
: kwd_default_trie.Match_bgn(match, 0, match_len) != null
|
||||
;
|
||||
}
|
||||
private Btrie_slim_mgr kwd_default_trie; private byte[] kwd_default_key; private boolean kwd_default_init_needed = true;
|
||||
public Xol_kwd_grp Get_at(int id) {return grps[id];}
|
||||
public Xol_kwd_grp Get_or_new(int id) {
|
||||
Xol_kwd_grp rv = grps[id];
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.kwds; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Xol_kwd_parse_data {
|
||||
public static byte[] Strip(Bry_bfr tmp, byte[] raw, Byte_obj_ref rslt) {
|
||||
@@ -74,7 +74,7 @@ public class Xol_kwd_parse_data {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return dirty ? tmp.Xto_bry_and_clear() : raw;
|
||||
return dirty ? tmp.To_bry_and_clear() : raw;
|
||||
}
|
||||
public static final byte Strip_none = 0, Strip_bgn = 1, Strip_end = 2;
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.kwds; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*; import gplx.core.primitives.*;
|
||||
public class Xol_kwd_parse_data_tst {
|
||||
@Before public void init() {Clear();}
|
||||
@@ -15,10 +15,10 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.lnki_trails; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xol_lnki_trail_mgr implements GfoInvkAble {
|
||||
public Xol_lnki_trail_mgr(Xol_lang lang) {}
|
||||
public Xol_lnki_trail_mgr(Xol_lang_itm lang) {}
|
||||
public void Clear() {trie.Clear();}
|
||||
public int Count() {return trie.Count();}
|
||||
public Btrie_slim_mgr Trie() {return trie;} Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.lnki_trails; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*;
|
||||
public class Xol_lnki_trail_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xol_lnki_trail_mgr_fxt fxt = new Xol_lnki_trail_mgr_fxt();
|
||||
@@ -24,10 +24,10 @@ public class Xol_lnki_trail_mgr_tst {
|
||||
}
|
||||
}
|
||||
class Xol_lnki_trail_mgr_fxt {
|
||||
Xol_lang lang; Xol_lnki_trail_mgr lnki_trail_mgr;
|
||||
Xol_lang_itm lang; Xol_lnki_trail_mgr lnki_trail_mgr;
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
lang = new Xol_lang(app.Lang_mgr(), Bry_.new_a7("fr"));
|
||||
lang = new Xol_lang_itm(app.Lang_mgr(), Bry_.new_a7("fr"));
|
||||
lnki_trail_mgr = lang.Lnki_trail_mgr();
|
||||
}
|
||||
public void Test_add_bulk(String raw, String... expd_ary) {
|
||||
@@ -15,34 +15,34 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_msg_itm {
|
||||
public Xol_msg_itm(int id, byte[] key) {this.id = id; this.key = key;}
|
||||
public int Id() {return id;} public void Id_(int v) {this.id = v;} private int id;
|
||||
public boolean Src_is_missing() {return src == Src_missing;}
|
||||
public byte Src() {return src;} public Xol_msg_itm Src_(byte v) {src = v; return this;} private byte src;
|
||||
public byte[] Key() {return key;} private byte[] key;
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public byte[] Val() {return val;} private byte[] val;
|
||||
public int Src() {return src;} public Xol_msg_itm Src_(int v) {src = v; return this;} private int src;
|
||||
public boolean Src_is_missing() {return src == Src_missing;}
|
||||
public boolean Has_fmt_arg() {return has_fmt_arg;} private boolean has_fmt_arg;
|
||||
public boolean Has_tmpl_txt() {return has_tmpl_txt;} private boolean has_tmpl_txt;
|
||||
public boolean Dirty() {return dirty;} public Xol_msg_itm Dirty_(boolean v) {dirty = v; return this;} private boolean dirty; // BLDR:
|
||||
public void Atrs_set(byte[] val, boolean has_fmt_arg, boolean has_tmpl_txt) {
|
||||
this.val = val; this.has_fmt_arg = has_fmt_arg; this.has_tmpl_txt = has_tmpl_txt;
|
||||
}
|
||||
public boolean Dirty() {return dirty;} public Xol_msg_itm Dirty_(boolean v) {dirty = v; return this;} private boolean dirty;
|
||||
public byte[] Fmt(Bry_bfr bfr, Object... args) {
|
||||
synchronized (tmp_fmtr) {
|
||||
tmp_fmtr.Fmt_(val);
|
||||
tmp_fmtr.Bld_bfr_many(bfr, args);
|
||||
return bfr.Xto_bry_and_clear();
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public byte[] Fmt_tmp(Bry_bfr bfr, byte[] tmp_val, Object... args) {
|
||||
synchronized (tmp_fmtr) {
|
||||
tmp_fmtr.Fmt_(tmp_val);
|
||||
tmp_fmtr.Bld_bfr_many(bfr, args);
|
||||
return bfr.Xto_bry_and_clear();
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public static final byte Src_null = 0, Src_lang = 1, Src_wiki = 2, Src_missing = 3;
|
||||
public static final int Src_null = 0, Src_lang = 1, Src_wiki = 2, Src_missing = 3;
|
||||
private static Bry_fmtr tmp_fmtr = Bry_fmtr.tmp_();
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xol_msg_itm_ {
|
||||
public static final int
|
||||
@@ -511,7 +511,7 @@ case Xol_msg_itm_.Id_xowa_wikidata_links_special: return new_(Xol_msg_itm_.Id_xo
|
||||
}
|
||||
}
|
||||
public static byte[] eval_(Bry_bfr bfr, Xol_msg_itm tmp_msg_itm, byte[] val, Object... args) {
|
||||
val = gplx.xowa.apps.gfss.Xoa_gfs_php_mgr.Xto_gfs(bfr, val);
|
||||
val = gplx.xowa.apps.gfs.Xoa_gfs_php_mgr.Xto_gfs(bfr, val);
|
||||
update_val_(tmp_msg_itm, val);
|
||||
return tmp_fmtr.Bld_bry_many(bfr, args);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*;
|
||||
public class Xol_msg_itm_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xol_msg_itm_fxt fxt = new Xol_msg_itm_fxt();
|
||||
@@ -15,7 +15,8 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.parsers.*;
|
||||
public class Xol_msg_mgr implements GfoInvkAble {
|
||||
private final GfoInvkAble owner; private final boolean owner_is_lang;
|
||||
public Xol_msg_mgr(GfoInvkAble owner, boolean owner_is_lang) {
|
||||
@@ -17,29 +17,29 @@ 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.langs.phps.*; import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.gfss.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
public class Xol_msg_mgr_ {
|
||||
// public static String Get_msg_val_gui_or_null(Xol_lang lang, byte[] pre, byte[] key, byte[] suf) {
|
||||
// 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);
|
||||
// return rv == null ? "<" + String_.new_u8(Bry_.Add(pre, key, suf)) + ">" : rv;
|
||||
// }
|
||||
public static String Get_msg_val_gui_or_empty(Xoa_lang_mgr lang_mgr, Xol_lang lang, byte[] pre, byte[] key, byte[] suf) { // get from lang, else get from en; does not use get_msg_val to skip db lookups; should only be used for gui; DATE:2014-05-28
|
||||
public static String Get_msg_val_gui_or_empty(Xoa_lang_mgr lang_mgr, Xol_lang_itm lang, byte[] pre, byte[] key, byte[] suf) { // get from lang, else get from en; does not use get_msg_val to skip db lookups; should only be used for gui; DATE:2014-05-28
|
||||
String rv = Get_msg_val_gui_or_null(lang_mgr, lang, pre, key, suf);
|
||||
return rv == null ? "" : rv;
|
||||
}
|
||||
public static String Get_msg_val_gui_or(Xoa_lang_mgr lang_mgr, Xol_lang lang, byte[] pre, byte[] key, byte[] suf, String or) {
|
||||
public static String Get_msg_val_gui_or(Xoa_lang_mgr lang_mgr, Xol_lang_itm lang, byte[] pre, byte[] key, byte[] suf, String or) {
|
||||
String rv = Get_msg_val_gui_or_null(lang_mgr, lang, pre, key, suf);
|
||||
return rv == null ? or : rv;
|
||||
}
|
||||
public static String Get_msg_val_gui_or_null(Xoa_lang_mgr lang_mgr, Xol_lang lang, byte[] pre, byte[] key, byte[] suf) { // get from lang, else get from en; does not use get_msg_val to skip db lookups; should only be used for gui; DATE:2014-05-28
|
||||
public static String Get_msg_val_gui_or_null(Xoa_lang_mgr lang_mgr, Xol_lang_itm lang, byte[] pre, byte[] key, byte[] suf) { // get from lang, else get from en; does not use get_msg_val to skip db lookups; should only be used for gui; DATE:2014-05-28
|
||||
byte[] msg_key = Bry_.Add(pre, key, suf);
|
||||
Xol_msg_itm msg_itm = lang.Msg_mgr().Itm_by_key_or_null(msg_key);
|
||||
if (msg_itm == null)
|
||||
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 lang, byte[] msg_key, byte[][] fmt_args) {
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
public static byte[] Get_msg_val(Xowe_wiki wiki, Xol_lang_itm lang, byte[] msg_key, byte[][] fmt_args) {
|
||||
Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_b512();
|
||||
Xol_msg_itm msg_itm = Get_msg_itm(tmp_bfr, wiki, lang, msg_key);
|
||||
byte[] rv = Get_msg_val(tmp_bfr, wiki, msg_itm, fmt_args);
|
||||
tmp_bfr.Mkr_rls();
|
||||
@@ -54,7 +54,7 @@ public class Xol_msg_mgr_ {
|
||||
Bry_fmtr tmp_fmtr = Bry_fmtr.tmp_().Missing_bgn_(Missing_bry).Missing_end_(Bry_.Empty).Missing_adj_(1);
|
||||
tmp_fmtr.Fmt_(msg_val);
|
||||
tmp_fmtr.Bld_bfr(tmp_bfr, fmt_args);
|
||||
msg_val = tmp_bfr.Xto_bry_and_clear();
|
||||
msg_val = tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
if (has_tmpl) {
|
||||
Xop_ctx sub_ctx = Xop_ctx.new_sub_(wiki); Xop_tkn_mkr tkn_mkr = sub_ctx.Tkn_mkr();
|
||||
@@ -63,16 +63,16 @@ public class Xol_msg_mgr_ {
|
||||
}
|
||||
return msg_val;
|
||||
}
|
||||
public static Xol_msg_itm Get_msg_itm(Bry_bfr tmp_bfr, Xowe_wiki wiki, Xol_lang lang, byte[] msg_key) {
|
||||
public static Xol_msg_itm Get_msg_itm(Bry_bfr tmp_bfr, Xowe_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_.NotFound) { // key is of format "key/lang"; EX: "January/en"
|
||||
int msg_key_len = msg_key.length;
|
||||
if (slash_pos != msg_key_len) { // get text after slash; EX: "en"
|
||||
Object o = Xol_lang_itm_.Regy().Get_by_mid(msg_key, slash_pos + 1, msg_key_len);
|
||||
Object o = Xol_lang_stub_.Regy().Get_by_mid(msg_key, slash_pos + 1, msg_key_len);
|
||||
if (o != null) { // text is known lang_code;
|
||||
Xol_lang_itm lang_itm = (Xol_lang_itm)o;
|
||||
lang = wiki.Appe().Lang_mgr().Get_by_key_or_new(lang_itm.Key()); // set lang
|
||||
Xol_lang_stub lang_itm = (Xol_lang_stub)o;
|
||||
lang = wiki.App().Lang_mgr().Get_by_or_new(lang_itm.Key()); // set lang
|
||||
}
|
||||
msg_key_sub_root = Bry_.Mid(msg_key, 0, slash_pos); // set msg to "a" (discarding "/b")
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class Xol_msg_mgr_ {
|
||||
if (msg_page.Missing()) { // [[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).Xto_bry_and_clear(); // set val to <msg_key>
|
||||
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.Src_(Xol_msg_itm.Src_missing);
|
||||
}
|
||||
else {
|
||||
@@ -100,31 +100,31 @@ public class Xol_msg_mgr_ {
|
||||
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 lang, byte[] msg_key, byte[] msg_key_sub_root) {
|
||||
private static Xoae_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 = Xoa_ttl.parse(wiki, 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
|
||||
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().Get_page_from_msg(ttl);
|
||||
if (rv.Missing()) { // [[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 = Xoa_ttl.parse(wiki, Bry_.Add(ns_bry, msg_key_sub_root, Slash_bry, fallback)); // ttl="MediaWiki:msg_key/fallback"
|
||||
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().Get_page_from_msg(ttl);
|
||||
if (!rv.Missing()) break;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static Xol_msg_itm Get_msg_itm_from_gfs(Xowe_wiki wiki, Xol_lang lang, byte[] msg_key_sub_root) {
|
||||
private static Xol_msg_itm Get_msg_itm_from_gfs(Xowe_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();
|
||||
int fallback_ary_len = fallback_ary.length;
|
||||
Xoa_lang_mgr lang_mgr = wiki.Appe().Lang_mgr();
|
||||
Xoa_lang_mgr lang_mgr = wiki.App().Lang_mgr();
|
||||
for (int i = 0; i < fallback_ary_len; i++) {
|
||||
byte[] fallback = fallback_ary[i];
|
||||
Xol_lang fallback_lang = lang_mgr.Get_by_key(fallback);
|
||||
Xol_lang_itm fallback_lang = lang_mgr.Get_by(fallback);
|
||||
if (fallback_lang == null) continue; // NOTE: en has fallback of "false"; ignore bad fallbacks;
|
||||
rv = fallback_lang.Msg_mgr().Itm_by_key_or_null(msg_key_sub_root);
|
||||
if (rv != null) break;
|
||||
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Xol_msg_mgr_tst {
|
||||
Xol_msg_mgr_fxt fxt = new Xol_msg_mgr_fxt();
|
||||
@@ -16,16 +16,16 @@ You should have received a copy of the GNU Affero General Public License
|
||||
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.xowa.html.sidebar.*;
|
||||
import gplx.xowa.htmls.sidebar.*;
|
||||
public class Xow_msg_mgr implements GfoInvkAble {
|
||||
private final Xowe_wiki wiki; private Xol_lang lang; private final Xol_msg_mgr msg_mgr;
|
||||
public Xow_msg_mgr(Xowe_wiki wiki, Xol_lang lang) {
|
||||
private final Xowe_wiki wiki; private Xol_lang_itm lang; private final Xol_msg_mgr msg_mgr;
|
||||
public Xow_msg_mgr(Xowe_wiki wiki, Xol_lang_itm lang) {
|
||||
this.wiki = wiki;
|
||||
this.lang = lang;
|
||||
this.msg_mgr = new Xol_msg_mgr(wiki, false);
|
||||
}
|
||||
public void Clear() {msg_mgr.Clear();}
|
||||
public void Lang_(Xol_lang v) {
|
||||
public void Lang_(Xol_lang_itm v) {
|
||||
this.lang = v;
|
||||
this.Clear();
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class Xow_msg_mgr implements GfoInvkAble {
|
||||
if (accesskey_found)
|
||||
bfr.Add_byte(Byte_ascii.Space).Add_byte(Byte_ascii.Brack_bgn).Add(accesskey_val).Add_byte(Byte_ascii.Brack_end);
|
||||
bfr.Add_byte(Byte_ascii.Quote);
|
||||
byte[] rv = bfr.Xto_bry_and_clear();
|
||||
byte[] rv = bfr.To_bry_and_clear();
|
||||
if (itm == null)
|
||||
return rv;
|
||||
else {
|
||||
|
||||
@@ -52,9 +52,9 @@ public class Xol_num_fmtr_base implements GfoInvkAble {
|
||||
i = dlm_match_pos - 1; // NOTE: handle multi-byte delims
|
||||
}
|
||||
}
|
||||
return tmp.Xto_bry_and_clear();
|
||||
return tmp.To_bry_and_clear();
|
||||
}
|
||||
public byte[] Fmt(int val) {return Fmt(Bry_.new_a7(Int_.Xto_str(val)));}
|
||||
public byte[] Fmt(int val) {return Fmt(Bry_.new_a7(Int_.To_str(val)));}
|
||||
public byte[] Fmt(byte[] src) { // SEE: DOC_1:Fmt
|
||||
int src_len = src.length;
|
||||
int num_bgn = -1, dec_pos = -1;
|
||||
@@ -95,7 +95,7 @@ public class Xol_num_fmtr_base implements GfoInvkAble {
|
||||
Gfo_num_fmt_wkr wkr = Get_or_new(src_len - num_bgn);
|
||||
wkr.Fmt(src, num_bgn, src_len, tmp);
|
||||
}
|
||||
return tmp.Xto_bry_and_clear();
|
||||
return tmp.To_bry_and_clear();
|
||||
}
|
||||
private Gfo_num_fmt_wkr Get_or_new(int src_len) {
|
||||
Gfo_num_fmt_wkr rv = null;
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Xol_num_grp_fmtr {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return dirty ? bfr.Xto_bry_and_clear() : src;
|
||||
return dirty ? bfr.To_bry_and_clear() : src;
|
||||
}
|
||||
private void Fmt_grp(Bry_bfr bfr, byte[] src, int bgn, int end, int len, int grp_len) {
|
||||
int seg_0 = bgn + (len % grp_len); // 5 digit number will have seg_0 of 2; 12345 -> 12,345
|
||||
|
||||
@@ -31,8 +31,8 @@ public class Xol_num_mgr implements GfoInvkAble {
|
||||
return num;
|
||||
}
|
||||
public byte[] Format_num_no_separators(byte[] num) {return Format_num(num, true);}
|
||||
public byte[] Format_num_by_long(long val) {return Format_num(Bry_.new_a7(Long_.Xto_str(val)));}
|
||||
public byte[] Format_num(int val) {return Format_num(Bry_.new_a7(Int_.Xto_str(val)));}
|
||||
public byte[] Format_num_by_long(long val) {return Format_num(Bry_.new_a7(Long_.To_str(val)));}
|
||||
public byte[] Format_num(int val) {return Format_num(Bry_.new_a7(Int_.To_str(val)));}
|
||||
public byte[] Format_num(byte[] num) {return Format_num(num, false);}
|
||||
public byte[] Format_num(byte[] num, boolean skip_commafy) {
|
||||
if (!skip_commafy) {
|
||||
|
||||
@@ -19,21 +19,21 @@ package gplx.xowa.langs.numbers; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
public class Xol_num_mgr_ {
|
||||
public static Xol_num_mgr new_by_lang_id(int lang_id) {
|
||||
switch (lang_id) {
|
||||
case Xol_lang_itm_.Id_be_tarask:
|
||||
case Xol_lang_itm_.Id_bg:
|
||||
case Xol_lang_itm_.Id_ru:
|
||||
case Xol_lang_itm_.Id_pl:
|
||||
case Xol_lang_itm_.Id_uk:
|
||||
case Xol_lang_itm_.Id_es:
|
||||
case Xol_lang_itm_.Id_et:
|
||||
case Xol_lang_itm_.Id_hy:
|
||||
case Xol_lang_itm_.Id_kaa:
|
||||
case Xol_lang_itm_.Id_kk_cyrl:
|
||||
case Xol_lang_itm_.Id_ksh:
|
||||
// case Xol_lang_itm_.Id_ku_ku:
|
||||
case Xol_lang_stub_.Id_be_tarask:
|
||||
case Xol_lang_stub_.Id_bg:
|
||||
case Xol_lang_stub_.Id_ru:
|
||||
case Xol_lang_stub_.Id_pl:
|
||||
case Xol_lang_stub_.Id_uk:
|
||||
case Xol_lang_stub_.Id_es:
|
||||
case Xol_lang_stub_.Id_et:
|
||||
case Xol_lang_stub_.Id_hy:
|
||||
case Xol_lang_stub_.Id_kaa:
|
||||
case Xol_lang_stub_.Id_kk_cyrl:
|
||||
case Xol_lang_stub_.Id_ksh:
|
||||
// case Xol_lang_stub_.Id_ku_ku:
|
||||
return new Xol_num_mgr__commafy_5();
|
||||
case Xol_lang_itm_.Id_km:
|
||||
case Xol_lang_itm_.Id_my: return new Xol_num_mgr__noop();
|
||||
case Xol_lang_stub_.Id_km:
|
||||
case Xol_lang_stub_.Id_my: return new Xol_num_mgr__noop();
|
||||
default: return new Xol_num_mgr();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.btries.*;
|
||||
public class Xol_transform_mgr implements GfoInvkAble {
|
||||
private Btrie_fast_mgr trie_k_to_v = Btrie_fast_mgr.cs();
|
||||
private Btrie_fast_mgr trie_v_to_k = Btrie_fast_mgr.cs();
|
||||
private Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
private Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
private boolean empty = true;
|
||||
public void Clear() {hash.Clear(); trie_k_to_v.Clear(); trie_v_to_k.Clear(); empty = true;}
|
||||
public int Len() {return hash.Count();}
|
||||
|
||||
@@ -15,15 +15,15 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_csv_parser {
|
||||
public void Save(Bry_bfr bfr, byte[] src) {
|
||||
int len = src.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Cr: bfr.Add_byte(Byte_ascii.Backslash); bfr.Add_byte(Byte_ascii.Ltr_r); break;
|
||||
case Byte_ascii.Nl: bfr.Add_byte(Byte_ascii.Backslash); bfr.Add_byte(Byte_ascii.Ltr_n); break;
|
||||
case Byte_ascii.Cr: bfr.Add_byte(Byte_ascii.Backslash); bfr.Add_byte(Byte_ascii.Ltr_r); break;
|
||||
case Byte_ascii.Nl: bfr.Add_byte(Byte_ascii.Backslash); bfr.Add_byte(Byte_ascii.Ltr_n); break;
|
||||
case Byte_ascii.Tab: bfr.Add_byte(Byte_ascii.Backslash); bfr.Add_byte(Byte_ascii.Ltr_t); break;
|
||||
case Byte_ascii.Backslash: bfr.Add_byte(Byte_ascii.Backslash); bfr.Add_byte(Byte_ascii.Backslash); break;
|
||||
case Byte_ascii.Pipe: bfr.Add(Bry_pipe); break;
|
||||
@@ -31,7 +31,7 @@ public class Xol_csv_parser {
|
||||
}
|
||||
}
|
||||
}
|
||||
public byte[] Load(byte[] src, int bgn, int end) {Load(tmp_bfr, src, bgn, end); return tmp_bfr.Xto_bry_and_clear();}
|
||||
public byte[] Load(byte[] src, int bgn, int end) {Load(tmp_bfr, src, bgn, end); return tmp_bfr.To_bry_and_clear();}
|
||||
public void Load(Bry_bfr bfr, byte[] src) {Load(bfr, src, 0, src.length);}
|
||||
public void Load(Bry_bfr bfr, byte[] src, int bgn, int end) {
|
||||
for (int i = bgn; i < end; i++) {
|
||||
@@ -56,7 +56,7 @@ public class Xol_csv_parser {
|
||||
byte[] utf_bytes = new byte[utf_len]; int utf_idx = 0;
|
||||
int utf_pos = i + 2;
|
||||
for (int j = 0; j < utf_len; j++) {
|
||||
int utf_int = Int_.Xto_int_hex(src, utf_pos, utf_pos + 4);
|
||||
int utf_int = Int_.To_int_hex(src, utf_pos, utf_pos + 4);
|
||||
if (utf_int == -1) throw Err_.new_wo_type("invalid value for \\u", "val", String_.new_u8(src, bgn, end));
|
||||
utf_bytes[utf_idx++] = (byte)utf_int;
|
||||
utf_pos += 6;
|
||||
@@ -78,5 +78,5 @@ public class Xol_csv_parser {
|
||||
}
|
||||
private static final byte[] Bry_pipe = Bry_.new_a7("\\u007C");
|
||||
private static final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public static final Xol_csv_parser _ = new Xol_csv_parser(); Xol_csv_parser() {}
|
||||
public static final Xol_csv_parser Instance = new Xol_csv_parser(); Xol_csv_parser() {}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*;
|
||||
public class Xol_csv_parser_tst {
|
||||
Xol_csv_parser_fxt fxt = new Xol_csv_parser_fxt();
|
||||
@@ -27,15 +27,15 @@ public class Xol_csv_parser_tst {
|
||||
@Test public void Utf() {fxt.Tst_load(" ", "\\u00c2\\u00a0");} // NOTE: 1st String is nbsp;
|
||||
}
|
||||
class Xol_csv_parser_fxt {
|
||||
Xol_csv_parser parser = Xol_csv_parser._; Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
Xol_csv_parser parser = Xol_csv_parser.Instance; Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public void Clear() {}
|
||||
public void Tst_save(String raw, String expd) {
|
||||
parser.Save(tmp_bfr, Bry_.new_u8(raw));
|
||||
Tfds.Eq(expd, tmp_bfr.Xto_str_and_clear());
|
||||
Tfds.Eq(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
public void Tst_load(String expd, String raw_str) {
|
||||
byte[] raw = Bry_.new_u8(raw_str);
|
||||
parser.Load(tmp_bfr, raw, 0, raw.length);
|
||||
Tfds.Eq(expd, tmp_bfr.Xto_str_and_clear());
|
||||
Tfds.Eq(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,16 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.intls.*;
|
||||
import gplx.xowa.apps.gfss.*; import gplx.xowa.langs.numbers.*;
|
||||
import gplx.xowa.nss.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.langs.numbers.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.bldrs.*; import gplx.xowa.langs.specials.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xol_lang_srl {
|
||||
public static Xow_ns[] Load_ns_grps(byte[] src) {
|
||||
int src_len = src.length, pos = 0, fld_bgn = 0;
|
||||
int cur_id = -1;
|
||||
List_adp rv = List_adp_.new_(); Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
List_adp rv = List_adp_.new_(); Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
while (true) {
|
||||
boolean last = pos == src_len; // NOTE: logic occurs b/c of \n}~-> dlm which gobbles up last \n
|
||||
byte b = last ? Byte_ascii.Nl : src[pos];
|
||||
@@ -52,7 +53,7 @@ public class Xol_lang_srl {
|
||||
int src_len = src.length, pos = 0, fld_bgn = 0, fld_idx = 0;
|
||||
boolean cur_cs = false; byte[] cur_key = Bry_.Empty;
|
||||
List_adp cur_words = List_adp_.new_();
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
while (true) {
|
||||
boolean last = pos == src_len; // NOTE: logic occurs b/c of \n}~-> dlm which gobbles up last \n
|
||||
byte b = last ? Byte_ascii.Nl : src[pos];
|
||||
@@ -100,7 +101,7 @@ public class Xol_lang_srl {
|
||||
public static void Load_messages(Xol_msg_mgr msg_mgr, byte[] src) {
|
||||
int src_len = src.length, pos = 0, fld_bgn = 0;
|
||||
byte[] cur_key = Bry_.Empty;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
while (true) {
|
||||
boolean last = pos == src_len; // NOTE: logic occurs b/c of \n}~-> dlm which gobbles up last \n
|
||||
byte b = last ? Byte_ascii.Nl : src[pos];
|
||||
@@ -126,7 +127,7 @@ public class Xol_lang_srl {
|
||||
public static void Load_specials(Xol_specials_mgr special_mgr, byte[] src) {
|
||||
int src_len = src.length, pos = 0, fld_bgn = 0;
|
||||
byte[] cur_key = Bry_.Empty;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
while (true) {
|
||||
boolean last = pos == src_len; // NOTE: logic occurs b/c of \n}~-> dlm which gobbles up last \n
|
||||
byte b = last ? Byte_ascii.Nl : src[pos];
|
||||
@@ -148,12 +149,12 @@ public class Xol_lang_srl {
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
public static void Save_num_mgr(Gfs_bldr bldr, Xol_num_mgr num_mgr) {
|
||||
public static void Save_num_mgr(Xoa_gfs_bldr bldr, Xol_num_mgr num_mgr) {
|
||||
Xol_transform_mgr separators_mgr = num_mgr.Separators_mgr(); int separators_len = separators_mgr.Len();
|
||||
Xol_transform_mgr digits_mgr = num_mgr.Digits_mgr(); int digits_len = digits_mgr.Len();
|
||||
byte[] digit_grouping_pattern = num_mgr.Num_grp_fmtr().Digit_grouping_pattern();
|
||||
if (separators_len > 0 || digits_len > 0 || digit_grouping_pattern != null) {
|
||||
bldr.Add_proc_init_one(Xol_lang.Invk_numbers).Add_curly_bgn_nl(); // numbers {
|
||||
bldr.Add_proc_init_one(Xol_lang_itm.Invk_numbers).Add_curly_bgn_nl(); // numbers {
|
||||
if (digit_grouping_pattern != null) {
|
||||
bldr.Add_indent(1).Add_eq_str(Xol_num_mgr.Invk_digit_grouping_pattern, digit_grouping_pattern);
|
||||
}
|
||||
@@ -180,8 +181,8 @@ public class Xol_lang_srl {
|
||||
bldr.Add_curly_end_nl(); // }
|
||||
}
|
||||
}
|
||||
public static void Save_ns_grps(Gfs_bldr bldr, Xol_ns_grp ns_grp, String proc_invk) {
|
||||
int ns_grp_len = ns_grp.Len(); Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
public static void Save_ns_grps(Xoa_gfs_bldr bldr, Xol_ns_grp ns_grp, String proc_invk) {
|
||||
int ns_grp_len = ns_grp.Len(); Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
if (ns_grp_len == 0) return;
|
||||
Bry_bfr bfr = bldr.Bfr();
|
||||
bldr.Add_proc_cont_one(proc_invk).Add_nl();
|
||||
@@ -196,11 +197,11 @@ public class Xol_lang_srl {
|
||||
bldr.Add_quote_xtn_end(); // ']:>\n
|
||||
bldr.Add_paren_end().Add_proc_cont_one(Invk_lang).Add_nl(); // ).lang\n
|
||||
}
|
||||
public static void Save_specials(Gfs_bldr bldr, Xol_specials_mgr specials_mgr) {
|
||||
int specials_len = specials_mgr.Count(); Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
public static void Save_specials(Xoa_gfs_bldr bldr, Xol_specials_mgr specials_mgr) {
|
||||
int specials_len = specials_mgr.Count(); Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
if (specials_len == 0) return;
|
||||
Bry_bfr bfr = bldr.Bfr();
|
||||
bldr.Add_proc_cont_one(Xol_lang.Invk_specials).Add_nl();
|
||||
bldr.Add_proc_cont_one(Xol_lang_itm.Invk_specials).Add_nl();
|
||||
bldr.Add_indent().Add_proc_cont_one(Xol_specials_mgr.Invk_clear).Add_nl();
|
||||
bldr.Add_indent().Add_proc_cont_one(Invk_load_text).Add_paren_bgn().Add_nl(); // .load_text(\n
|
||||
bldr.Add_quote_xtn_bgn(); // <~{\n'
|
||||
@@ -217,8 +218,8 @@ public class Xol_lang_srl {
|
||||
bldr.Add_quote_xtn_end(); // ']:>\n
|
||||
bldr.Add_paren_end().Add_proc_cont_one(Invk_lang).Add_nl(); // ).lang\n
|
||||
}
|
||||
public static void Save_keywords(Gfs_bldr bldr, Xol_kwd_mgr kwd_mgr) {
|
||||
int len = kwd_mgr.Len(); Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
public static void Save_keywords(Xoa_gfs_bldr bldr, Xol_kwd_mgr kwd_mgr) {
|
||||
int len = kwd_mgr.Len(); Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
int count = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xol_kwd_grp grp = kwd_mgr.Get_at(i); if (grp == null) continue; // some items may not be loaded/set by lang
|
||||
@@ -226,7 +227,7 @@ public class Xol_lang_srl {
|
||||
}
|
||||
if (count == 0) return;
|
||||
Bry_bfr bfr = bldr.Bfr();
|
||||
bldr.Add_proc_cont_one(Xol_lang.Invk_keywords).Add_nl(); // .keywords\n
|
||||
bldr.Add_proc_cont_one(Xol_lang_itm.Invk_keywords).Add_nl(); // .keywords\n
|
||||
bldr.Add_indent().Add_proc_cont_one(Invk_load_text).Add_paren_bgn().Add_nl(); // .load_text(\n
|
||||
bldr.Add_quote_xtn_bgn(); // <~{\n'
|
||||
for (int i = 0; i < len; i++) {
|
||||
@@ -245,8 +246,8 @@ public class Xol_lang_srl {
|
||||
bldr.Add_quote_xtn_end(); // ']:>\n
|
||||
bldr.Add_paren_end().Add_proc_cont_one(Invk_lang).Add_nl(); // ).lang\n
|
||||
}
|
||||
public static void Save_messages(Gfs_bldr bldr, Xol_msg_mgr msg_mgr, boolean dirty) {
|
||||
int len = msg_mgr.Itms_max(); Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
public static void Save_messages(Xoa_gfs_bldr bldr, Xol_msg_mgr msg_mgr, boolean dirty) {
|
||||
int len = msg_mgr.Itms_max(); Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
int count = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xol_msg_itm itm = msg_mgr.Itm_by_id_or_null(i); if (itm == null) continue; // some items may not be loaded/set by lang
|
||||
@@ -255,7 +256,7 @@ public class Xol_lang_srl {
|
||||
}
|
||||
if (count == 0) return;
|
||||
Bry_bfr bfr = bldr.Bfr();
|
||||
bldr.Add_proc_cont_one(Xol_lang.Invk_messages).Add_nl(); // .keywords\n
|
||||
bldr.Add_proc_cont_one(Xol_lang_itm.Invk_messages).Add_nl(); // .keywords\n
|
||||
bldr.Add_indent().Add_proc_cont_one(Invk_load_text).Add_paren_bgn().Add_nl(); // .load_text(\n
|
||||
bldr.Add_quote_xtn_bgn(); // <~{\n'
|
||||
for (int i = 0; i < len; i++) {
|
||||
@@ -15,11 +15,12 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
import gplx.core.intls.*;
|
||||
import gplx.xowa.apps.gfss.*; import gplx.xowa.langs.numbers.*;
|
||||
import gplx.xowa.nss.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.langs.numbers.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.bldrs.*; import gplx.xowa.langs.specials.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xol_lang_srl_tst {
|
||||
private Xol_lang_srl_fxt fxt = new Xol_lang_srl_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@@ -36,7 +37,7 @@ public class Xol_lang_srl_tst {
|
||||
fxt.Invk(raw);
|
||||
Xol_ns_grp grp = fxt.Lang().Ns_names();
|
||||
fxt.Tst_ns_grp(grp, fxt.ns_(6, "Filex"), fxt.ns_(10, "Templatex"));
|
||||
fxt.Run_save_ns_grp(grp, Xol_lang.Invk_ns_names, raw);
|
||||
fxt.Run_save_ns_grp(grp, Xol_lang_itm.Invk_ns_names, raw);
|
||||
}
|
||||
@Test public void Ns_aliases() {
|
||||
String raw = String_.Concat_lines_nl
|
||||
@@ -51,7 +52,7 @@ public class Xol_lang_srl_tst {
|
||||
fxt.Invk(raw);
|
||||
Xol_ns_grp grp = fxt.Lang().Ns_aliases();
|
||||
fxt.Tst_ns_grp(grp, fxt.ns_(6, "Filex"), fxt.ns_(10, "Templatex"));
|
||||
fxt.Run_save_ns_grp(grp, Xol_lang.Invk_ns_aliases, raw);
|
||||
fxt.Run_save_ns_grp(grp, Xol_lang_itm.Invk_ns_aliases, raw);
|
||||
}
|
||||
@Test public void Kwds() {
|
||||
String raw = String_.Concat_lines_nl // NOTE: notoc must go before toc because ID order
|
||||
@@ -66,7 +67,7 @@ public class Xol_lang_srl_tst {
|
||||
fxt.Invk(raw);
|
||||
Xol_kwd_mgr kwd_mgr = fxt.Lang().Kwd_mgr();
|
||||
fxt.Tst_keywords(kwd_mgr, fxt.kwd_("notoc", true, "no_table_of_contents", "toc_n"), fxt.kwd_("toc", false, "table_of_contents", "toc_y"));
|
||||
fxt.Run_save_kwd_mgr(kwd_mgr, Xol_lang.Invk_keywords, raw);
|
||||
fxt.Run_save_kwd_mgr(kwd_mgr, Xol_lang_itm.Invk_keywords, raw);
|
||||
}
|
||||
@Test public void Specials() {
|
||||
String raw = String_.Concat_lines_nl // NOTE: notoc must go before toc because ID order
|
||||
@@ -82,7 +83,7 @@ public class Xol_lang_srl_tst {
|
||||
fxt.Invk(raw);
|
||||
Xol_specials_mgr specials_mgr = fxt.Lang().Specials_mgr();
|
||||
fxt.Tst_specials(specials_mgr, fxt.special_("Randompage", "PageAuHasard", "Page_au_hasard"), fxt.special_("Search", "Recherche", "Rechercher"));
|
||||
fxt.Run_save_specials_mgr(specials_mgr, Xol_lang.Invk_specials, raw);
|
||||
fxt.Run_save_specials_mgr(specials_mgr, Xol_lang_itm.Invk_specials, raw);
|
||||
}
|
||||
@Test public void Kwds_blank_line() { // PURPOSE.fix: extra blank line negates entire entry
|
||||
String raw = String_.Concat_lines_nl
|
||||
@@ -111,10 +112,10 @@ public class Xol_lang_srl_tst {
|
||||
fxt.Invk(raw);
|
||||
Xol_msg_mgr msg_mgr = fxt.Lang().Msg_mgr();
|
||||
fxt.Tst_messages(msg_mgr, fxt.msg_("sunday", "dimanche"), fxt.msg_("monday", "lundi"));
|
||||
fxt.Run_save_msg_mgr(msg_mgr, Xol_lang.Invk_messages, raw);
|
||||
fxt.Run_save_msg_mgr(msg_mgr, Xol_lang_itm.Invk_messages, raw);
|
||||
}
|
||||
@Test public void Fallback() {
|
||||
Io_mgr.I.SaveFilStr(Xol_lang_.xo_lang_fil_(fxt.App().Fsys_mgr(), "zh-hans"), String_.Concat_lines_nl
|
||||
Io_mgr.Instance.SaveFilStr(Xol_lang_itm_.xo_lang_fil_(fxt.App().Fsys_mgr(), "zh-hans"), String_.Concat_lines_nl
|
||||
( "this"
|
||||
, ".keywords"
|
||||
, " .load_text("
|
||||
@@ -164,9 +165,9 @@ public class Xol_lang_srl_tst {
|
||||
fxt.Tst_messages(fxt.Lang().Msg_mgr(), fxt.msg_("sunday", "sunday1"), fxt.msg_("monday", "monday1"));
|
||||
}
|
||||
@Test public void Fallback_circular() { // PURPOSE: pt and pt-br cite each other as fallback in Messages*.php; DATE:2013-02-18
|
||||
Io_mgr.I.SaveFilStr(Xol_lang_.xo_lang_fil_(fxt.App().Fsys_mgr(), "pt") , "fallback_load('pt-br');");
|
||||
Io_mgr.I.SaveFilStr(Xol_lang_.xo_lang_fil_(fxt.App().Fsys_mgr(), "pt-br") , "fallback_load('pt');");
|
||||
Xol_lang lang = new Xol_lang(fxt.App().Lang_mgr(), Bry_.new_a7("pt"));
|
||||
Io_mgr.Instance.SaveFilStr(Xol_lang_itm_.xo_lang_fil_(fxt.App().Fsys_mgr(), "pt") , "fallback_load('pt-br');");
|
||||
Io_mgr.Instance.SaveFilStr(Xol_lang_itm_.xo_lang_fil_(fxt.App().Fsys_mgr(), "pt-br") , "fallback_load('pt');");
|
||||
Xol_lang_itm lang = new Xol_lang_itm(fxt.App().Lang_mgr(), Bry_.new_a7("pt"));
|
||||
lang.Init_by_load();
|
||||
}
|
||||
@Test public void Num_fmt() {
|
||||
@@ -202,11 +203,11 @@ public class Xol_lang_srl_tst {
|
||||
class Xol_lang_srl_fxt {
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.app_();
|
||||
lang = new Xol_lang(app.Lang_mgr(), Bry_.new_a7("fr"));
|
||||
lang = new Xol_lang_itm(app.Lang_mgr(), Bry_.new_a7("fr"));
|
||||
Xoa_gfs_mgr.Msg_parser_init(); // required by fallback_load
|
||||
} GfsCtx ctx = GfsCtx.new_(); Gfs_bldr bldr = new Gfs_bldr(); //Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
} GfsCtx ctx = GfsCtx.new_(); Xoa_gfs_bldr bldr = new Xoa_gfs_bldr(); //Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public Xoae_app App() {return app;} private Xoae_app app;
|
||||
public Xol_lang Lang() {return lang;} private Xol_lang lang;
|
||||
public Xol_lang_itm Lang() {return lang;} private Xol_lang_itm lang;
|
||||
public Xow_ns ns_(int id, String s) {return new Xow_ns(id, Xow_ns_case_.Id_1st, Bry_.new_u8(s), false);}
|
||||
public Xol_specials_itm special_(String key, String... words) {return new Xol_specials_itm(Bry_.new_u8(key), Bry_.Ary(words));}
|
||||
public Xol_kwd_grp kwd_(String key, boolean case_match, String... words) {
|
||||
@@ -238,23 +239,23 @@ class Xol_lang_srl_fxt {
|
||||
}
|
||||
public void Run_save_ns_grp(Xol_ns_grp grp, String invk, String raw) {
|
||||
Xol_lang_srl.Save_ns_grps(bldr, grp, invk);
|
||||
Tfds.Eq_str_lines("." + raw, bldr.Bfr().Xto_str_and_clear());
|
||||
Tfds.Eq_str_lines("." + raw, bldr.Bfr().To_str_and_clear());
|
||||
}
|
||||
public void Run_save_kwd_mgr(Xol_kwd_mgr kwd_mgr, String invk, String raw) {
|
||||
Xol_lang_srl.Save_keywords(bldr, kwd_mgr);
|
||||
Tfds.Eq_str_lines("." + raw, bldr.Bfr().Xto_str_and_clear());
|
||||
Tfds.Eq_str_lines("." + raw, bldr.Bfr().To_str_and_clear());
|
||||
}
|
||||
public void Run_save_msg_mgr(Xol_msg_mgr msg_mgr, String invk, String raw) {
|
||||
Xol_lang_srl.Save_messages(bldr, msg_mgr, true);
|
||||
Tfds.Eq_str_lines("." + raw, bldr.Bfr().Xto_str_and_clear());
|
||||
Tfds.Eq_str_lines("." + raw, bldr.Bfr().To_str_and_clear());
|
||||
}
|
||||
public void Run_save_num_mgr(Xol_num_mgr num_mgr, String raw) {
|
||||
Xol_lang_srl.Save_num_mgr(bldr, num_mgr);
|
||||
Tfds.Eq_str_lines(raw, bldr.Bfr().Xto_str_and_clear());
|
||||
Tfds.Eq_str_lines(raw, bldr.Bfr().To_str_and_clear());
|
||||
}
|
||||
public void Run_save_specials_mgr(Xol_specials_mgr specials_mgr, String invk, String raw) {
|
||||
Xol_lang_srl.Save_specials(bldr, specials_mgr);
|
||||
Tfds.Eq_str_lines("." + raw, bldr.Bfr().Xto_str_and_clear());
|
||||
Tfds.Eq_str_lines("." + raw, bldr.Bfr().To_str_and_clear());
|
||||
}
|
||||
public void Tst_num_fmt(String raw, String expd) {Tfds.Eq(expd, String_.new_u8(lang.Num_mgr().Format_num(Bry_.new_u8(raw))));}
|
||||
public void Tst_keywords(Xol_kwd_mgr kwd_mgr, Xol_kwd_grp... ary) {
|
||||
@@ -277,7 +278,7 @@ class Xol_lang_srl_fxt {
|
||||
sb.Add(itm.Aliases()[j]).Add_char_nl();
|
||||
}
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
private Xol_specials_itm[] To_ary(Xol_specials_mgr specials_mgr) {
|
||||
int len = specials_mgr.Count();
|
||||
@@ -292,7 +293,7 @@ class Xol_lang_srl_fxt {
|
||||
Xow_ns ns = ary[i];
|
||||
sb.Add(ns.Id()).Add("|").Add(ns.Name_str()).Add_char_nl();
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
Xow_ns[] To_ary(Xol_ns_grp ary) {
|
||||
int len = ary.Len();
|
||||
@@ -323,7 +324,7 @@ class Xol_lang_srl_fxt {
|
||||
}
|
||||
sb.Add_char_nl();
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
Xol_msg_itm[] To_ary(Xol_msg_mgr msg_mgr) {
|
||||
int len = msg_mgr.Itms_max();
|
||||
@@ -341,7 +342,7 @@ class Xol_lang_srl_fxt {
|
||||
Xol_msg_itm itm = ary[i];
|
||||
sb.Add(itm.Key()).Add("|").Add(itm.Val()).Add_char_nl();
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
private static String_bldr sb = String_bldr_.new_();
|
||||
}
|
||||
@@ -17,5 +17,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.plurals; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public interface Xol_plural {
|
||||
byte[] Plural_eval(Xol_lang lang, int count, byte[][] words);
|
||||
byte[] Plural_eval(Xol_lang_itm lang, int count, byte[][] words);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.xowa.langs.plurals; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
public class Xol_plural_ {
|
||||
public static Xol_plural new_by_lang_id(int lang_id) {
|
||||
switch (lang_id) {
|
||||
case Xol_lang_itm_.Id_ru: return Xol_plural_ru._;
|
||||
default: return Xol_plural__default._;
|
||||
case Xol_lang_stub_.Id_ru: return Xol_plural_ru.Instance;
|
||||
default: return Xol_plural__default.Instance;
|
||||
}
|
||||
}
|
||||
public static byte[][] Fill_ary(byte[][] words, int words_len, int reqd_len) {// convert words to an ary of at least reqd_len where new entries are filled with last item; EX: {"a", "b"}, 3 -> {"a", "b", "b"}
|
||||
@@ -32,7 +32,7 @@ public class Xol_plural_ {
|
||||
}
|
||||
}
|
||||
class Xol_plural__default implements Xol_plural {
|
||||
public byte[] Plural_eval(Xol_lang lang, int count, byte[][] forms) {
|
||||
public byte[] Plural_eval(Xol_lang_itm lang, int count, byte[][] forms) {
|
||||
int forms_len = forms.length;
|
||||
switch (forms_len) {
|
||||
case 0: return Bry_.Empty; // forms is empty; do nothing
|
||||
@@ -40,5 +40,5 @@ class Xol_plural__default implements Xol_plural {
|
||||
default: return count == 1 ? forms[0] : forms[1]; // TODO: incorporate plurals.xml logic
|
||||
}
|
||||
}
|
||||
public static final Xol_plural__default _ = new Xol_plural__default(); Xol_plural__default() {}
|
||||
public static final Xol_plural__default Instance = new Xol_plural__default(); Xol_plural__default() {}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.plurals; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_plural_ru implements Xol_plural {
|
||||
public byte[] Plural_eval(Xol_lang lang, int count, byte[][] forms) {
|
||||
public byte[] Plural_eval(Xol_lang_itm lang, int count, byte[][] forms) {
|
||||
int forms_len = forms.length;
|
||||
switch (forms_len) {
|
||||
case 0: return null; // forms is empty; do nothing
|
||||
@@ -36,5 +36,5 @@ public class Xol_plural_ru implements Xol_plural {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static final Xol_plural_ru _ = new Xol_plural_ru(); Xol_plural_ru() {}
|
||||
public static final Xol_plural_ru Instance = new Xol_plural_ru(); Xol_plural_ru() {}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Xol_plural_ru_tst {
|
||||
Tst(5, String_.Ary("a"), "a"); // 1 form; count % 10 != (1, 2, 3, 4); but only 1 element, so take 1st
|
||||
}
|
||||
private void Tst(int count, String[] forms, String expd) {
|
||||
byte[] actl = Xol_plural_ru._.Plural_eval(null, count, Bry_.Ary(forms));
|
||||
byte[] actl = Xol_plural_ru.Instance.Plural_eval(null, count, Bry_.Ary(forms));
|
||||
Tfds.Eq_bry(Bry_.new_a7(expd), actl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_specials_itm {
|
||||
public Xol_specials_itm(byte[] special, byte[][] aliases) {this.special = special; this.aliases = aliases;}
|
||||
public byte[] Special() {return special;} private byte[] special;
|
||||
@@ -15,10 +15,11 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.langs.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.parsers.*;
|
||||
public class Xol_specials_mgr implements GfoInvkAble {
|
||||
private Ordered_hash hash_by_special = Ordered_hash_.new_bry_(), hash_by_aliases = Ordered_hash_.new_bry_();
|
||||
public Xol_specials_mgr(Xol_lang lang) {this.lang = lang;} private Xol_lang lang;
|
||||
private Ordered_hash hash_by_special = Ordered_hash_.New_bry(), hash_by_aliases = Ordered_hash_.New_bry();
|
||||
public Xol_specials_mgr(Xol_lang_itm lang) {this.lang = lang;} private Xol_lang_itm lang;
|
||||
public void Clear() {hash_by_special.Clear();}
|
||||
public int Count() {return hash_by_special.Count();}
|
||||
public Xol_specials_itm Get_at(int i) {return (Xol_specials_itm)hash_by_special.Get_at(i);}
|
||||
@@ -26,10 +26,10 @@ public class Xol_vnt_itm implements GfoInvkAble {
|
||||
public byte[] Key() {return key;} private final byte[] key; // EX: zh-cn
|
||||
public byte[] Name() {return name;} private final byte[] name; // EX: 大陆简体
|
||||
public boolean Visible() {return visible;} private boolean visible = true; // visible in menu
|
||||
public byte[][] Fallback_ary() {return fallback_ary;} private byte[][] fallback_ary = Bry_.Ary_empty; // EX: zh-hans|zh
|
||||
public int Dir() {return dir;} private int dir = Xol_vnt_dir_.Tid__bi; // EX: "bidirectional"
|
||||
public int Mask__vnt() {return mask__vnt;} private final int mask__vnt; // EX: 8
|
||||
public int Mask__fallbacks() {return mask_fallbacks;} private int mask_fallbacks; // EX: 11 for zh,zh-hans,zh-cn
|
||||
public int Dir() {return dir;} private int dir = Xol_vnt_dir_.Tid__bi; // EX: "bidirectional"
|
||||
public byte[][] Fallback_ary() {return fallback_ary;} private byte[][] fallback_ary = Bry_.Ary_empty; // EX: zh-hans|zh
|
||||
public byte[][] Convert_ary() {return convert_ary;} private byte[][] convert_ary = Bry_.Ary_empty; // EX: zh-hans|zh-cn
|
||||
public Xol_convert_wkr Convert_wkr() {return convert_wkr;} private final Xol_convert_wkr convert_wkr;
|
||||
public void Visible_(boolean v) {this.visible = v;}
|
||||
@@ -37,12 +37,12 @@ public class Xol_vnt_itm implements GfoInvkAble {
|
||||
public void Init(int dir, byte[][] fallback_ary) {
|
||||
this.dir = dir; this.fallback_ary = fallback_ary;
|
||||
}
|
||||
public void Mask__fallbacks__calc(Xol_vnt_regy regy, byte[][] ary) {
|
||||
public void Mask__fallbacks_(Xol_vnt_regy regy, byte[][] ary) {
|
||||
this.mask_fallbacks = regy.Mask__calc(Bry_.Ary_add(Bry_.Ary(key), ary));// NOTE: must add lang.key which is not part of fallback; EX: "zh-cn" has fallback of "zh-hans", but chain should calc "zh-cn","zh-hans"
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_fallbacks_)) fallback_ary = Bry_split_.Split(m.ReadBry("v"), Byte_ascii.Pipe);
|
||||
else if (ctx.Match(k, Invk_converts_)) convert_ary = Bry_split_.Split(m.ReadBry("v"), Byte_ascii.Pipe);
|
||||
else if (ctx.Match(k, Invk_converts_)) Convert_ary_(Bry_split_.Split(m.ReadBry("v"), Byte_ascii.Pipe));
|
||||
else if (ctx.Match(k, Invk_dir_)) dir = Xol_vnt_dir_.Parse(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.parsers.vnts.*;
|
||||
class Xol_vnt_itm_sorter__rule implements gplx.lists.ComparerAble {
|
||||
private Hash_adp hash;
|
||||
public void Sort(Hash_adp hash, Xop_vnt_rule_tkn[] ary) {
|
||||
synchronized (hash) {
|
||||
this.hash = hash;
|
||||
Array_.Sort(ary, this);
|
||||
}
|
||||
}
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
return -Int_.Compare(To_mask(lhsObj), To_mask(rhsObj)); // - to sort by descending order; "more specific" vnts are at end of list;
|
||||
}
|
||||
private int To_mask(Object o) {
|
||||
int rv = -1;
|
||||
Xop_vnt_rule_tkn rule = (Xop_vnt_rule_tkn)o; if (rule == null) return rv;
|
||||
Xol_vnt_itm itm = (Xol_vnt_itm)hash.Get_by(rule.Rule_lang()); if (itm == null) return rv;
|
||||
return itm.Mask__vnt();
|
||||
}
|
||||
public static final Xol_vnt_itm_sorter__rule I = new Xol_vnt_itm_sorter__rule(); Xol_vnt_itm_sorter__rule() {}
|
||||
}
|
||||
@@ -16,17 +16,20 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.vnts.converts.*;
|
||||
import gplx.xowa.parsers.vnts.*;
|
||||
import gplx.xowa.langs.vnts.converts.*; import gplx.xowa.parsers.vnts.*;
|
||||
public class Xol_vnt_mgr implements GfoInvkAble {
|
||||
public Xol_vnt_mgr(Xol_lang lang) {this.lang = lang;}
|
||||
public Xol_lang Lang() {return lang;} private final Xol_lang lang;
|
||||
public boolean Enabled() {return enabled;} private boolean enabled = false;
|
||||
public Xol_vnt_regy Regy() {return regy;} private final Xol_vnt_regy regy = new Xol_vnt_regy(); // EX:zh;zh-hans;zh-hant;zh-cn;zh-hk;zh-mo;zh-sg;zh-tw
|
||||
public byte[] Cur_key() {return cur_key;} private byte[] cur_key; // EX:zh-cn
|
||||
public Xol_vnt_itm Cur_itm() {return cur_itm;} private Xol_vnt_itm cur_itm;
|
||||
public Xol_vnt_mgr(Xol_lang_itm lang) {
|
||||
this.lang = lang;
|
||||
this.convert_lang = new Vnt_convert_lang(convert_mgr, regy);
|
||||
}
|
||||
public Xol_lang_itm Lang() {return lang;} private final Xol_lang_itm lang;
|
||||
public Xol_convert_mgr Convert_mgr() {return convert_mgr;} private final Xol_convert_mgr convert_mgr = new Xol_convert_mgr();
|
||||
public Vnt_convert_lang Convert_lang() {return convert_lang;} private final Vnt_convert_lang convert_lang;
|
||||
public Xol_vnt_regy Regy() {return regy;} private final Xol_vnt_regy regy = new Xol_vnt_regy(); // EX:zh;zh-hans;zh-hant;zh-cn;zh-hk;zh-mo;zh-sg;zh-tw
|
||||
public Xol_vnt_itm Cur_itm() {return cur_itm;} private Xol_vnt_itm cur_itm; // EX:zh-cn
|
||||
public boolean Enabled() {return enabled;} private boolean enabled = false;
|
||||
public String Html__lnki_style() {return html__lnki_style;} private String html__lnki_style = ""; // style for showing vnt lnkis in different colors
|
||||
public void Enabled_(boolean v) {this.enabled = v;} // TEST
|
||||
public Xol_vnt_itm Regy__get_or_new(byte[] key) {
|
||||
Xol_vnt_itm rv = regy.Get_by(key);
|
||||
if (rv == null) {
|
||||
@@ -36,6 +39,18 @@ public class Xol_vnt_mgr implements GfoInvkAble {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Cur_itm_(byte[] v) {
|
||||
this.cur_itm = regy.Get_by(v); if (cur_itm == null) throw Err_.new_("lang.vnt", "vnt not found", "key", v);
|
||||
}
|
||||
public void Init_end() {
|
||||
int len = regy.Len();
|
||||
for (int i = 0; i < len; ++i) { // calc fallback_flag; needs to be run after all items added, b/c "zh-cn" added before "zh-sg" but "zh-cn" can have "zh-sg" as fallback
|
||||
Xol_vnt_itm itm = regy.Get_at(i);
|
||||
Xol_lang_itm vnt_lang = lang.Lang_mgr().Get_by_or_load(itm.Key()); // load vnt's language in order to get fallback; EX: "zh-mo" to get "zh-hant|zh-hk|zh-tw"
|
||||
itm.Mask__fallbacks_(regy, vnt_lang.Fallback_bry_ary());
|
||||
}
|
||||
convert_mgr.Init(regy); // needs to run at end b/c converts are added one at a time
|
||||
}
|
||||
private void Limit_visibility(byte[][] ary) {
|
||||
int regy_len = regy.Len();
|
||||
for (int i = 0; i < regy_len; ++i)
|
||||
@@ -44,29 +59,11 @@ public class Xol_vnt_mgr implements GfoInvkAble {
|
||||
for (int i = 0; i < ary_len; ++i)
|
||||
regy.Get_by(ary[i]).Visible_(Bool_.Y);
|
||||
}
|
||||
public void Cur_vnt_(byte[] v) {
|
||||
this.cur_itm = regy.Get_by(v); if (v == null) throw Err_.new_("lang.vnt", "vnt not found", "key", v);
|
||||
this.cur_key = v;
|
||||
convert_mgr.Cur_vnt_(v);
|
||||
}
|
||||
public void Init_by_wiki(Xowe_wiki wiki) {
|
||||
if (!enabled) return;
|
||||
Xop_vnt_lxr_.Init(wiki);
|
||||
}
|
||||
public void Init_end() {
|
||||
int len = regy.Len();
|
||||
for (int i = 0; i < len; ++i) { // calc fallback_flag; needs to be run after all items added, b/c "zh-cn" added before "zh-sg" but "zh-cn" can have "zh-sg" as fallback
|
||||
Xol_vnt_itm itm = regy.Get_at(i);
|
||||
Xol_lang vnt_lang = lang.Lang_mgr().Get_by_key_or_load(itm.Key()); // load vnt's language in order to get fallback; EX: "zh-mo" to get "zh-hant|zh-hk|zh-tw"
|
||||
itm.Mask__fallbacks__calc(regy, vnt_lang.Fallback_bry_ary());
|
||||
}
|
||||
convert_mgr.Init(regy); // needs to run at end b/c converts are added one at a time
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Regy__get_or_new(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_init_end)) Init_end();
|
||||
else if (ctx.Match(k, Invk_vnt_grp_)) Limit_visibility(m.ReadBryAry("v", Byte_ascii.Pipe));
|
||||
else if (ctx.Match(k, Invk_cur_vnt_)) Cur_vnt_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_cur_vnt_)) Cur_itm_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_html_style_)) html__lnki_style = m.ReadStr("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -48,9 +48,9 @@ public class Xol_vnt_regy {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public boolean Mask__match_any(int lhs, int rhs) { // EX: match "zh-cn|zh-hans|zh-hant" against "zh|zh-hans|zh-hant"
|
||||
public boolean Mask__match_any(int lhs, int rhs) { // EX: match "zh-cn|zh-hans|zh-hant" against "zh|zh-hans|zh-hant"
|
||||
for (int i = 0; i < hash_len; ++i) {
|
||||
int mask = gplx.core.brys.Bit_.Get_flag(i); // 1,2,4,8
|
||||
int mask = gplx.core.brys.Bit_.Get_flag(i); // 1,2,4,8
|
||||
if (Bitmask_.Has_int(lhs, mask)) { // lhs has mask; EX: for lhs=6, mask=1 -> 'n'; mask=2 -> 'y'
|
||||
if (Bitmask_.Has_int(rhs, mask)) // if rhs does not have mask, return false;
|
||||
return true;
|
||||
@@ -58,5 +58,4 @@ public class Xol_vnt_regy {
|
||||
}
|
||||
return false; // should only occur when len = 0;
|
||||
}
|
||||
public void Mask__sort(Xop_vnt_rule_tkn... ary) {Xol_vnt_itm_sorter__rule.I.Sort(hash, ary);}
|
||||
}
|
||||
|
||||
@@ -32,15 +32,14 @@ public class Xol_vnt_regy_fxt {
|
||||
public void Test_calc(String[] ary, int expd) {
|
||||
Tfds.Eq(expd, mgr.Mask__calc(Bry_.Ary(ary)));
|
||||
}
|
||||
public void Test_sort(String[] vnt_ary, String[] expd) {
|
||||
int vnt_len = vnt_ary.length;
|
||||
Xop_vnt_rule_tkn[] rule_ary = new Xop_vnt_rule_tkn[vnt_len];
|
||||
for (int i = 0; i < vnt_len; ++i)
|
||||
rule_ary[i] = new Xop_vnt_rule_tkn(Bry_.Empty, Bry_.new_u8(vnt_ary[i]), gplx.xowa.parsers.Xop_tkn_itm_.Ary_empty);
|
||||
mgr.Mask__sort(rule_ary);
|
||||
for (int i = 0; i < vnt_len; ++i)
|
||||
vnt_ary[i] = String_.new_u8(rule_ary[i].Rule_lang());
|
||||
Tfds.Eq_ary_str(expd, vnt_ary);
|
||||
public static void Init__vnt_mgr(Xol_vnt_mgr vnt_mgr, int cur_idx, String[] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xol_vnt_itm itm = vnt_mgr.Regy__get_or_new(Bry_.new_a7(ary[i]));
|
||||
vnt_mgr.Lang().Lang_mgr().Get_by_or_load(itm.Key()).Fallback_bry_(Bry_.new_a7("zh-hans,zh-hant"));
|
||||
}
|
||||
vnt_mgr.Init_end();
|
||||
vnt_mgr.Cur_itm_(Bry_.new_a7(ary[cur_idx]));
|
||||
}
|
||||
public static Xol_vnt_regy new_chinese() { // REF.MW:/languages/classes/LanguageZh.php|LanguageZh|__construct
|
||||
Xol_vnt_regy rv = new Xol_vnt_regy();
|
||||
|
||||
@@ -46,8 +46,4 @@ public class Xol_vnt_regy_tst {
|
||||
, String_.Ary("zh", "zh-hant", "zh-hans")
|
||||
);
|
||||
}
|
||||
@Test public void Sort() {
|
||||
fxt.Test_sort(String_.Ary("zh" ) , String_.Ary("zh"));
|
||||
fxt.Test_sort(String_.Ary("zh", "zh-hans", "zh-cn" ) , String_.Ary("zh-cn", "zh-hans", "zh"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts.converts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.langs.parsers.*;
|
||||
public class Xol_convert_grp implements GfoInvkAble {// group of convert_itm by vnt; EX: zh-hant {A -> A1; B -> B1}
|
||||
private final Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
public Xol_convert_grp(byte[] key) {this.key = key;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public int Len() {return hash.Count();}
|
||||
@@ -32,7 +33,7 @@ public class Xol_convert_grp implements GfoInvkAble {// group of convert_itm by
|
||||
int len = raw.length;
|
||||
int pos = 0, fld_bgn = 0, fld_idx = 0;
|
||||
byte[] src = Bry_.Empty, trg = Bry_.Empty;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
while (true) {
|
||||
boolean last = pos == len;
|
||||
byte b = last ? Byte_ascii.Nl : raw[pos];
|
||||
|
||||
@@ -16,36 +16,21 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts.converts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.nss.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xol_convert_mgr {
|
||||
private final Ordered_hash tmp_page_list = Ordered_hash_.new_bry_();
|
||||
private int wkr_ary_len, cur_wkr_idx = -1;
|
||||
private final Ordered_hash tmp_page_list = Ordered_hash_.New_bry();
|
||||
public Xol_convert_regy Converter_regy() {return converter_regy;} private final Xol_convert_regy converter_regy = new Xol_convert_regy();
|
||||
public Xol_convert_wkr[] Converter_ary() {return wkr_ary;} private Xol_convert_wkr[] wkr_ary;
|
||||
public Xol_convert_wkr[] Converter_ary() {return wkr_ary;} private Xol_convert_wkr[] wkr_ary; private int wkr_ary_len;
|
||||
public void Init(Xol_vnt_regy regy) {
|
||||
int len = regy.Len();
|
||||
this.wkr_ary_len = len;
|
||||
this.wkr_ary = new Xol_convert_wkr[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xol_vnt_itm itm = regy.Get_at(i);
|
||||
itm.Convert_wkr().Rebuild(converter_regy, itm.Convert_ary());
|
||||
itm.Convert_wkr().Init(converter_regy, itm.Convert_ary());
|
||||
wkr_ary[i] = itm.Convert_wkr();
|
||||
}
|
||||
}
|
||||
public void Cur_vnt_(byte[] cur_vnt) {
|
||||
int new_wkr_idx = -1;
|
||||
for (int i = 0; i < wkr_ary_len; i++) {
|
||||
Xol_convert_wkr wkr = wkr_ary[i];
|
||||
if (Bry_.Eq(cur_vnt, wkr.Key())) {
|
||||
new_wkr_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (new_wkr_idx == -1) throw Err_.new_("lang.vnt", "unknown vnt", "key", cur_vnt);
|
||||
this.cur_wkr_idx = new_wkr_idx;
|
||||
}
|
||||
public byte[] Convert_text(byte[] src) {return Convert_text(src, 0, src.length);}
|
||||
public byte[] Convert_text(byte[] src, int bgn, int end) {return Convert_text(cur_wkr_idx, src, bgn, end);}
|
||||
public byte[] Convert_text(int vnt_idx, byte[] src, int bgn, int end) {
|
||||
Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_m001();
|
||||
Xol_convert_wkr converter = wkr_ary[vnt_idx];
|
||||
@@ -54,16 +39,17 @@ public class Xol_convert_mgr {
|
||||
}
|
||||
public Xowd_page_itm Convert_ttl(Xowe_wiki wiki, Xoa_ttl ttl) {return Convert_ttl(wiki, ttl.Ns(), ttl.Page_db());} // NOTE: not Full_db as ttl.Ns is passed; EX:Шаблон:Šablon:Jez-eng; PAGE:sr.w:ДНК DATE:2014-07-06
|
||||
public Xowd_page_itm Convert_ttl(Xowe_wiki wiki, Xow_ns ns, byte[] ttl_bry) {
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_b512();
|
||||
Xowd_page_itm rv = Convert_ttl(wiki, tmp_bfr, ns, ttl_bry);
|
||||
tmp_bfr.Mkr_rls();
|
||||
return rv;
|
||||
}
|
||||
public Xowd_page_itm Convert_ttl(Xowe_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) { // REF.MW:LanguageConverter.php|findVariantLink
|
||||
synchronized (tmp_page_list) {
|
||||
private Xowd_page_itm Convert_ttl(Xowe_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) { // REF.MW:LanguageConverter.php|findVariantLink
|
||||
synchronized (tmp_page_list) { // THREAD:
|
||||
int converted = Convert_ttl__convert_each_vnt(wiki, tmp_bfr, ns, ttl_bry); // convert ttl for each vnt
|
||||
if (converted == 0) return Xowd_page_itm.Null; // ttl_bry has no conversions; exit;
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttls(Cancelable_.Never, tmp_page_list, true, 0, converted);
|
||||
// wiki.Data__core_mgr().Tbl__page().Select_in__ns_ttl(Cancelable_.Never, tmp_page_list, wiki.Ns_mgr(), true, 0, converted); // TODO: use this call; when defaulting test to use db_mgr, not txt_mgr
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttls(Cancelable_.Never, tmp_page_list, Bool_.Y, 0, converted);
|
||||
for (int i = 0; i < converted; i++) {
|
||||
Xowd_page_itm page = (Xowd_page_itm)tmp_page_list.Get_at(i);
|
||||
if (page.Exists()) return page; // return 1st found page
|
||||
@@ -71,23 +57,21 @@ public class Xol_convert_mgr {
|
||||
return Xowd_page_itm.Null;
|
||||
}
|
||||
}
|
||||
private int Convert_ttl__convert_each_vnt(Xowe_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) {
|
||||
synchronized (tmp_page_list) {
|
||||
tmp_page_list.Clear();
|
||||
int rv = 0;
|
||||
for (int i = 0; i < wkr_ary_len; i++) { // convert ttl for each variant
|
||||
Xol_convert_wkr converter = wkr_ary[i];
|
||||
tmp_bfr.Clear();
|
||||
if (!converter.Convert_text(tmp_bfr, ttl_bry)) continue; // ttl is not converted for variant; ignore
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ns.Id(), tmp_bfr.Xto_bry_and_clear()); // NOTE: must convert to ttl in order to upper 1st letter; EX:{{jez-eng|sense}} -> Jez-eng; PAGE:sr.w:ДНК DATE:2014-07-06
|
||||
if (ttl == null) continue;
|
||||
Xowd_page_itm page = new Xowd_page_itm();
|
||||
page.Ttl_(ns, ttl.Page_db());
|
||||
byte[] converted_ttl = page.Ttl_full_db(); if (tmp_page_list.Has(converted_ttl)) continue;
|
||||
tmp_page_list.Add(converted_ttl, page);
|
||||
++rv;
|
||||
}
|
||||
return rv;
|
||||
private int Convert_ttl__convert_each_vnt(Xow_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) {
|
||||
tmp_page_list.Clear();
|
||||
int rv = 0;
|
||||
for (int i = 0; i < wkr_ary_len; i++) { // convert ttl for each variant
|
||||
Xol_convert_wkr converter = wkr_ary[i];
|
||||
tmp_bfr.Clear();
|
||||
if (!converter.Convert_text(tmp_bfr, ttl_bry)) continue; // ttl is not converted for variant; ignore
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(ns.Id(), tmp_bfr.To_bry_and_clear()); // NOTE: must convert to ttl in order to upper 1st letter; EX:{{jez-eng|sense}} -> Jez-eng; PAGE:sr.w:ДНК DATE:2014-07-06
|
||||
if (ttl == null) continue;
|
||||
Xowd_page_itm page = new Xowd_page_itm();
|
||||
page.Ttl_(ns, ttl.Page_db());
|
||||
byte[] converted_ttl = page.Ttl_full_db(); if (tmp_page_list.Has(converted_ttl)) continue;
|
||||
tmp_page_list.Add(converted_ttl, page);
|
||||
++rv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.langs.vnts.converts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.apps.fsys.*;
|
||||
public class Xol_convert_regy implements GfoInvkAble { // registry of convert_grp; EX: zh-hans;zh-hant;
|
||||
private final Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
public Xol_convert_grp Get_or_null(byte[] key) {return (Xol_convert_grp)hash.Get_by(key);}
|
||||
public Xol_convert_grp Get_or_make(byte[] key) {
|
||||
Xol_convert_grp rv = (Xol_convert_grp)hash.Get_by(key);
|
||||
|
||||
@@ -47,15 +47,15 @@ class Xol_convert_regy_fxt {
|
||||
public Xop_fxt Parser_fxt() {return parser_fxt;} private Xop_fxt parser_fxt;
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.app_();
|
||||
Xol_lang lang = app.Lang_mgr().Get_by_key_or_new(Bry_.new_a7("zh"));
|
||||
Xol_lang_.Lang_init(lang);
|
||||
Xol_lang_itm lang = app.Lang_mgr().Get_by_or_new(Bry_.new_a7("zh"));
|
||||
Xol_lang_itm_.Lang_init(lang);
|
||||
Init_cnv(app, "zh", "zh-hant", KeyVal_.new_("x0", "x1"));
|
||||
wiki = Xoa_app_fxt.wiki_(app, "zh.wikipedia.org", lang);
|
||||
gplx.xowa.parsers.vnts.Xop_vnt_parser_fxt.Vnt_mgr__init(wiki.Lang().Vnt_mgr(), 1, String_.Ary("zh", "zh-hans", "zh-hant"));
|
||||
gplx.xowa.langs.vnts.Xol_vnt_regy_fxt.Init__vnt_mgr(wiki.Lang().Vnt_mgr(), 1, String_.Ary("zh", "zh-hans", "zh-hant"));
|
||||
parser_fxt = new Xop_fxt(app, wiki);
|
||||
}
|
||||
public static void Init_cnv(Xoae_app app, String lang_key, String vnt_key, KeyVal... ary) {
|
||||
Xol_lang lang = app.Lang_mgr().Get_by_key_or_new(Bry_.new_a7(lang_key));
|
||||
Xol_lang_itm lang = app.Lang_mgr().Get_by_or_new(Bry_.new_a7(lang_key));
|
||||
Xol_convert_grp grp = lang.Vnt_mgr().Convert_mgr().Converter_regy().Get_or_make(Bry_.new_a7(vnt_key));
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
@@ -64,21 +64,14 @@ class Xol_convert_regy_fxt {
|
||||
}
|
||||
Xol_vnt_itm vnt_itm = lang.Vnt_mgr().Regy__get_or_new(Bry_.new_a7(vnt_key));
|
||||
vnt_itm.Convert_ary_(Bry_.Ary(vnt_key));
|
||||
vnt_itm.Convert_wkr().Rebuild(lang.Vnt_mgr().Convert_mgr().Converter_regy(), vnt_itm.Convert_ary());
|
||||
vnt_itm.Convert_wkr().Init(lang.Vnt_mgr().Convert_mgr().Converter_regy(), vnt_itm.Convert_ary());
|
||||
}
|
||||
// public void Test_convert(String lang, String vnt, String raw, String expd) {
|
||||
// Xol_convert_grp convert_grp = app.Lang_mgr().Get_by_key_or_new(Bry_.new_a7(lang)).Cnv_mgr().Get_or_new(Bry_.new_a7(vnt));
|
||||
// Bry_bfr bfr = Bry_bfr.new_();
|
||||
// boolean converted = convert_grp.Convert_to_bfr(bfr, Bry_.new_u8(raw));
|
||||
// String actl = converted ? bfr.Xto_str_and_clear() : raw;
|
||||
// Tfds.Eq(expd, actl);
|
||||
// }
|
||||
public void Test_parse(String raw, String expd) {
|
||||
parser_fxt.Test_parse_page_all_str(raw, expd);
|
||||
}
|
||||
public void Test_convert_by_ttl(String lang_key, String raw, boolean expd) {
|
||||
Xol_lang lang = app.Lang_mgr().Get_by_key_or_new(Bry_.new_a7(lang_key));
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(raw));
|
||||
Xol_lang_itm lang = app.Lang_mgr().Get_by_or_new(Bry_.new_a7(lang_key));
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.new_u8(raw));
|
||||
Xowd_page_itm page = lang.Vnt_mgr().Convert_mgr().Convert_ttl(wiki, ttl);
|
||||
if (expd)
|
||||
Tfds.Eq_true(page.Exists());
|
||||
|
||||
@@ -21,8 +21,8 @@ public class Xol_convert_wkr {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
public Xol_convert_wkr(byte[] key) {this.key = key;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public void Add(byte[] src, byte[] trg) {trie.Add_obj(src, trg);}
|
||||
public void Del(byte[] src) {trie.Del(src);}
|
||||
public void Add(byte[] src, byte[] trg) {trie.Add_obj(src, trg);} // called by -{H}-
|
||||
public void Del(byte[] src) {trie.Del(src);} // called by -{-}-
|
||||
public boolean Convert_text(Bry_bfr bfr, byte[] src) {return Convert_text(bfr, src, 0, src.length);}
|
||||
public boolean Convert_text(Bry_bfr bfr, byte[] src, int bgn, int end) {
|
||||
int pos = bgn;
|
||||
@@ -52,16 +52,16 @@ public class Xol_convert_wkr {
|
||||
if (!matched) bfr.Add_mid(src, bgn, end); // no convert; make sure to add back src, else bfr will be blank
|
||||
return matched;
|
||||
}
|
||||
public void Rebuild(Xol_convert_regy regy, byte[][] ary) {
|
||||
public void Init(Xol_convert_regy regy, byte[][] vnt_ary) { // EX: "zh-cn" should add all converts from "zh-hans" "zh-cn" to its wkr
|
||||
trie.Clear();
|
||||
int len = ary.length;
|
||||
int len = vnt_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte[] key = ary[i];
|
||||
Xol_convert_grp grp = regy.Get_or_null(key); if (grp == null) continue; // vnts may not have convert mapping; EX: zh-my
|
||||
Rebuild_grp(grp);
|
||||
byte[] key = vnt_ary[i];
|
||||
Xol_convert_grp grp = regy.Get_or_null(key); if (grp == null) continue; // vnt may not have convert mapping; EX: zh-my
|
||||
Init_grp(grp);
|
||||
}
|
||||
}
|
||||
private void Rebuild_grp(Xol_convert_grp grp) {
|
||||
private void Init_grp(Xol_convert_grp grp) {
|
||||
int len = grp.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xol_convert_itm itm = grp.Get_at(i);
|
||||
|
||||
@@ -19,23 +19,26 @@ package gplx.xowa.langs.vnts.converts; import gplx.*; import gplx.xowa.*; import
|
||||
import org.junit.*;
|
||||
import gplx.langs.phps.*;
|
||||
public class Xol_mw_parse_tst {
|
||||
private Xol_mw_parse_fxt fxt = new Xol_mw_parse_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_convert("$zh2Hant = array('a' => 'A', 'b' => 'B',);", String_.Concat_lines_nl
|
||||
( "// zh_zh-hant"
|
||||
, "app.langs.get('zh').converts.get('zh-hant').add_bulk("
|
||||
, "<:['"
|
||||
, "a|A"
|
||||
, "b|B"
|
||||
, "']:>"
|
||||
, ");"
|
||||
));
|
||||
}
|
||||
private final Xol_mw_parse_fxt fxt = new Xol_mw_parse_fxt();
|
||||
// @Test public void Basic() {
|
||||
// fxt.Test_convert("$zh2Hant = array('a' => 'A', 'b' => 'B',);", String_.Concat_lines_nl
|
||||
// ( "// zh_zh-hant"
|
||||
// , "app.langs.get('zh').converts.get('zh-hant').add_bulk("
|
||||
// , "<:['"
|
||||
// , "a|A"
|
||||
// , "b|B"
|
||||
// , "']:>"
|
||||
// , ");"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Run() {
|
||||
// Io_url src_dir = Io_url_.new_dir_("C:\\xowa\\bin\\any\\xowa\\lang\\mediawiki\\converts\\");
|
||||
// Io_url trg_dir = Io_url_.new_dir_("C:\\xowa\\bin\\any\\xowa\\lang\\");
|
||||
// Io_url src_dir = Io_url_.new_dir_("C:\\xowa\\bin\\any\\xowa\\cfg\\lang\\mediawiki\\converts\\");
|
||||
// Io_url trg_dir = Io_url_.new_dir_("C:\\xowa\\bin\\any\\xowa\\cfg\\lang\\");
|
||||
// fxt.Test_run(src_dir, trg_dir);
|
||||
// }
|
||||
@Test public void Ignore() {
|
||||
fxt.toString();
|
||||
}
|
||||
}
|
||||
class Xol_mw_parse_grp {
|
||||
public byte[] Lng() {return lng;} public Xol_mw_parse_grp Lng_(byte[] v) {lng = v; return this;} private byte[] lng;
|
||||
@@ -80,15 +83,15 @@ class Xol_mw_parse_fxt {
|
||||
Xol_mw_parse_grp[] actl_ary = Parse(Bry_.new_u8(mw));
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
actl_ary[0].Write_as_gfs(bfr);
|
||||
Tfds.Eq_str_lines(expd, bfr.Xto_str());
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str());
|
||||
}
|
||||
public void Test_run(Io_url src_dir, Io_url trg_dir) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Io_url[] fils = Io_mgr.I.QueryDir_fils(src_dir);
|
||||
Io_url[] fils = Io_mgr.Instance.QueryDir_fils(src_dir);
|
||||
int fils_len = fils.length;
|
||||
for (int i = 0; i < fils_len; i++) {
|
||||
Io_url fil = fils[i];
|
||||
byte[] src = Io_mgr.I.LoadFilBry(fil);
|
||||
byte[] src = Io_mgr.Instance.LoadFilBry(fil);
|
||||
Xol_mw_parse_grp[] itms = Parse(src);
|
||||
int itms_len = itms.length;
|
||||
String lang_name = String_.Lower(String_.Mid(fil.NameOnly(), 0, 2)); // ZhConversion.php -> Zh
|
||||
@@ -97,7 +100,7 @@ class Xol_mw_parse_fxt {
|
||||
itm.Write_as_gfs(bfr);
|
||||
}
|
||||
Io_url trg_fil = Xol_convert_regy.Bld_url(trg_dir, lang_name);
|
||||
Io_mgr.I.SaveFilBry(trg_fil, bfr.Xto_bry_and_clear());
|
||||
Io_mgr.Instance.SaveFilBry(trg_fil, bfr.To_bry_and_clear());
|
||||
}
|
||||
}
|
||||
public Xol_mw_parse_grp[] Parse(byte[] src) {
|
||||
@@ -119,7 +122,7 @@ class Xol_mw_parse_fxt {
|
||||
private Xol_mw_parse_grp Parse_grp(Php_line_assign line) {
|
||||
Xol_mw_parse_grp grp = new Xol_mw_parse_grp();
|
||||
byte[] key = line.Key().Val_obj_bry(); // EX: "zh2Hant"
|
||||
key = Bry_.Lcase__all(key); // EX: "zh2hant"
|
||||
key = Bry_.Lcase__all(key); // EX: "zh2hant"
|
||||
byte[][] parts = Bry_split_.Split(key, Byte_ascii.Num_2); // EX: "zh", "hant"
|
||||
byte[] src = parts[0];
|
||||
byte[] trg = Bry_.Add(parts[0], new byte[] {Byte_ascii.Dash}, parts[1]);
|
||||
|
||||
Reference in New Issue
Block a user