模块:String:修订间差异
imported>Great Brightstar |
imported>Great Brightstar 翻译 |
||
| 第87行: | 第87行: | ||
if i > len or j > len or i < 1 or j < 1 then | if i > len or j > len or i < 1 or j < 1 then | ||
return str._error( ' | return str._error( '截取字符串索引脱离区间' ); | ||
end | end | ||
if j < i then | if j < i then | ||
return str._error( ' | return str._error( '截取字符串指示脱离顺序' ); | ||
end | end | ||
| 第158行: | 第158行: | ||
if s == '' then | if s == '' then | ||
return str._error( ' | return str._error( '目标字符串是空的' ); | ||
end | end | ||
if pattern == '' then | if pattern == '' then | ||
return str._error( ' | return str._error( '模式字符串是空的' ); | ||
end | end | ||
if math.abs(start) < 1 or math.abs(start) > mw.ustring.len( s ) then | if math.abs(start) < 1 or math.abs(start) > mw.ustring.len( s ) then | ||
return str._error( ' | return str._error( '要求的起始点脱离区间' ); | ||
end | end | ||
if match_index == 0 then | if match_index == 0 then | ||
return str._error( ' | return str._error( '匹配索引脱离区间' ); | ||
end | end | ||
if plain_flag then | if plain_flag then | ||
| 第207行: | 第207行: | ||
if result == nil then | if result == nil then | ||
if nomatch == nil then | if nomatch == nil then | ||
return str._error( ' | return str._error( '找不到匹配' ); | ||
else | else | ||
return nomatch; | return nomatch; | ||
| 第247行: | 第247行: | ||
if pos == 0 or math.abs(pos) > mw.ustring.len( target_str ) then | if pos == 0 or math.abs(pos) > mw.ustring.len( target_str ) then | ||
return str._error( ' | return str._error( '字符串索引脱离区间' ); | ||
end | end | ||
| 第423行: | 第423行: | ||
function str._error( error_str ) | function str._error( error_str ) | ||
local frame = mw.getCurrentFrame(); | local frame = mw.getCurrentFrame(); | ||
local error_category = frame.args.error_category or ' | local error_category = frame.args.error_category or '字符串模块报告的错误'; | ||
local ignore_errors = frame.args.ignore_errors or false; | local ignore_errors = frame.args.ignore_errors or false; | ||
local no_category = frame.args.no_category or false; | local no_category = frame.args.no_category or false; | ||
| 第431行: | 第431行: | ||
end | end | ||
local error_str = '<strong class="error"> | local error_str = '<strong class="error">字符串模块出错:' .. error_str .. '</strong>'; | ||
if error_category ~= '' and not str._getBoolean( no_category ) then | if error_category ~= '' and not str._getBoolean( no_category ) then | ||
error_str = '[[Category:' .. error_category .. ']]' .. error_str; | error_str = '[[Category:' .. error_category .. ']]' .. error_str; | ||
| 第456行: | 第456行: | ||
boolean_value = boolean_str; | boolean_value = boolean_str; | ||
else | else | ||
error( ' | error( '布尔值找不到' ); | ||
end | end | ||
return boolean_value | return boolean_value | ||