1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-29 23:10:52 +00:00

Xomw: Add more implementation for extractParam

This commit is contained in:
gnosygnu 2017-04-30 08:47:54 -04:00
parent af2d0c51db
commit 417fd8b990
6 changed files with 81 additions and 76 deletions

View File

@ -3010,13 +3010,13 @@ public class XomwDefaultSettings {
// * is 'dmy or mdy'. // * is 'dmy or mdy'.
// */ // */
// $wgAmericanDates = false; // $wgAmericanDates = false;
//
// /** /**
// * For Hindi and Arabic use local numerals instead of Western style (0-9) * For Hindi and Arabic use local numerals instead of Western style (0-9)
// * numerals in interface. * numerals in interface.
// */ */
// $wgTranslateNumerals = true; public static boolean wgTranslateNumerals = true;
//
// /** // /**
// * Translation using MediaWiki: namespace. // * Translation using MediaWiki: namespace.
// * Interface messages will be loaded from the database. // * Interface messages will be loaded from the database.

View File

@ -1108,7 +1108,7 @@ public class XomwMessage {
* @return String * @return String
*/ */
// DFLT:type="before" // DFLT:type="before"
// private byte[] replaceParameters(byte[] message, int prm_tid, int format) { // private byte[] replaceParameters(byte[] message, int type, int format) {
// $replacementKeys = []; // $replacementKeys = [];
// foreach (this.parameters as $n => $param) { // foreach (this.parameters as $n => $param) {
// list($paramType, $value) = this.extractParam($param, $format); // list($paramType, $value) = this.extractParam($param, $format);
@ -1141,30 +1141,29 @@ public class XomwMessage {
case XomwMessagePrm.Tid__num: case XomwMessagePrm.Tid__num:
// Replace number prmsVar always in before step for now. // Replace number prmsVar always in before step for now.
// No support for combined raw and num prmsVar // No support for combined raw and num prmsVar
// rv.Set(PRM_TID_BEFORE, this.getLanguage().formatNum((XomwMessagePrm_num)prm).num); rv.Set(PRM_TID_BEFORE, this.getLanguage().formatNum(((XomwMessagePrm_num)prm).numAsBry()));
// return [PRM_TID_BEFORE, this.getLanguage()->formatNum($param['num']) ];
break; break;
case XomwMessagePrm.Tid__duration: // case XomwMessagePrm.Tid__duration:
// return [PRM_TID_BEFORE, this.getLanguage()->formatDuration($param['duration']) ]; // return [PRM_TID_BEFORE, this.getLanguage()->formatDuration($param['duration']) ];
break; // break;
case XomwMessagePrm.Tid__expiry: // case XomwMessagePrm.Tid__expiry:
// return [PRM_TID_BEFORE, this.getLanguage()->formatExpiry($param['expiry']) ]; // return [PRM_TID_BEFORE, this.getLanguage()->formatExpiry($param['expiry']) ];
break; // break;
case XomwMessagePrm.Tid__period: // case XomwMessagePrm.Tid__period:
// return [PRM_TID_BEFORE, this.getLanguage()->formatTimePeriod($param['period']) ]; // return [PRM_TID_BEFORE, this.getLanguage()->formatTimePeriod($param['period']) ];
break; // break;
case XomwMessagePrm.Tid__size: // case XomwMessagePrm.Tid__size:
// return [PRM_TID_BEFORE, this.getLanguage()->formatSize($param['size']) ]; // return [PRM_TID_BEFORE, this.getLanguage()->formatSize($param['size']) ];
break; // break;
case XomwMessagePrm.Tid__bitrate: // case XomwMessagePrm.Tid__bitrate:
// return [PRM_TID_BEFORE, this.getLanguage()->formatBitrate($param['bitrate']) ]; // return [PRM_TID_BEFORE, this.getLanguage()->formatBitrate($param['bitrate']) ];
break; // break;
case XomwMessagePrm.Tid__plaintext: // case XomwMessagePrm.Tid__plaintext:
// return [PRM_TID_AFTER, this.formatPlaintext($param['plaintext'], $format) ]; // return [PRM_TID_AFTER, this.formatPlaintext($param['plaintext'], $format) ];
break; // break;
case XomwMessagePrm.Tid__list: // case XomwMessagePrm.Tid__list:
// return this.formatListParam($param['list'], $param['type'], $format); // return this.formatListParam($param['list'], $param['type'], $format);
break; // break;
default: default:
String warning = "Invalid parameter for message '" + this.getKey() + "': " + String warning = "Invalid parameter for message '" + this.getKey() + "': " +
prm.toString(); prm.toString();
@ -1373,6 +1372,7 @@ class XomwMessagePrm_raw extends XomwMessagePrm { public byte[] raw;
} }
} }
class XomwMessagePrm_num extends XomwMessagePrm { public int num; class XomwMessagePrm_num extends XomwMessagePrm { public int num;
public byte[] numAsBry() {return Int_.To_bry(num);}
public XomwMessagePrm_num(int num) {super(Tid__num); public XomwMessagePrm_num(int num) {super(Tid__num);
this.num = num; this.num = num;
} }

View File

@ -51,6 +51,7 @@ class XomwMediaWikiTitleCodecFxt {
public XomwLanguage Make_lang() { public XomwLanguage Make_lang() {
Xoae_app app = Xoa_app_fxt.Make__app__edit(); Xoae_app app = Xoa_app_fxt.Make__app__edit();
Xol_lang_itm lang = new Xol_lang_itm(app.Lang_mgr(), Xol_lang_itm_.Key_en); Xol_lang_itm lang = new Xol_lang_itm(app.Lang_mgr(), Xol_lang_itm_.Key_en);
XomwEnv env = new XomwEnv(lang);
return new XomwLanguage(lang); return new XomwLanguage(lang);
} }
public void Test_splitTitleString(XomwMediaWikiTitleCodec codec, String src, XomwMediaWikiTitleCodecParts expd) { public void Test_splitTitleString(XomwMediaWikiTitleCodec codec, String src, XomwMediaWikiTitleCodecParts expd) {

View File

@ -47,7 +47,7 @@ public class XomwLanguage {
// /** // /**
// * @var LocalisationCache // * @var LocalisationCache
// */ // */
// static public $dataCache; // static public $dataCache; // equivalent to MessagesLangCode.php
// //
// static public $mLangObjCache = []; // static public $mLangObjCache = [];
// //
@ -3267,49 +3267,52 @@ public class XomwLanguage {
// function emphasize($text) { // function emphasize($text) {
// return "<em>$text</em>"; // return "<em>$text</em>";
// } // }
//
// /** /**
// * Normally we output all numbers in plain en_US style, that is * Normally we output all numbers in plain en_US style, that is
// * 293,291.235 for twohundredninetythreethousand-twohundredninetyone * 293,291.235 for twohundredninetythreethousand-twohundredninetyone
// * point twohundredthirtyfive. However this is not suitable for all * point twohundredthirtyfive. However this is not suitable for all
// * languages, some such as Bengali (bn) want ,৯৩,২৯১.২৩৫ and others such as * languages, some such as Bengali (bn) want ,৯৩,২৯১.২৩৫ and others such as
// * Icelandic just want to use commas instead of dots, and dots instead * Icelandic just want to use commas instead of dots, and dots instead
// * of commas like "293.291,235". * of commas like "293.291,235".
// * *
// * An example of this function being called: * An example of this function being called:
// * <code> * <code>
// * wfMessage('message')->numParams($num)->text() * wfMessage('message')->numParams($num)->text()
// * </code> * </code>
// * *
// * See $separatorTransformTable on MessageIs.php for * See $separatorTransformTable on MessageIs.php for
// * the , => . and . => , implementation. * the , => . and . => , implementation.
// * *
// * @todo check if it's viable to use localeconv() for the decimal separator thing. * @todo check if it's viable to use localeconv() for the decimal separator thing.
// * @param int|float $number The String to be formatted, should be an integer * @param int|float $number The String to be formatted, should be an integer
// * or a floating point number. * or a floating point number.
// * @param boolean $nocommafy Set to true for special numbers like dates * @param boolean $nocommafy Set to true for special numbers like dates
// * @return String * @return String
// */ */
// public function formatNum($number, $nocommafy = false) { // DFLT:nocommafy=false
// global $wgTranslateNumerals; public byte[] formatNum(byte[] number) {return formatNum(number, false);}
// if (!$nocommafy) { public byte[] formatNum(byte[] number, boolean nocommafy) {
// $number = this.commafy($number); if (!nocommafy) {
// $s = this.separatorTransformTable(); // XOMW: use earlier port
// if ($s) { // number = this.commafy(number);
// $number = strtr($number, $s); // s = this.separatorTransformTable();
// if (s) {
// number = strtr(number, s);
// }
return xoLang.Num_mgr().Format_num(number, nocommafy);
}
if (XomwDefaultSettings.wgTranslateNumerals) {
// s = this.digitTransformTable();
// if (s) {
// number = strtr(number, s);
// } // }
// } }
//
// if ($wgTranslateNumerals) { return number;
// $s = this.digitTransformTable(); }
// if ($s) {
// $number = strtr($number, $s);
// }
// }
//
// return $number;
// }
//
// /** // /**
// * Front-end for non-commafied formatNum // * Front-end for non-commafied formatNum
// * // *
@ -3512,14 +3515,14 @@ public class XomwLanguage {
// function digitTransformTable() { // function digitTransformTable() {
// return self::$dataCache->getItem(this.mCode, 'digitTransformTable'); // return self::$dataCache->getItem(this.mCode, 'digitTransformTable');
// } // }
//
// /** /**
// * @return array * @return array
// */ */
// function separatorTransformTable() { // private byte[][] separatorTransformTable() {
// return self::$dataCache->getItem(this.mCode, 'separatorTransformTable'); // return self::$dataCache->getItem(this.mCode, 'separatorTransformTable');
// } // }
//
// /** // /**
// * Take a list of strings and build a locale-friendly comma-separated // * Take a list of strings and build a locale-friendly comma-separated
// * list, using the local comma-separator message. // * list, using the local comma-separator message.

View File

@ -118,6 +118,7 @@ class XomwLanguageFxt {
public XomwLanguageFxt() { public XomwLanguageFxt() {
Xoae_app app = Xoa_app_fxt.Make__app__edit(); Xoae_app app = Xoa_app_fxt.Make__app__edit();
Xol_lang_itm xoLang = new Xol_lang_itm(app.Lang_mgr(), Bry_.new_a7("en")); Xol_lang_itm xoLang = new Xol_lang_itm(app.Lang_mgr(), Bry_.new_a7("en"));
XomwEnv env = new XomwEnv(xoLang);
this.lang = new XomwLanguage(xoLang); this.lang = new XomwLanguage(xoLang);
} }
public void Init_digitGroupingPattern(String digitGroupingPattern) { public void Init_digitGroupingPattern(String digitGroupingPattern) {

View File

@ -1 +1 @@
blog_new_job_ update