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

'v3.8.2.1'

This commit is contained in:
gnosygnu
2016-08-07 21:36:50 -04:00
parent b0fdf78a41
commit e4a2af026b
165 changed files with 2534 additions and 1247 deletions

View File

@@ -22,13 +22,13 @@ public class Xol_msg_itm {
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;} private int src;
public boolean Src_is_missing() {return src == Src_missing;}
public int Defined_in() {return defined_in;} private int defined_in;
public boolean Defined_in_none() {return defined_in == Defined_in__none;}
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;} private boolean dirty; // BLDR:
public Xol_msg_itm Src_(int v) {src = v; return this;}
public Xol_msg_itm Defined_in_(int v) {defined_in = v; return this;}
public Xol_msg_itm Dirty_(boolean v) {dirty = v; return this;}
public void Atrs_set(byte[] val, boolean has_fmt_arg, boolean has_tmpl_txt) {
@@ -44,5 +44,5 @@ public class Xol_msg_itm {
fmtr.Bld_bfr_many(bfr, args);
return bfr.To_bry_and_clear();
}
public static final int Src_null = 0, Src_lang = 1, Src_wiki = 2, Src_missing = 3;
public static final int Defined_in__unknown = 0, Defined_in__lang = 1, Defined_in__wiki = 2, Defined_in__none = 3; // NOTE: unknown not manually used, but is different than none (which means missing?)
}

View File

