Ejemplo n.º 1
0
 @Override
 public void Func_evaluate(Bry_bfr bfr, Xop_ctx ctx, Xot_invk caller, Xot_invk self, byte[] src) {
   byte[] user_name = Eval_argx(ctx, src, caller, self);
   byte[] when_m = Bry_.Empty, when_f = Bry_.Empty, when_u = Bry_.Empty;
   int self_args_len = self.Args_len();
   if (self_args_len == 0) return; // per MW: EX: {{gender:name}} -> ""
   else {
     if (self_args_len > 0) {
       when_m =
           when_u =
               Pf_func_.Eval_arg_or_empty(
                   ctx, src, caller, self, self_args_len, 0); // default when_u to when_m
       if (self_args_len > 1) {
         when_f = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, self_args_len, 1);
         if (self_args_len > 2) {
           when_u = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, self_args_len, 2);
         }
       }
     }
   }
   if (self_args_len == 1) {
     bfr.Add(when_m);
     return;
   } // per MW: EX: {{gender:name|a}} -> "a"
   int gender = Get_gender(ctx.App().User(), user_name);
   Xol_lang_itm lang = ctx.Page().Lang();
   bfr.Add(lang.Gender().Gender_eval(gender, when_m, when_f, when_u));
 }
Ejemplo n.º 2
0
 public static void Reg(
     Xow_domain_itm domain_itm, gplx.xowa.langs.funcs.Xol_func_regy func_regy, Xol_lang_itm lang) {
   Xol_kwd_mgr kwd_mgr = lang.Kwd_mgr();
   int[] kwd_ary = Ary_get(domain_itm, !lang.Kwd_mgr__strx());
   int len = kwd_ary.length;
   for (int i = 0; i < len; i++) {
     int id = kwd_ary[i];
     func_regy.Reg_defn(kwd_mgr, id, Get_prototype(id));
   }
 }
Ejemplo n.º 3
0
 public Xow_special_mgr(Xowe_wiki wiki, Xol_lang_itm lang) {
   this.app = wiki.App();
   hash = Hash_adp_bry.ci_u8(lang.Case_mgr());
   page_allpages = new Xows_page_allpages(wiki);
   page_search = new Srch_special_page(wiki);
   Evt_lang_changed(wiki.Lang());
 }
Ejemplo n.º 4
0
 private void Format_durations_init() {
   Xol_msg_mgr msg_mgr = lang.Msg_mgr();
   int len = Xol_duration_itm_.Ary_default.length;
   interval_msgs = new Xol_msg_itm[len];
   for (int i = 0; i < len; i++) {
     Xol_duration_itm itm = Xol_duration_itm_.Ary_default[i];
     byte[] msg_key = Bry_.Add(Bry_duration, itm.Name_bry());
     interval_msgs[i] = msg_mgr.Itm_by_key_or_new(msg_key);
   }
 }
Ejemplo n.º 5
0
  public void Evt_lang_changed(Xol_lang_itm lang) {
    // add special pages by old manual method; DEPRECATED
    hash.Clear();
    hash.Add_str_obj(Xow_special_meta_.Ttl__search, page_search);
    hash.Add_str_obj(Xow_special_meta_.Ttl__all_pages, page_allpages);
    hash.Add_str_obj("prefixindex", page_allpages);
    hash.Add_bry_obj(Xou_history_mgr.Ttl_name, page_history);
    hash.Add_str_obj(Xow_special_meta_.Ttl__page_history, page_history2);
    hash.Add_str_obj(Xow_special_meta_.Ttl__nearby, page_nearby);
    hash.Add_str_obj(Xow_special_meta_.Ttl__my_language, page_mylanguage);
    hash.Add_str_obj(Xow_special_meta_.Ttl__item_by_title, page_itemByTitle);
    hash.Add_str_obj(Xow_special_meta_.Ttl__statistics, page_statistics);
    hash.Add_str_obj(Xow_special_meta_.Ttl__move_page, page_movePage);
    hash.Add_str_obj(Xow_special_meta_.Ttl__system_data, page_system_data);
    hash.Add_str_obj(Xow_special_meta_.Ttl__default_tab, page_default_tab);
    hash.Add_str_obj(Xow_special_meta_.Ttl__popup_history, page_popup_history);
    hash.Add_str_obj(Xow_special_meta_.Ttl__bookmarks, page_bmk);
    hash.Add_str_obj(Xow_special_meta_.Ttl__diag, page_diag);

    // add app's Special_regy to hash table; needed for case insensitivity by wiki's lang; EX:
    // Special:rANDom; NOTE: needs to go before lang aliases
    Xoa_special_regy special_regy = app.Special_regy();
    int len = special_regy.Len();
    for (int i = 0; i < len; ++i) {
      Xow_special_page proto = special_regy.Get_at(i);
      Xow_special_meta proto_meta = proto.Special__meta();
      hash.Add_if_dupe_use_1st(proto_meta.Key_bry(), proto);
      for (byte[] alias : proto_meta.Aliases()) hash.Add_if_dupe_use_1st(alias, proto);
    }

    // add lang's special aliases to hash table; EX: Special:Recherche
    Xol_specials_mgr lang_mgr = lang.Specials_mgr();
    len = lang_mgr.Len();
    for (int i = 0; i < len; ++i) {
      Xol_specials_itm lang_itm = lang_mgr.Get_at(i);
      Xow_special_page page = (Xow_special_page) hash.Get_by_bry(lang_itm.Special());
      if (page == null)
        continue; // NOTE: ignore specials that are not in XOWA; EX: Special:ChangeEmail
      for (byte[] alias : lang_itm.Aliases()) hash.Add_if_dupe_use_1st(alias, page);
    }
  }
Ejemplo n.º 6
0
 private void List_to_str_init() {
   Xol_msg_mgr msg_mgr = lang.Msg_mgr();
   Msg_and = msg_mgr.Val_by_str_or_empty("and");
   Msg_word_separator = msg_mgr.Val_by_str_or_empty("word-separator");
   Msg_comma_separator = msg_mgr.Val_by_str_or_empty("comma-separator");
 }