1
0
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:
gnosygnu
2015-10-18 22:17:57 -04:00
parent 8e18af05b6
commit 4f43f51b18
1935 changed files with 12500 additions and 12889 deletions

View File

@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.translates; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.primitives.*;
import gplx.xowa.nss.*;
import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*;
public class Xop_languages_xnde implements Xox_xnde {
public Xop_xnde_tkn Xnde() {return xnde;} private Xop_xnde_tkn xnde;
@@ -56,17 +56,17 @@ public class Xop_languages_xnde implements Xox_xnde {
&& page_ttl_bry[lang_bgn - 1] == Xoa_ttl.Subpage_spr // prv char must be /; EX: "Page/fr"
) {
byte[] lang_key = Bry_.Mid(page_ttl_bry, lang_bgn, page_ttl_bry_len);
if (Bry_.Eq(lang_key, Xol_lang_.Key_en)) // lang is english; mark english found;
if (Bry_.Eq(lang_key, Xol_lang_itm_.Key_en)) // lang is english; mark english found;
english_needed = false;
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key(lang_key);
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_null(lang_key);
if (lang_itm == null) continue; // not a known lang
rv.Add(lang_itm);
}
}
if (rv.Count() == 0) return List_adp_.Noop; // no lang items; handles situations where just "Page" is returned
if (english_needed) // english not found; always add; handles situations wherein Page/fr and Page/de added, but not Page/en
rv.Add(Xol_lang_itm_.Get_by_key(Xol_lang_.Key_en));
rv.Sort_by(Xol_lang_itm_.Comparer_key);
rv.Add(Xol_lang_stub_.Get_by_key_or_en(Xol_lang_itm_.Key_en));
rv.Sort_by(Xol_lang_stub_.Comparer_key);
return rv;
}
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
@@ -108,24 +108,24 @@ class Xop_languages_fmtr implements Bry_fmtr_arg {
this.root_ttl = root_ttl;
this.cur_lang = cur_lang;
} private List_adp langs; private Xowe_wiki wiki; private Xoa_ttl root_ttl; private byte[] cur_lang;
public void XferAry(Bry_bfr bfr, int idx) {
public void Fmt__do(Bry_bfr bfr) {
int len = langs.Count();
Xoh_href_wtr href_wtr = wiki.Appe().Html__href_wtr();
int ns_id = root_ttl.Ns().Id();
byte[] root_ttl_bry = root_ttl.Page_db(); // NOTE: do not use .Full(); ns will be added in Xoa_ttl.parse below
for (int i = 0; i < len; i++) {
Xol_lang_itm lang = (Xol_lang_itm)langs.Get_at(i);
Xol_lang_stub lang = (Xol_lang_stub)langs.Get_at(i);
byte[] lang_key = lang.Key();
boolean lang_is_en = Bry_.Eq(lang_key, Xol_lang_.Key_en);
boolean lang_is_en = Bry_.Eq(lang_key, Xol_lang_itm_.Key_en);
byte[] lang_ttl_bry = lang_is_en ? root_ttl_bry : Bry_.Add_w_dlm(Xoa_ttl.Subpage_spr, root_ttl_bry, lang_key);
Xoa_ttl lang_ttl = Xoa_ttl.parse(wiki, ns_id, lang_ttl_bry);
byte[] lang_href = href_wtr.Build_to_bry(wiki, lang_ttl);
byte[] lang_title = Xoh_html_wtr.Ttl_to_title(lang_ttl.Full_txt());
Bry_fmtr fmtr = null;
if (Bry_.Eq(lang_key, Xol_lang_.Key_en)) fmtr = Xop_languages_xnde.fmtr_itm_english;
if (Bry_.Eq(lang_key, Xol_lang_itm_.Key_en)) fmtr = Xop_languages_xnde.fmtr_itm_english;
else if (Bry_.Eq(lang_key, cur_lang)) fmtr = Xop_languages_xnde.fmtr_itm_selected;
else fmtr = Xop_languages_xnde.fmtr_itm_basic;
fmtr.Bld_bfr_many(bfr, lang_href, lang_title, lang.Localized_name());
fmtr.Bld_bfr_many(bfr, lang_href, lang_title, lang.Canonical_name());
}
}
}

View File

@@ -19,7 +19,7 @@ package gplx.xowa.xtns.translates; import gplx.*; import gplx.xowa.*; import gpl
import org.junit.*;
public class Xop_languages_xnde_tst {
@Before public void init() {
Io_mgr.I.InitEngine_mem();
Io_mgr.Instance.InitEngine_mem();
fxt.Reset();
fxt.Page_ttl_("Help:A");
fxt.Init_page_create("Help:A", ""); // create for AllPages

View File

@@ -25,7 +25,7 @@ public class Xop_mylanguage_page implements Xows_page {
byte[] page_bry = ttl.Leaf_txt_wo_qarg(); // EX: Help:A
byte[] lang_key = wiki.Appe().Usere().Lang().Key_bry(); // EX: fr
byte[] trg_bry = page_bry;
boolean lang_is_english = Bry_.Eq(lang_key, Xol_lang_.Key_en);
boolean lang_is_english = Bry_.Eq(lang_key, Xol_lang_itm_.Key_en);
if (!lang_is_english)
trg_bry = Bry_.Add_w_dlm(Xoa_ttl.Subpage_spr, page_bry, lang_key);
Xoae_page found_page = wiki.Data_mgr().Redirect(page, trg_bry);

View File

@@ -16,11 +16,11 @@ 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.xtns.translates; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.html.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*;
public class Xop_translate_xnde implements Xox_xnde, Xop_xnde_atr_parser {
import gplx.xowa.htmls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
public class Xop_translate_xnde implements Xox_xnde {
public Xop_root_tkn Xtn_root() {return xtn_root;} private Xop_root_tkn xtn_root;
public void Xatr_parse(Xowe_wiki wiki, byte[] src, Xop_xatr_itm xatr, Object xatr_obj) {}
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {}
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
byte[] translate_src = Bry_.Mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
translate_src = Bry_.Trim(translate_src, 0, translate_src.length);

View File

@@ -21,7 +21,7 @@ import gplx.xowa.parsers.*;
public class Xop_tvar_lxr implements Xop_lxr {
public int Lxr_tid() {return Xop_lxr_.Tid_tvar;}
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook_bgn, this);}
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
public void Init_by_lang(Xol_lang_itm lang, Btrie_fast_mgr core_trie) {}
public void Term(Btrie_fast_mgr core_trie) {}
private static final byte[] Hook_bgn = Bry_.new_a7("<tvar|"), Close_nde = Bry_.new_a7("</>");
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
@@ -35,5 +35,5 @@ public class Xop_tvar_lxr implements Xop_lxr {
ctx.Subs_add(root, tkn_mkr.Tvar(bgn_pos, end_pos, cur_pos, rhs_end, rhs_end + Int_.Const_position_after_char, lhs_bgn, body));
return end_pos;
}
public static final Xop_tvar_lxr _ = new Xop_tvar_lxr(); Xop_tvar_lxr() {}
public static final Xop_tvar_lxr Instance = new Xop_tvar_lxr(); Xop_tvar_lxr() {}
}