Sửa đổi Mô đun:Citation
Chú ý: Bạn chưa đăng nhập và địa chỉ IP của bạn sẽ hiển thị công khai khi lưu các sửa đổi.
Bạn có thể tham gia như người biên soạn chuyên nghiệp và lâu dài ở Bách khoa Toàn thư Việt Nam, bằng cách đăng ký và đăng nhập - IP của bạn sẽ không bị công khai và có thêm nhiều lợi ích khác.
Các sửa đổi có thể được lùi lại. Xin hãy kiểm tra phần so sánh bên dưới để xác nhận lại những gì bạn muốn làm, sau đó lưu thay đổi ở dưới để hoàn tất việc lùi lại sửa đổi.
Bản hiện tại | Nội dung bạn nhập | ||
Dòng 10: | Dòng 10: | ||
strip_apostrophe_markup; | strip_apostrophe_markup; | ||
− | local z ={}; | + | local z ={}; -- tables in Module:Citation/CS1/Utilities |
local extract_ids, extract_id_access_levels, build_id_list, is_embargoed; -- functions in Module:Citation/Identifiers | local extract_ids, extract_id_access_levels, build_id_list, is_embargoed; -- functions in Module:Citation/Identifiers | ||
Dòng 19: | Dòng 19: | ||
local whitelist = {}; -- table of tables listing valid template parameter names; defined in Module:Citation/Whitelist | local whitelist = {}; -- table of tables listing valid template parameter names; defined in Module:Citation/Whitelist | ||
+ | ---Định dạng ngày tháng | ||
+ | local function vi_formatdate(rawDate, dayPrefix) | ||
+ | local formatStr = 'j F "năm" Y' | ||
+ | if dayPrefix then formatStr = '"ngày" ' .. formatStr end | ||
+ | -- Năm | ||
+ | if tonumber(rawDate) then | ||
+ | formatStr = 'Y' | ||
+ | -- Năm tháng | ||
+ | elseif mw.ustring.match(rawDate, "^[Tt]háng %d%d?,? %d%d%d%d$") or | ||
+ | mw.ustring.match(rawDate, "^[Tt]háng %d%d?,? năm %d%d%d%d$") or | ||
+ | mw.ustring.match(rawDate, "^[Tt]háng %a+,? năm %d%d%d%d$") or | ||
+ | mw.ustring.match(rawDate, "^%a+%.?,? %d%d%d%d$") or | ||
+ | mw.ustring.match(rawDate, "^%d%d%d%d%-%d%d$") then | ||
+ | rawDate = mw.ustring.gsub(rawDate, ",", "") | ||
+ | formatStr = 'F "năm" Y' | ||
+ | end | ||
+ | local good, formattedDate = pcall(contentLanguage.formatDate, contentLanguage, formatStr, rawDate) | ||
+ | if good then return formattedDate else return rawDate end | ||
+ | end | ||
+ | function z._vi_formatdate(frame) | ||
+ | return vi_formatdate(frame.args[1], frame.args[2]) | ||
+ | end | ||
+ | |||
+ | ---Cho ra tên tiếng Việt của ngôn ngữ có mã được đưa vào. Nếu một tên ngôn ngữ được đưa vào, tên đó được cho ra. | ||
+ | local function vi_formatlanguage(rawLanguage) | ||
+ | local languageName = mw.language.fetchLanguageName(rawLanguage, contentLanguage:getCode()) | ||
+ | if not languageName or #languageName < 1 then return rawLanguage end | ||
+ | return (mw.ustring.gsub(languageName, "^[Tt]iếng ", "tiếng ", 1)) | ||
+ | end | ||
+ | function z._vi_formatlanguage(frame) | ||
+ | return vi_formatlanguage(frame.args[1]) | ||
+ | end | ||
+ | |||
+ | ---Định dạng số ấn bản. | ||
+ | local function vi_formatedition(rawEdition) | ||
+ | if tonumber(rawEdition) then return rawEdition end | ||
+ | local num = mw.ustring.match(rawEdition, "(%d+)th") or | ||
+ | mw.ustring.match(rawEdition, "(%d+)st") or | ||
+ | mw.ustring.match(rawEdition, "(%d+)nd") or | ||
+ | mw.ustring.match(rawEdition, "(%d+)rd") | ||
+ | return num or "" | ||
+ | end | ||
+ | function z._vi_formatedition(frame) | ||
+ | return vi_formatedition(frame.args[1]) | ||
+ | end | ||
--[[--------------------------< P A G E S C O P E V A R I A B L E S >-------------------------------------- | --[[--------------------------< P A G E S C O P E V A R I A B L E S >-------------------------------------- | ||
Dòng 1.391: | Dòng 1.436: | ||
When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned | When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned | ||
− | that will cause list_people() to add the static 'et al.' text from Module:Citation/Configuration. This keeps 'et al.' out of the | + | that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration. This keeps 'et al.' out of the |
template's metadata. When this occurs, the page is added to a maintenance category. | template's metadata. When this occurs, the page is added to a maintenance category. | ||
Dòng 1.647: | Dòng 1.692: | ||
local function set_style (mode, ps, ref, cite_class) | local function set_style (mode, ps, ref, cite_class) | ||
local sep; | local sep; | ||
− | if 'cs2' == mode then | + | if 'cs2' == mode then -- if this template is to be rendered in CS2 (citation) style |
sep, ps, ref = set_cs2_style (ps, ref); | sep, ps, ref = set_cs2_style (ps, ref); | ||
− | elseif 'cs1' == mode then | + | elseif 'cs1' == mode then -- if this template is to be rendered in CS1 (cite xxx) style |
sep, ps = set_cs1_style (ps); | sep, ps = set_cs1_style (ps); | ||
− | else | + | else -- anything but cs1 or cs2 |
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass | sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass | ||
end | end | ||
Dòng 2.015: | Dòng 2.060: | ||
elseif (4 < mw.ustring.len(volume)) then -- not all digits or roman numerals and longer than 4 characters | elseif (4 < mw.ustring.len(volume)) then -- not all digits or roman numerals and longer than 4 characters | ||
vol = substitute (cfg.messages['j-vol'], {sepc, volume}); -- not bold | vol = substitute (cfg.messages['j-vol'], {sepc, volume}); -- not bold | ||
− | + | add_prop_cat ('long_vol'); | |
else -- four or less characters | else -- four or less characters | ||
vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)}); -- bold | vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)}); -- bold | ||
Dòng 2.562: | Dòng 2.607: | ||
end | end | ||
− | local sepc; | + | local sepc; -- separator between citation elements for CS1 a period, for CS2, a comma |
local PostScript; | local PostScript; | ||
local Ref = A['Ref']; | local Ref = A['Ref']; | ||
Dòng 2.841: | Dòng 2.886: | ||
we get the date used in the metadata. | we get the date used in the metadata. | ||
− | Date validation supporting code is in Module:Citation/Date_validation | + | Date validation supporting code is in Module:Citation/CS1/Date_validation |
]] | ]] | ||
do -- create defined block to contain local variables error_message, date_parameters_list, mismatch | do -- create defined block to contain local variables error_message, date_parameters_list, mismatch | ||
Dòng 3.831: | Dòng 3.876: | ||
metadata.set_selected_modules (cfg, utilities); -- so that functions in COinS can see the selected cfg tables and selected Utilities module | metadata.set_selected_modules (cfg, utilities); -- so that functions in COinS can see the selected cfg tables and selected Utilities module | ||
− | dates = validation.dates; | + | dates = validation.dates; -- imported functions from Module:Citation/CS1/Date validation |
year_date_check = validation.year_date_check; | year_date_check = validation.year_date_check; | ||
reformat_dates = validation.reformat_dates; | reformat_dates = validation.reformat_dates; | ||
Dòng 3.837: | Dòng 3.882: | ||
date_name_xlate = validation.date_name_xlate; | date_name_xlate = validation.date_name_xlate; | ||
− | is_set = utilities.is_set; | + | is_set = utilities.is_set; -- imported functions from Module:Citation/CS1/Utilities |
in_array = utilities.in_array; | in_array = utilities.in_array; | ||
substitute = utilities.substitute; | substitute = utilities.substitute; | ||
Dòng 3.850: | Dòng 3.895: | ||
strip_apostrophe_markup = utilities.strip_apostrophe_markup; | strip_apostrophe_markup = utilities.strip_apostrophe_markup; | ||
− | z = utilities.z; | + | z = utilities.z; -- table of error and category tables in Module:Citation/CS1/Utilities |
− | extract_ids = identifiers.extract_ids; | + | extract_ids = identifiers.extract_ids; -- imported functions from Module:Citation/CS1/Identifiers |
build_id_list = identifiers.build_id_list; | build_id_list = identifiers.build_id_list; | ||
is_embargoed = identifiers.is_embargoed; | is_embargoed = identifiers.is_embargoed; | ||
extract_id_access_levels = identifiers.extract_id_access_levels; | extract_id_access_levels = identifiers.extract_id_access_levels; | ||
− | make_coins_title = metadata.make_coins_title; | + | make_coins_title = metadata.make_coins_title; -- imported functions from Module:Citation/CS1/COinS |
get_coins_pages = metadata.get_coins_pages; | get_coins_pages = metadata.get_coins_pages; | ||
COinS = metadata.COinS; | COinS = metadata.COinS; | ||
− | local args = {}; | + | local args = {}; -- table where we store all of the template's arguments |
− | local suggestions = {}; | + | local suggestions = {}; -- table where we store suggestions if we need to loadData them |
local error_text, error_state; | local error_text, error_state; | ||