mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.3.1'
This commit is contained in:
@@ -18,14 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.apps.fsys.*;
|
||||
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 class Xoa_lang_mgr implements Gfo_invk {
|
||||
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 Xol_lang_itm Lang_en() {return lang_en;} private final Xol_lang_itm lang_en;
|
||||
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);}
|
||||
@@ -43,7 +43,7 @@ public class Xoa_lang_mgr implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
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;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
} private static final String Invk_get = "get", Invk_mediawiki_converter = "mediawiki_converter";
|
||||
public static final byte[] Fallback_false = Bry_.new_a7("false");
|
||||
public static final byte[] Fallback_false = Bry_.new_a7("false");
|
||||
}
|
||||
|
||||
@@ -17,10 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.envs.*;
|
||||
import gplx.gfui.draws.*;
|
||||
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 {
|
||||
public class Xol_lang_itm implements Gfo_invk {
|
||||
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);
|
||||
@@ -41,19 +42,19 @@ public class Xol_lang_itm implements GfoInvkAble {
|
||||
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 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_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 Xol_font_info Gui_font() {return gui_font;} private final Xol_font_info gui_font = new Xol_font_info(null, 0, FontStyleAdp_.Plain);
|
||||
public byte[] Fallback_bry() {return fallback_bry;}
|
||||
public Xol_lang_itm Fallback_bry_(byte[] v) {
|
||||
fallback_bry = v;
|
||||
@@ -67,15 +68,15 @@ public class Xol_lang_itm implements GfoInvkAble {
|
||||
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 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 Xol_func_regy Func_regy() {return func_regy;} private final Xol_func_regy func_regy;
|
||||
public int Img_thumb_halign_default() {return img_thumb_halign_default;} private int 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() {
|
||||
@@ -101,7 +102,7 @@ public class Xol_lang_itm implements GfoInvkAble {
|
||||
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;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_ns_names = "ns_names", Invk_ns_aliases = "ns_aliases"
|
||||
@@ -112,7 +113,7 @@ public class Xol_lang_itm implements GfoInvkAble {
|
||||
, 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
|
||||
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;
|
||||
@@ -139,7 +140,7 @@ public class Xol_lang_itm implements GfoInvkAble {
|
||||
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[]
|
||||
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")
|
||||
;
|
||||
@@ -165,5 +166,5 @@ public class Xol_lang_itm implements GfoInvkAble {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static final byte[][] Fallback_bry_ary__en = new byte[][] {Xol_lang_itm_.Key_en};
|
||||
private static final byte[][] Fallback_bry_ary__en = new byte[][] {Xol_lang_itm_.Key_en};
|
||||
}
|
||||
|
||||
@@ -814,7 +814,7 @@ 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_simple, "simple", "Simple"); // NOTE: changed from "Simple English"; DATE:2016-06-11
|
||||
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");
|
||||
|
||||
@@ -26,7 +26,7 @@ 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);
|
||||
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();
|
||||
@@ -49,7 +49,7 @@ abstract class Json_itm_wkr__base implements Json_itm_wkr {
|
||||
@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");
|
||||
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();
|
||||
|
||||
@@ -19,16 +19,16 @@ package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xo
|
||||
import gplx.core.log_msgs.*;
|
||||
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 class Xobc_utl_make_lang implements Gfo_invk {
|
||||
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 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);
|
||||
@@ -44,7 +44,7 @@ public class Xobc_utl_make_lang implements GfoInvkAble {
|
||||
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;
|
||||
else return Gfo_invk_.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";
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@ 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 class Xobc_utl_make_lang_kwds implements Gfo_invk, 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;
|
||||
else return Gfo_invk_.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";
|
||||
|
||||
@@ -103,7 +103,7 @@ public class Xobc_utl_make_lang_kwds implements GfoInvkAble, Xol_lang_transform
|
||||
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;
|
||||
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];
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Xol_mw_lang_parser {
|
||||
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_();
|
||||
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"));
|
||||
@@ -116,7 +116,7 @@ public class Xol_mw_lang_parser {
|
||||
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_();
|
||||
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();
|
||||
@@ -172,7 +172,7 @@ public class Xol_mw_lang_parser {
|
||||
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_();
|
||||
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++) {
|
||||
@@ -235,7 +235,7 @@ public class Xol_mw_lang_parser {
|
||||
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_();
|
||||
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);
|
||||
@@ -302,7 +302,7 @@ public class Xol_mw_lang_parser {
|
||||
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);
|
||||
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());
|
||||
@@ -315,12 +315,12 @@ public class Xol_mw_lang_parser {
|
||||
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 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);
|
||||
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());
|
||||
|
||||
@@ -239,7 +239,7 @@ public class Xol_mw_lang_parser_tst {
|
||||
}
|
||||
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);
|
||||
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.Make__app__edit();
|
||||
|
||||
@@ -18,7 +18,7 @@ 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.wikis.nss.*;
|
||||
import gplx.xowa.langs.parsers.*;
|
||||
public class Xol_ns_grp implements GfoInvkAble {
|
||||
public class Xol_ns_grp implements Gfo_invk {
|
||||
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;
|
||||
@@ -33,11 +33,11 @@ public class Xol_ns_grp implements GfoInvkAble {
|
||||
new_ary[i + old_ary_len] = add_ary[i];
|
||||
this.ary = new_ary;
|
||||
}
|
||||
private static final Xow_ns[] Ary_empty = new Xow_ns[0];
|
||||
private static final Xow_ns[] Ary_empty = new Xow_ns[0];
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_lang)) return lang;
|
||||
else if (ctx.Match(k, Invk_load_text)) Exec_load_text(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_lang = Xol_lang_srl.Invk_lang, Invk_load_text = Xol_lang_srl.Invk_load_text;
|
||||
private void Exec_load_text(byte[] bry) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xol_case_itm_ {
|
||||
return new Xol_case_itm_bry(tid, src, trg);
|
||||
}
|
||||
public static Xol_case_itm[] parse_xo_(byte[] src) {
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
int src_len = src.length, src_pos = 0, fld_bgn = 0, fld_idx = 0;
|
||||
byte cur_cmd = Byte_.Zero;
|
||||
byte[] cur_lhs = null;
|
||||
@@ -144,6 +144,6 @@ public class Xol_case_itm_ {
|
||||
++pos;
|
||||
}
|
||||
return pos;
|
||||
} private static final byte[] parse_mw_upper= Bry_.new_a7("wikiUpperChars"), parse_mw_lower= Bry_.new_a7("wikiLowerChars"), Bry_upper = Bry_.new_a7("upper"), Bry_lower = Bry_.new_a7("lower"), Bry_pipe = Bry_.new_a7("|");
|
||||
} private static final byte[] parse_mw_upper= Bry_.new_a7("wikiUpperChars"), parse_mw_lower= Bry_.new_a7("wikiLowerChars"), Bry_upper = Bry_.new_a7("upper"), Bry_lower = Bry_.new_a7("lower"), Bry_pipe = Bry_.new_a7("|");
|
||||
static final String GRP_KEY = "xowa.langs.case_parser";
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ 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.core.btries.*; import gplx.core.intls.*;
|
||||
public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.new_(); private Btrie_fast_mgr upper_trie = Btrie_fast_mgr.cs(), lower_trie = Btrie_fast_mgr.cs(); private Xol_case_itm[] itms;
|
||||
public class Xol_case_mgr implements Gfo_invk, Gfo_case_mgr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr_.New(); private Btrie_fast_mgr upper_trie = Btrie_fast_mgr.cs(), lower_trie = Btrie_fast_mgr.cs(); private Xol_case_itm[] itms;
|
||||
public Xol_case_mgr(byte tid) {this.tid = tid;}
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public Gfo_case_itm Get_or_null(byte bgn_byte, byte[] src, int bgn, int end) {
|
||||
@@ -130,7 +130,7 @@ public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_add_bulk)) Add_bulk(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_clear)) throw Err_.new_unimplemented();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_clear = "clear", Invk_add_bulk = "add_bulk";
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Xol_case_mgr_tst {
|
||||
}
|
||||
// @Test public void Hack() {
|
||||
// Xol_case_itm[] ary = Xol_case_mgr_.Utf_8;
|
||||
// Bry_bfr bfr = Bry_bfr.new_();
|
||||
// Bry_bfr bfr = Bry_bfr_.New();
|
||||
// for (int i = 0; i < ary.length; i++) {
|
||||
// Xol_case_itm itm = ary[i];
|
||||
// bfr.Add_str_a7("xo|");
|
||||
@@ -119,7 +119,7 @@ class Xol_case_mgr_fxt {
|
||||
}
|
||||
}
|
||||
return raw_str_(uppers_list.To_str_ary(), lowers_list.To_str_ary());
|
||||
} List_adp uppers_list = List_adp_.new_(), lowers_list = List_adp_.new_();
|
||||
} List_adp uppers_list = List_adp_.New(), lowers_list = List_adp_.New();
|
||||
String raw_str_(String[] uppers, String[] lowers) {
|
||||
sb.Add("a:2:{s:14:\"wikiUpperChars\";a:1046:{");
|
||||
raw_ary(sb, uppers);
|
||||
|
||||
@@ -17,7 +17,7 @@ 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.*;
|
||||
public class Xol_duration_itm_ {
|
||||
private static final Hash_adp_bry regy = Hash_adp_bry.ci_a7(); // ASCII:MW.consts
|
||||
private static final Hash_adp_bry regy = Hash_adp_bry.ci_a7(); // ASCII:MW.consts
|
||||
public static final byte
|
||||
Tid_millenia = 0
|
||||
, Tid_centuries = 1
|
||||
@@ -29,7 +29,7 @@ public class Xol_duration_itm_ {
|
||||
, Tid_minutes = 7
|
||||
, Tid_seconds = 8
|
||||
;
|
||||
public static final Xol_duration_itm
|
||||
public static final Xol_duration_itm
|
||||
Itm_millenia = new_(Tid_millenia , "millenia" , 31556952000L)
|
||||
, Itm_centuries = new_(Tid_centuries , "centuries" , 3155695200L)
|
||||
, Itm_decades = new_(Tid_decades , "decades" , 315569520L)
|
||||
@@ -45,7 +45,7 @@ public class Xol_duration_itm_ {
|
||||
regy.Add(rv.Name_bry(), rv);
|
||||
return rv;
|
||||
}
|
||||
public static final Xol_duration_itm[] Ary_default = new Xol_duration_itm[]
|
||||
public static final Xol_duration_itm[] Ary_default = new Xol_duration_itm[]
|
||||
{ Itm_millenia
|
||||
, Itm_centuries
|
||||
, Itm_decades
|
||||
@@ -58,7 +58,7 @@ public class Xol_duration_itm_ {
|
||||
};
|
||||
public static Xol_duration_itm[] Xto_itm_ary(Keyval[] kv_ary) {
|
||||
if (kv_ary == null) return Xol_duration_itm_.Ary_default;
|
||||
List_adp rv = List_adp_.new_();
|
||||
List_adp rv = List_adp_.New();
|
||||
int len = kv_ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Keyval kv = kv_ary[i];
|
||||
@@ -76,5 +76,5 @@ class Xol_duration_itm_sorter implements gplx.core.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 Instance = 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() {}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ import gplx.xowa.langs.msgs.*;
|
||||
public class Xol_duration_mgr {
|
||||
private Xol_msg_itm[] interval_msgs = null;
|
||||
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);
|
||||
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.Instance);
|
||||
int intervals_len = intervals.length;
|
||||
long val = seconds;
|
||||
List_adp rv = List_adp_.new_();
|
||||
List_adp rv = List_adp_.New();
|
||||
for (int i = 0; i < intervals_len; i++) {
|
||||
Xol_duration_itm itm = intervals[i];
|
||||
long itm_seconds = itm.Seconds();
|
||||
@@ -65,7 +65,7 @@ public class Xol_duration_mgr {
|
||||
byte[] msg_key = Bry_.Add(Bry_duration, itm.Name_bry());
|
||||
interval_msgs[i] = msg_mgr.Itm_by_key_or_new(msg_key);
|
||||
}
|
||||
} private static final byte[] Bry_duration = Bry_.new_a7("duration-");
|
||||
} private static final byte[] Bry_duration = Bry_.new_a7("duration-");
|
||||
private void List_to_str_init() {
|
||||
Xol_msg_mgr msg_mgr = lang.Msg_mgr();
|
||||
Msg_and = msg_mgr.Val_by_str_or_empty("and");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xol_func_regy {
|
||||
if (Env_.Mode_testing())
|
||||
continue; // TEST: allows partial parsing of $magicWords
|
||||
else
|
||||
list = lang_mgr.Lang_en().Kwd_mgr().Get_at(id); // get from fallback language; TODO: allow other fallback langs besides "English"
|
||||
list = lang_mgr.Lang_en().Kwd_mgr().Get_at(id); // get from fallback language; TODO_OLD: allow other fallback langs besides "English"
|
||||
}
|
||||
Reg_defn(kwd_mgr, id, Pf_func_.Get_prototype(id));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.langs.grammars; import gplx.*; import gplx.xowa.*; import gplx
|
||||
import gplx.core.btries.*;
|
||||
public class Xol_grammar_he implements Xol_grammar {
|
||||
public boolean Grammar_eval(Bry_bfr bfr, Xol_lang_itm lang, byte[] word, byte[] type) {
|
||||
// if ( isset( $wgGrammarForms['he'][$case][$word] ) ) return $wgGrammarForms['he'][$case][$word]; // TODO: implement global $wgGrammarForms; WHEN: need to find he.w entries for DefaultSettings.php
|
||||
// if ( isset( $wgGrammarForms['he'][$case][$word] ) ) return $wgGrammarForms['he'][$case][$word]; // TODO_OLD: implement global $wgGrammarForms; WHEN: need to find he.w entries for DefaultSettings.php
|
||||
if (hash.Get_as_int_or(type, -1) == Tid__prefixed) {
|
||||
// Duplicate the "Waw" if prefixed, but not if it is already double.
|
||||
if ( Bry_.Match(word, 0, 2, Bry__waw__0) // "ו"
|
||||
@@ -39,11 +39,11 @@ public class Xol_grammar_he implements Xol_grammar {
|
||||
return true;
|
||||
}
|
||||
private static final int Tid__prefixed = 1;
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.ci_u8(gplx.xowa.langs.cases.Xol_case_mgr_.U8())
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.ci_u8(gplx.xowa.langs.cases.Xol_case_mgr_.U8())
|
||||
.Add_str_int("prefixed" , Tid__prefixed)
|
||||
.Add_str_int("תחילית" , Tid__prefixed)
|
||||
;
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Bry__waw__0 = Bry_.new_u8("ו"), Bry__waw__1 = Bry_.new_u8("וו")
|
||||
, Bry__he__0 = Bry_.new_u8("ה")
|
||||
, Bry__maqaf__0 = Bry_.new_u8("א"), Bry__maqaf__1 = Bry_.new_u8("ת"), Bry__maqaf__2 = Bry_.new_u8("־")
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
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 {
|
||||
private final Xol_lang_itm lang; private final Xol_kwd_grp[] grps = new Xol_kwd_grp[Xol_kwd_grp_.Id__max];
|
||||
public class Xol_kwd_mgr implements Gfo_invk {
|
||||
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;}
|
||||
@@ -71,7 +71,7 @@ public class Xol_kwd_mgr implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_lang)) return lang;
|
||||
else if (ctx.Match(k, Invk_load_text)) Xol_lang_srl.Load_keywords(this, m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_lang = Xol_lang_srl.Invk_lang, Invk_load_text = Xol_lang_srl.Invk_load_text;
|
||||
public static Btrie_slim_mgr trie_(Xol_kwd_mgr mgr, int id) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Xol_kwd_parse_data_tst {
|
||||
}
|
||||
Xol_kwd_parse_data_tst Key_(String v) {this.key = v; return this;} private String key;
|
||||
Xol_kwd_parse_data_tst Tst_strip(String v) {
|
||||
Bry_bfr tmp = Bry_bfr.new_();
|
||||
Bry_bfr tmp = Bry_bfr_.New();
|
||||
Byte_obj_ref rslt = Byte_obj_ref.zero_();
|
||||
byte[] actl = Xol_kwd_parse_data.Strip(tmp, Bry_.new_a7(v), rslt);
|
||||
Tfds.Eq(key, String_.new_a7(actl));
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 class Xol_lnki_trail_mgr implements Gfo_invk {
|
||||
public Xol_lnki_trail_mgr(Xol_lang_itm lang) {}
|
||||
public void Clear() {trie.Clear();}
|
||||
public int Count() {return trie.Count();}
|
||||
@@ -35,7 +35,7 @@ public class Xol_lnki_trail_mgr implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_add_many)) Add_many(m);
|
||||
else if (ctx.Match(k, Invk_add_bulk)) Add_bulk(m);
|
||||
else if (ctx.Match(k, Invk_clear)) Clear();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_add_many = "add_many", Invk_add_range = "add_range", Invk_add_bulk = "add_bulk", Invk_clear = "clear";
|
||||
private void Add_bulk(GfoMsg m) {byte[] src = m.ReadBry("bulk"); Add_bulk(src);}
|
||||
|
||||
@@ -259,16 +259,16 @@ public static final int
|
||||
update_val_(rv, val);
|
||||
return rv;
|
||||
}
|
||||
private static final Bry_fmtr tmp_fmtr = Bry_fmtr.tmp_().Fail_when_invalid_escapes_(false);
|
||||
private static final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private static final Bry_fmtr tmp_fmtr = Bry_fmtr.tmp_().Fail_when_invalid_escapes_(false);
|
||||
private static final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
public static void update_val_(Xol_msg_itm itm, byte[] val) {
|
||||
boolean has_fmt_arg = tmp_fmtr.Fmt_(val).Compile().Fmt_args_exist();
|
||||
boolean has_tmpl_txt = Bry_find_.Find_fwd(val, Xop_curly_bgn_lxr.Hook, 0) != -1;
|
||||
val = trie_space.Replace(tmp_bfr, val, 0, val.length);
|
||||
itm.Atrs_set(val, has_fmt_arg, has_tmpl_txt);
|
||||
}
|
||||
public static final byte[] Bry_nbsp = Byte_.Ary_by_ints(194, 160);
|
||||
private static final Btrie_slim_mgr trie_space = Btrie_slim_mgr.cs() // MW:cache/MessageCache.php|get|Fix for trailing whitespace, removed by textarea|DATE:2014-04-29
|
||||
public static final byte[] Bry_nbsp = Byte_.Ary_by_ints(194, 160);
|
||||
private static final Btrie_slim_mgr trie_space = Btrie_slim_mgr.cs() // MW:cache/MessageCache.php|get|Fix for trailing whitespace, removed by textarea|DATE:2014-04-29
|
||||
.Add_bry(" " , " ")
|
||||
.Add_bry(" " , Bry_nbsp)
|
||||
.Add_bry(" " , Bry_nbsp)
|
||||
|
||||
@@ -17,9 +17,9 @@ 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.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) {
|
||||
public class Xol_msg_mgr implements Gfo_invk {
|
||||
private final Gfo_invk owner; private final boolean owner_is_lang;
|
||||
public Xol_msg_mgr(Gfo_invk owner, boolean owner_is_lang) {
|
||||
this.owner = owner; this.owner_is_lang = owner_is_lang;
|
||||
this.Clear();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class Xol_msg_mgr implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_lang)) return owner;
|
||||
else if (ctx.Match(k, Invk_load_text)) Xol_lang_srl.Load_messages(this, m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_lang = Xol_lang_srl.Invk_lang, Invk_load_text = Xol_lang_srl.Invk_load_text;
|
||||
private void Itms_reg(Xol_msg_itm itm) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Xol_msg_mgr_ {
|
||||
byte[] rv = Get_msg_val(tmp_bfr, wiki, msg_itm, fmt_args);
|
||||
tmp_bfr.Mkr_rls();
|
||||
return rv;
|
||||
} private static final byte[] Missing_bry = Bry_.new_a7("$"), Slash_bry = new byte[] {Byte_ascii.Slash};
|
||||
} private static final byte[] Missing_bry = Bry_.new_a7("$"), Slash_bry = new byte[] {Byte_ascii.Slash};
|
||||
public static byte[] Get_msg_val(Bry_bfr tmp_bfr, Xowe_wiki wiki, Xol_msg_itm msg_itm, byte[][] fmt_args) {
|
||||
byte[] msg_val = msg_itm.Val();
|
||||
boolean has_fmt = msg_itm.Has_fmt_arg(), has_tmpl = msg_itm.Has_tmpl_txt();
|
||||
@@ -104,14 +104,14 @@ public class Xol_msg_mgr_ {
|
||||
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 = 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);
|
||||
Xoae_page rv = ttl == null ? Xoae_page.Empty : wiki.Data_mgr().Load_page_by_ttl_for_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 = 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);
|
||||
rv = ttl == null ? Xoae_page.Empty : wiki.Data_mgr().Load_page_by_ttl_for_msg(ttl);
|
||||
if (!rv.Missing()) break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ 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.htmls.sidebar.*;
|
||||
public class Xow_msg_mgr implements GfoInvkAble {
|
||||
private final Xowe_wiki wiki; private Xol_lang_itm lang; private final Xol_msg_mgr msg_mgr;
|
||||
public class Xow_msg_mgr implements Gfo_invk {
|
||||
private final Xowe_wiki wiki; private Xol_lang_itm lang; private final Xol_msg_mgr msg_mgr;
|
||||
public Xow_msg_mgr(Xowe_wiki wiki, Xol_lang_itm lang) {
|
||||
this.wiki = wiki;
|
||||
this.lang = lang;
|
||||
@@ -104,10 +104,10 @@ public class Xow_msg_mgr implements GfoInvkAble {
|
||||
itm.Accesskey_(accesskey_val).Title_(tooltip_val).Atr_accesskey_and_title_(rv);
|
||||
return null;
|
||||
}
|
||||
} static final byte[] CONST_prefix_tooltip = Bry_.new_a7("tooltip-"), CONST_prefix_accesskey = Bry_.new_a7("accesskey-"), CONST_atr_title = Bry_.new_a7(" title=\""), CONST_atr_accesskey = Bry_.new_a7(" accesskey=\"");
|
||||
} static final byte[] CONST_prefix_tooltip = Bry_.new_a7("tooltip-"), CONST_prefix_accesskey = Bry_.new_a7("accesskey-"), CONST_atr_title = Bry_.new_a7(" title=\""), CONST_atr_accesskey = Bry_.new_a7(" accesskey=\"");
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return this.Val_by_key_obj(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_get_html_accesskey_and_title)) return this.Val_html_accesskey_and_title(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
} private static final String Invk_get = "get", Invk_get_html_accesskey_and_title = "get_html_accesskey_and_title";
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.numbers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
public class Xol_num_fmtr_base implements GfoInvkAble {
|
||||
public class Xol_num_fmtr_base implements Gfo_invk {
|
||||
private Btrie_fast_mgr dlm_trie = Btrie_fast_mgr.cs();
|
||||
private Xol_num_grp[] grp_ary = Xol_num_grp.Ary_empty; int grp_ary_len;
|
||||
private Gfo_num_fmt_wkr[] cache; int cache_len = 16;
|
||||
private Bry_bfr tmp = Bry_bfr.new_();
|
||||
private Bry_bfr tmp = Bry_bfr_.New();
|
||||
public boolean Standard() {return standard;} private boolean standard = true;
|
||||
public byte[] Dec_dlm() {return dec_dlm;} public Xol_num_fmtr_base Dec_dlm_(byte[] v) {this.dec_dlm = v; dlm_trie.Add_bry_byte(v, Raw_tid_dec); return this;} private byte[] dec_dlm = Dec_dlm_default;
|
||||
private byte[] grp_dlm;
|
||||
@@ -136,13 +136,13 @@ public class Xol_num_fmtr_base implements GfoInvkAble {
|
||||
if (ctx.Match(k, Invk_dec_dlm_)) this.Dec_dlm_(m.ReadBry("v")); // NOTE: must call mutator
|
||||
else if (ctx.Match(k, Invk_clear)) this.Clear();
|
||||
else if (ctx.Match(k, Invk_grps_add)) this.Grps_add(new Xol_num_grp(m.ReadBry("dlm"), m.ReadInt("digits"), m.ReadYn("repeat")));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_dec_dlm_ = "dec_dlm_", Invk_clear = "clear", Invk_grps_add = "grps_add";
|
||||
private static final byte Raw_tid_dec = 0, Raw_tid_grp = 1;
|
||||
private static final byte[] Dec_dlm_default = new byte[] {Byte_ascii.Dot};
|
||||
public static final byte[] Grp_dlm_default = new byte[] {Byte_ascii.Comma};
|
||||
private static final byte[] Dec_dlm_default = new byte[] {Byte_ascii.Dot};
|
||||
public static final byte[] Grp_dlm_default = new byte[] {Byte_ascii.Comma};
|
||||
public static final byte Tid_format = 0, Tid_raw = 1, Tid_nosep = 2;
|
||||
}
|
||||
class Gfo_num_fmt_wkr {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Xol_num_grp_fmtr_tst {
|
||||
}
|
||||
class Xol_num_grp_fmtr_fxt {
|
||||
private Xol_num_grp_fmtr grouper = new Xol_num_grp_fmtr();
|
||||
private Bry_bfr bfr = Bry_bfr.new_();
|
||||
private Bry_bfr bfr = Bry_bfr_.New();
|
||||
public void Reset() {}
|
||||
public void Test_fmt_regx(String raw, String expd) {
|
||||
byte[] actl = grouper.Fmt_regx(bfr, Bry_.new_a7(raw));
|
||||
|
||||
@@ -16,10 +16,10 @@ 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.numbers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_num_mgr implements GfoInvkAble {
|
||||
public class Xol_num_mgr implements Gfo_invk {
|
||||
private boolean digits_translate;
|
||||
protected Bry_bfr tmp_bfr = Bry_bfr.reset_(32);
|
||||
private static final byte[] Comma_bry = Bry_.new_a7(",");
|
||||
protected Bry_bfr tmp_bfr = Bry_bfr_.Reset(32);
|
||||
private static final byte[] Comma_bry = Bry_.new_a7(",");
|
||||
public Xol_num_grp_fmtr Num_grp_fmtr() {return num_grp_fmtr;} private Xol_num_grp_fmtr num_grp_fmtr = new Xol_num_grp_fmtr();
|
||||
public Xol_transform_mgr Separators_mgr() {return separators_mgr;} private Xol_transform_mgr separators_mgr = new Xol_transform_mgr();
|
||||
public Xol_transform_mgr Digits_mgr() {return digits_mgr;} private Xol_transform_mgr digits_mgr = new Xol_transform_mgr();
|
||||
@@ -62,12 +62,12 @@ public class Xol_num_mgr implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_digits)) {digits_translate = true; return digits_mgr;} // NOTE: only langes with a digit_transform_table will call digits; DATE:2014-05-28
|
||||
else if (ctx.Match(k, Invk_digit_grouping_pattern)) return String_.new_u8(num_grp_fmtr.Digit_grouping_pattern());
|
||||
else if (ctx.Match(k, Invk_digit_grouping_pattern_)) num_grp_fmtr.Digit_grouping_pattern_(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_clear = "clear", Invk_separators = "separators"
|
||||
, Invk_digits = "digits", Invk_digit_grouping_pattern = "digit_grouping_pattern", Invk_digit_grouping_pattern_ = "digit_grouping_pattern_";
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
Separators_key__grp = new byte[]{Byte_ascii.Comma}
|
||||
, Separators_key__dec = new byte[]{Byte_ascii.Dot}
|
||||
;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.numbers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xol_transform_mgr implements GfoInvkAble {
|
||||
public class Xol_transform_mgr implements Gfo_invk {
|
||||
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();
|
||||
@@ -47,7 +47,7 @@ public class Xol_transform_mgr implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_set)) Set(m.ReadBry("k"), m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_clear)) Clear();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_set = "set", Invk_clear = "clear";
|
||||
|
||||
@@ -76,7 +76,7 @@ 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 Instance = new Xol_csv_parser(); 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 Instance = new Xol_csv_parser(); Xol_csv_parser() {}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ 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.Instance; 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));
|
||||
|
||||
@@ -24,7 +24,7 @@ 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.Instance;
|
||||
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];
|
||||
@@ -53,7 +53,7 @@ public class Xol_lang_srl {
|
||||
public static void Load_keywords(Xol_kwd_mgr keyword_mgr, byte[] src) {
|
||||
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_();
|
||||
List_adp cur_words = 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
|
||||
@@ -199,7 +199,7 @@ public class Xol_lang_srl {
|
||||
bldr.Add_paren_end().Add_proc_cont_one(Invk_lang).Add_nl(); // ).lang\n
|
||||
}
|
||||
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;
|
||||
int specials_len = specials_mgr.Len(); 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_itm.Invk_specials).Add_nl();
|
||||
|
||||
@@ -205,7 +205,7 @@ class Xol_lang_srl_fxt {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
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_(); Xoa_gfs_bldr bldr = new Xoa_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_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_.Tid__1st, Bry_.new_u8(s), false);}
|
||||
@@ -281,7 +281,7 @@ class Xol_lang_srl_fxt {
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
private Xol_specials_itm[] To_ary(Xol_specials_mgr specials_mgr) {
|
||||
int len = specials_mgr.Count();
|
||||
int len = specials_mgr.Len();
|
||||
Xol_specials_itm[] rv = new Xol_specials_itm[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
rv[i] = specials_mgr.Get_at(i);
|
||||
@@ -304,7 +304,7 @@ class Xol_lang_srl_fxt {
|
||||
}
|
||||
Xol_kwd_grp[] To_ary(Xol_kwd_mgr kwd_mgr) {
|
||||
int len = kwd_mgr.Len();
|
||||
List_adp rv = List_adp_.new_();
|
||||
List_adp rv = List_adp_.New();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xol_kwd_grp kwd_grp = kwd_mgr.Get_at(i);
|
||||
if (kwd_grp == null) continue;
|
||||
@@ -328,7 +328,7 @@ class Xol_lang_srl_fxt {
|
||||
}
|
||||
Xol_msg_itm[] To_ary(Xol_msg_mgr msg_mgr) {
|
||||
int len = msg_mgr.Itms_max();
|
||||
List_adp rv = List_adp_.new_();
|
||||
List_adp rv = List_adp_.New();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xol_msg_itm itm = msg_mgr.Itm_by_id_or_null(i);
|
||||
if (itm == null || !itm.Dirty()) continue;
|
||||
|
||||
@@ -37,8 +37,8 @@ class Xol_plural__default implements Xol_plural {
|
||||
switch (forms_len) {
|
||||
case 0: return Bry_.Empty; // forms is empty; do nothing
|
||||
case 1: return forms[0]; // only one word specified; use it; REF.MW:$pluralForm = min( $pluralForm, count( $forms ) - 1 );
|
||||
default: return count == 1 ? forms[0] : forms[1]; // TODO: incorporate plurals.xml logic
|
||||
default: return count == 1 ? forms[0] : forms[1]; // TODO_OLD: incorporate plurals.xml logic
|
||||
}
|
||||
}
|
||||
public static final Xol_plural__default Instance = new Xol_plural__default(); Xol_plural__default() {}
|
||||
public static final Xol_plural__default Instance = new Xol_plural__default(); Xol_plural__default() {}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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_itm lang) {this.lang = lang;} private Xol_lang_itm lang;
|
||||
public class Xol_specials_mgr implements Gfo_invk {
|
||||
private final Ordered_hash hash_by_special = Ordered_hash_.New_bry(), hash_by_aliases = Ordered_hash_.New_bry();
|
||||
private final Xol_lang_itm lang;
|
||||
public Xol_specials_mgr(Xol_lang_itm lang) {this.lang = lang;}
|
||||
public void Clear() {hash_by_special.Clear();}
|
||||
public int Count() {return hash_by_special.Count();}
|
||||
public int Len() {return hash_by_special.Len();}
|
||||
public Xol_specials_itm Get_at(int i) {return (Xol_specials_itm)hash_by_special.Get_at(i);}
|
||||
public Xol_specials_itm Get_by_alias(byte[] alias) {return (Xol_specials_itm)hash_by_aliases.Get_by(alias);}
|
||||
public Xol_specials_itm Get_by_key(byte[] special) {return (Xol_specials_itm)hash_by_special.Get_by(special);}
|
||||
@@ -39,7 +40,7 @@ public class Xol_specials_mgr implements GfoInvkAble {
|
||||
if (ctx.Match(k, Invk_lang)) return lang;
|
||||
else if (ctx.Match(k, Invk_clear)) this.Clear();
|
||||
else if (ctx.Match(k, Invk_load_text)) Xol_lang_srl.Load_specials(this, m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_lang = "lang", Invk_clear = "clear", Invk_load_text = "load_text";
|
||||
|
||||
@@ -17,21 +17,21 @@ 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.*;
|
||||
public class Xol_vnt_itm implements GfoInvkAble {
|
||||
public class Xol_vnt_itm implements Gfo_invk {
|
||||
public Xol_vnt_itm(int idx, byte[] key, byte[] name, int mask__vnt) {
|
||||
this.idx = idx; this.key = key; this.name = name; this.mask__vnt = mask__vnt;
|
||||
this.convert_wkr = new Xol_convert_wkr(key);
|
||||
}
|
||||
public int Idx() {return idx;} private final int idx; // EX: 2
|
||||
public byte[] Key() {return key;} private final byte[] key; // EX: zh-cn
|
||||
public byte[] Name() {return name;} private final byte[] name; // EX: 大陆简体
|
||||
public int Idx() {return idx;} private final int idx; // EX: 2
|
||||
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 int Mask__vnt() {return mask__vnt;} private final int mask__vnt; // EX: 8
|
||||
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 Xol_convert_wkr Convert_wkr() {return convert_wkr;} private final Xol_convert_wkr convert_wkr;
|
||||
public void Visible_(boolean v) {this.visible = v;}
|
||||
public void Convert_ary_(byte[][] v) {convert_ary = v;}
|
||||
public void Init(int dir, byte[][] fallback_ary) {
|
||||
@@ -44,7 +44,7 @@ public class Xol_vnt_itm implements GfoInvkAble {
|
||||
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_dir_)) dir = Xol_vnt_dir_.Parse(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_fallbacks_ = "fallbacks_", Invk_converts_ = "converts_", Invk_dir_ = "dir_";
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ 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.*;
|
||||
public class Xol_vnt_mgr implements GfoInvkAble {
|
||||
public class Xol_vnt_mgr implements Gfo_invk {
|
||||
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_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
|
||||
@@ -65,8 +65,8 @@ public class Xol_vnt_mgr implements GfoInvkAble {
|
||||
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_itm_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_html_style_)) html__lnki_style = m.ReadStr("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_get = "get", Invk_init_end = "init_end", Invk_cur_vnt_ = "cur_vnt_", Invk_vnt_grp_ = "vnt_grp_", Invk_html_style_ = "html_style_";
|
||||
private static final byte[] Msg_variantname = Bry_.new_a7("variantname-");
|
||||
private static final byte[] Msg_variantname = Bry_.new_a7("variantname-");
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.core.btries.*; import gplx.core.bits.*;
|
||||
import gplx.xowa.parsers.vnts.*;
|
||||
public class Xol_vnt_regy {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.ci_a7(); private int hash_len;
|
||||
private final List_adp list = List_adp_.new_();
|
||||
public Btrie_slim_mgr Trie() {return trie;} private final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.ci_a7(); private int hash_len;
|
||||
private final List_adp list = List_adp_.New();
|
||||
public Btrie_slim_mgr Trie() {return trie;} private final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7();
|
||||
public int Len() {return hash.Count();}
|
||||
public boolean Has(byte[] k) {return hash.Has(k);}
|
||||
public Xol_vnt_itm Get_at(int i) {return (Xol_vnt_itm)list.Get_at(i);}
|
||||
|
||||
@@ -17,16 +17,16 @@ 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();
|
||||
public class Xol_convert_grp implements Gfo_invk {// group of convert_itm by vnt; EX: zh-hant {A -> A1; B -> B1}
|
||||
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 byte[] Key() {return key;} private final byte[] key;
|
||||
public int Len() {return hash.Count();}
|
||||
public Xol_convert_itm Get_at(int i) {return (Xol_convert_itm)hash.Get_at(i);}
|
||||
public void Add(byte[] src, byte[] trg) {hash.Add_if_dupe_use_nth(src, new Xol_convert_itm(src, trg));}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_add_bulk)) Add_bulk(this, m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_add_bulk = "add_bulk";
|
||||
private static void Add_bulk(Xol_convert_grp grp, byte[] raw) {
|
||||
|
||||
@@ -18,8 +18,8 @@ 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.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xol_convert_mgr {
|
||||
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();
|
||||
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; private int wkr_ary_len;
|
||||
public void Init(Xol_vnt_regy regy) {
|
||||
int len = regy.Len();
|
||||
@@ -48,7 +48,7 @@ public class Xol_convert_mgr {
|
||||
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.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.Data__core_mgr().Tbl__page().Select_in__ns_ttl(Cancelable_.Never, tmp_page_list, wiki.Ns_mgr(), true, 0, converted); // TODO_OLD: 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);
|
||||
|
||||
@@ -17,8 +17,8 @@ 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();
|
||||
public class Xol_convert_regy implements Gfo_invk { // registry of convert_grp; EX: zh-hans;zh-hant;
|
||||
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);
|
||||
@@ -30,7 +30,7 @@ public class Xol_convert_regy implements GfoInvkAble { // registry of convert_gr
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get_or_make(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
} private static final String Invk_get = "get";
|
||||
public static Io_url Bld_url(Xoa_fsys_mgr app_fsys_mgr, String lang) {return Bld_url(app_fsys_mgr.Cfg_lang_core_dir(), lang);}
|
||||
public static Io_url Bld_url(Io_url dir, String lang) {return dir.GenSubFil_nest("variants", lang + ".gfs");}
|
||||
|
||||
@@ -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 org.junit.*; import gplx.core.log_msgs.*; import gplx.langs.phps.*;
|
||||
public class Xol_mw_parse_tst {
|
||||
private final Xol_mw_parse_fxt fxt = new Xol_mw_parse_fxt();
|
||||
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"
|
||||
@@ -80,12 +80,12 @@ class Xol_mw_parse_itm {
|
||||
class Xol_mw_parse_fxt {
|
||||
public void Test_convert(String mw, String expd) {
|
||||
Xol_mw_parse_grp[] actl_ary = Parse(Bry_.new_u8(mw));
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
actl_ary[0].Write_as_gfs(bfr);
|
||||
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_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Io_url[] fils = Io_mgr.Instance.QueryDir_fils(src_dir);
|
||||
int fils_len = fils.length;
|
||||
for (int i = 0; i < fils_len; i++) {
|
||||
@@ -103,7 +103,7 @@ class Xol_mw_parse_fxt {
|
||||
}
|
||||
}
|
||||
public Xol_mw_parse_grp[] Parse(byte[] src) {
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
Php_parser parser = new Php_parser();
|
||||
Gfo_msg_log msg_log = new Gfo_msg_log("xowa");
|
||||
Php_evaluator evaluator = new Php_evaluator(msg_log);
|
||||
@@ -117,7 +117,7 @@ class Xol_mw_parse_fxt {
|
||||
}
|
||||
return (Xol_mw_parse_grp[])list.To_ary(Xol_mw_parse_grp.class);
|
||||
}
|
||||
private List_adp tmp_itm_list = List_adp_.new_();
|
||||
private List_adp tmp_itm_list = List_adp_.New();
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user