Mô đun:Science redirect
| Mô đun này được xếp loại beta. Nó được đánh giá là sẵn sàng để sử dụng rộng rãi, nhưng vì nó vẫn còn khá là mới, nên vẫn cần phải được sử dụng một cách thận trọng để đảm bảo rằng kết quả đạt được như mong đợi. |
| Mô đun Lua này được sử dụng ở rất nhiều trang, vì thế những thay đổi đến nó sẽ hiện ra rõ ràng. Vui lòng thử nghiệm các thay đổi ở trang con /sandbox, /testcases của mô đun, hoặc ở chỗ thử mô đun. Cân nhắc thảo luận các thay đổi tại trang thảo luận trước khi áp dụng sửa đổi. |
| Mô đun này phụ thuộc vào các mô đun sau: |
Mô-đun này được thiết kế để phục vụ như một back end cho {{R from alternative scientific name}}, {{R to scientific name}}, {{R from scientific name}}, {{R to monotypic taxon}} và {{R from monotypic taxon}}.
Các tham số bản mẫu và các thể loại công nhận được đặt trong Module:Science redirect/conf.
Sử dụng
{{#invoke:Science redirect|R|tên bản mẫu không chứa 'R'}}
Ví dụ, đối với {{R to scientific name}}, ta dán mã {{#invoke:Science redirect|R|to scientific name}} để cho ra:
- Đến danh pháp khoa học của một sinh vật: Trang này là trang đổi hướng từ một tên thông dụng đến danh pháp khoa học của một sinh vật (hoặc nhóm sinh vật).
Thêm thắt hoặc sửa đổi các bản mẫu được hỗ trợ
The template parameters and recognized categories are set in Module:Science redirect/conf. Instructions on how to add data are in the comments of that file.
For debugging, add parameter |debug=true, e.g. {{#invoke:Science redirect|R|to scientific name|debug=true}} produces:
{{Redirect template
| name = Đến danh pháp khoa học của một sinh vật
| from = một tên thông dụng
| main category = Trang đổi hướng đến tên khoa học
| printworthy = yes
| to = danh pháp khoa học của một sinh vật (hoặc nhóm sinh vật)
}}
Các thể loại theo dõi
Science redirects ( 0 )
- Thể loại:Redirects from alternative scientific names ( 0 )
- Thể loại:Redirects to scientific names ( 0 )
- Thể loại:Redirects from scientific names ( 0 )
- Thể loại:Redirects to monotypic taxa ( 0 )
- Thể loại:Redirects from monotypic taxa ( 0 )
Lỗi kịch bản: Hàm “list” không tồn tại.
Các tham số không hợp lệ
- Thể loại:Redirects from alternative scientific names using unknown values for parameter 1 ( 0 )
- Thể loại:Redirects to scientific names using unknown values for parameter 1 ( 0 )
- Thể loại:Redirects from scientific names using unknown values for parameter 1 ( 0 )
- Thể loại:Redirects to monotypic taxa using unknown values for parameter 1 ( 0 )
- Thể loại:Redirects from monotypic taxa using unknown values for parameter 1 ( 0 )
local conf = require( "Module:Science redirect/conf" )local p = {}function p.R(frame) local template = mw.ustring.gsub(frame.args[1], ' ', '_') if conf.templates[template] then return p._main(frame, conf.templates[template].name, conf.templates[template].from, conf.templates[template].to, conf.templates[template].category, conf.templates[template].info, conf.templates[template].removeA) elseif template then return '<span class="error">Bản mẫu '..template..'không hợp lệ.</span>\n' else return '<span class="error">Không có bản mẫu nào được định rõ</span>\n' endendfunction p._main(frame, name, from, to, category, info, removeA) --initialize variables local args = frame:getParent().args local singleNoun, pluralNoun = '', '' local outStr = '' --Check for known parameter 1 local cat = mw.ustring.match(mw.ustring.lower(args[1] or 'none'), '^(.-)s?$') if conf.cats[cat] then singleNoun, pluralNoun = conf.cats[cat][1], conf.cats[cat][2] else singleNoun, pluralNoun = 'an organism' outStr = '[[Thể loại:Trang đổi hướng '..category..' sử dụng giá trị không rõ cho tham số 1]]' end --strip article from singleNoun if removeA is true if removeA == true then if singleNoun == 'an organism' then singleNoun = '' else singleNoun = (mw.ustring.match(singleNoun, '^an? (.*)$') or singleNoun) end end --support alternative indications for printworthy if args[2] == 'unprintworthy' or args['unprintworthy'] == 'true' then args['printworthy'] = 'no' end --build template arguments local main_category = 'Trang đổi hướng '..category if pluralNoun then main_category = main_category..' của '..pluralNoun end local outArgs = { name = mw.ustring.gsub(name, '$1', singleNoun), from = mw.ustring.gsub(mw.ustring.gsub(from, '$1', singleNoun), '$2', (pluralNoun or 'sinh vật')), to = mw.ustring.gsub(mw.ustring.gsub(to, '$1', singleNoun), '$2', (pluralNoun or 'sinh vật')), ['main category'] = main_category, printworthy = (args['printworthy'] or 'yes'), info = info, } --build output string if frame.args['debug'] == 'true' then local debugStr = '{{Redirect template<br />\n' for k,v in pairs( outArgs ) do debugStr = debugStr..'| '..k..' = '..v..'<br />\n' end outStr = debugStr..'}}'..frame:extensionTag{ name = 'nowiki', content = outStr} else outStr = frame:expandTemplate{ title = 'Redirect template', args = outArgs }..outStr end return outStrendreturn p- Mô đun trong giai đoạn beta
- Bản mẫu cho trang đổi hướng liên quan đến khoa học
- Mô đun thêm một thể loại theo dõi