"ব্যবহারকারী:Johnuniq/sandbox" পাতাটির দুইটি সংশোধিত সংস্করণের মধ্যে পার্থক্য

have narrowed down problem
(tweaks)
(have narrowed down problem)
Demonstration of problem using mw.loadData using [[Module:Convert/sandbox]].
[[Module:Convert]] has a problem at line 90:
*<code><nowiki>{{#invoke:convert/sandbox|123.4|mmain|mmTEST}}</nowiki></code> → {{#invoke:convert/sandbox|123.4|mmain|mmTEST}}
<pre> text = ustring.gsub(text, '%d', to_en_table)</pre>
*<code><nowiki>{{#invoke:convert/sandbox|১২৩.৪main|mTEST|mmrequire}}</nowiki></code> → {{#invoke:convert/sandbox|১২৩.৪main|mTEST|mmrequire}}
Before the above is the code <code>local ustring = mw.ustring</code>. The above is supposed to translate bn digits to en digits, but it makes no change to text.
*<code><nowiki>{{#invoke:convert/sandbox|main|TEST|load}}</nowiki></code> → {{#invoke:convert/sandbox|main|TEST|load}}
 
A test system is in the module to brute-force the translation. To view the results, edit the above module, then preview it using this page <code>User:Johnuniq/sandbox</code> as the target.
 
:Test 1 uses a local table (correct result).
*<code><nowiki>{{convert|123.4|m|mm}}</nowiki></code> → {{convert|123.4|m|mm}}
:Test 2 uses a table accessed with "require" (correct result).
*<code><nowiki>{{convert|১২৩.৪|m|mm}}</nowiki></code> → {{convert|১২৩.৪|m|mm}}
:Test 3 uses a table accessed with "loadData" (bug).
 
 
The above is working because ustring.gsub is currently not used, but when using the code shown above for line 90, the second convert gives the following because the input number is not converted to en digits:
:Conversion error: Value "১২৩.৪" must be a number
 
Paste the following into the debug window to see the mw.log output:
<pre>
=p.convert{ args = {}, getParent = function(f) return { args = {'TEST','mm','m'} } end }
</pre>
 
It shows:
<pre>
=p.convert{ args = {}, getParent = function(f) return { args = {'TEST','mm','m'} } end }
mw.ustring.gsub(১২৩৪৫৬৭৮৯০, '%d', to_en_table) → ১২৩৪৫৬৭৮৯০
loop string.gsub → 1234567890
<span style="color:black; background-color:orange;">[[Module talk:Convert|Conversion error]]: Value "TEST" must be a number[[Category:Convert error]]</span>
</pre>
 
The "mw.ustring.gsub" line shows that the input number is not translated. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|আলাপ]]) ০৪:২৬, ৪ জুলাই ২০১৩ (ইউটিসি)
৩০৮টি

সম্পাদনা