@@ -42,7 +42,9 @@ public class Xol_msg_mgr_ {
public static byte[] Get_msg_val(Xowe_wiki wiki, Xol_lang_itm lang, byte[] msg_key, byte[][] fmt_args) {
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
Xol_msg_itm msg_itm = Get_msg_itm(tmp_bfr, wiki, lang, msg_key);
byte[] rv = Get_msg_val(tmp_bfr, wiki, msg_itm, fmt_args);
byte[] rv = (msg_itm.Defined_in_none())
? tmp_bfr.Add_byte(Byte_ascii.Lt).Add(msg_key).Add_byte(Byte_ascii.Gt).To_bry_and_clear() // NOTE: do not use key from msg_itm; msg_itms are case-insensitive, and val should match key exactly; EX: missing should return <missing> not <Missing> DATE:2016-08-01
: 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};
@@ -87,16 +89,16 @@ public class Xol_msg_mgr_ {
Xol_msg_itm msg_in_lang = Get_msg_itm_from_gfs(wiki, lang, msg_key_sub_root);
if (msg_in_lang == null) {
msg_val = tmp_bfr.Add_byte(Byte_ascii.Lt).Add(msg_key).Add_byte(Byte_ascii.Gt).To_bry_and_clear(); // set val to <msg_key>
msg_in_wiki.Src_(Xol_msg_itm.Src_missing);
msg_in_wiki.Defined_in_(Xol_msg_itm.Defined_in__none);
}
else {
msg_val = msg_in_lang.Val();
msg_in_wiki.Src_(Xol_msg_itm.Src_lang);
msg_in_wiki.Defined_in_(Xol_msg_itm.Defined_in__lang);
}
}
else { // page found; dump entire contents
msg_val = Xoa_gfs_php_mgr.Xto_gfs(tmp_bfr, msg_page.Db().Text().Text_bry()); // note that MediaWiki msg's use php arg format ($1); xowa.gfs msgs are already converted
msg_in_wiki.Src_(Xol_msg_itm.Src_wiki);
msg_in_wiki.Defined_in_(Xol_msg_itm.Defined_in__wiki);
}
Xol_msg_itm_.update_val_(msg_in_wiki, msg_val);
return msg_in_wiki;

View File

@@ -16,10 +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.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();
@Before public void init() {fxt.Clear();}
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.langs.msgs.*;
public class Xol_msg_mgr_tst {
@Before public void init() {fxt.Clear();} private final Xol_msg_mgr_fxt fxt = new Xol_msg_mgr_fxt();
@Test public void Template_msg() {fxt.Test_val_by_key("About {{SITENAME}}", "About Wikipedia");} // PURPOSE.fix: {{Template}} not working inside label tags; EX:de.wikisource.org; DATE:2013-02-10
@Test public void Template_mediawiki() { // PURPOSE.fix: {{Template}} not working inside MediaWiki template
fxt.Test_mediaWiki_msg("About {{SITENAME}}", "About Wikipedia");
@@ -30,6 +29,10 @@ public class Xol_msg_mgr_tst {
fxt.Clear().Test_val_html_accesskey_and_title("test_title" , "" , " title=\"test_title\""); // accesskey is ""
fxt.Clear().Test_val_html_accesskey_and_title(null , "a" , " title=\"\""); // no title; leave blank
}
@Test public void Missing() {
fxt.Test__get_msg_val("missing", "<missing>"); // check that key is enclosed in <>
fxt.Test__get_msg_val("Missing", "<Missing>"); // check that val matches key; used to match 1st case-insensitive variant; EX: "<missing>" b/c "<missing>" was returned above; DATE:2016-08-01
}
}
class Xol_msg_mgr_fxt {
public Xol_msg_mgr_fxt Clear() {
@@ -57,6 +60,9 @@ class Xol_msg_mgr_fxt {
if (init_accesskey != null) new_msg_itm_("accesskey-test" , init_accesskey);
Tfds.Eq(expd, String_.new_a7(wiki.Msg_mgr().Val_html_accesskey_and_title(Bry_.new_a7("test"))));
}
public void Test__get_msg_val(String key, String expd) {
Gftest.Eq__str(expd, Xol_msg_mgr_.Get_msg_val(wiki, wiki.Lang(), Bry_.new_a7(key), Bry_.Ary_empty));
}
private void new_msg_itm_(String key, String val) {
Xol_msg_itm itm = wiki.Lang().Msg_mgr().Itm_by_key_or_new(Bry_.new_a7(key));
itm.Atrs_set(Bry_.new_a7(val), false, true);

View File

@@ -20,12 +20,12 @@ public class Xow_mainpage_finder {
public static byte[] Find_or(Xowe_wiki wiki, byte[] or) {
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
Xol_msg_itm msg_itm = Xol_msg_mgr_.Get_msg_itm(tmp_bfr, wiki, wiki.Lang(), Msg_mainpage);
byte[] rv = msg_itm.Src_is_missing()
byte[] rv = msg_itm.Defined_in_none()
? or
: Xol_msg_mgr_.Get_msg_val(tmp_bfr, wiki, msg_itm, Bry_.Ary_empty)
;
tmp_bfr.Mkr_rls();
return rv;
}
public static final byte[] Msg_mainpage = Bry_.new_a7("mainpage");
public static final byte[] Msg_mainpage = Bry_.new_a7("mainpage");
}

View File

@@ -49,7 +49,7 @@ public class Xow_msg_mgr implements Gfo_invk {
if (itm == null) {
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
itm = Xol_msg_mgr_.Get_msg_itm(tmp_bfr, wiki, lang, key);
if (itm.Src_is_missing()) itm = null;
if (itm.Defined_in_none()) itm = null;
tmp_bfr.Mkr_rls();
}
return itm;
@@ -62,7 +62,7 @@ public class Xow_msg_mgr implements Gfo_invk {
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
if (itm == null)
itm = Xol_msg_mgr_.Get_msg_itm(tmp_bfr, wiki, lang, key);
if (itm.Src_is_missing()) {
if (itm.Defined_in_none()) {
tmp_bfr.Mkr_rls();
return Bry_.Empty;
}

View File

@@ -113,7 +113,7 @@ public class Xol_lang_srl {
break;
case Byte_ascii.Nl:
byte[] cur_val = csv_parser.Load(src, fld_bgn, pos);
Xol_msg_itm itm = msg_mgr.Itm_by_key_or_new(cur_key).Src_(Xol_msg_itm.Src_lang); // NOTE: this proc should only be called when loading lang.gfs
Xol_msg_itm itm = msg_mgr.Itm_by_key_or_new(cur_key).Defined_in_(Xol_msg_itm.Defined_in__lang); // NOTE: this proc should only be called when loading lang.gfs
Xol_msg_itm_.update_val_(itm, cur_val);
itm.Dirty_(true);
fld_bgn = pos + 1;