local p =
function p._addquotes(s) if s then if s:match(^(['"]).*%1$) or s:match(^‘.*’$) or s:match(^“.*”$) then -- If the string starts and ends with a quotemark (or starts and ends with an apostrophe), display it unchanged return s elseif s:match((["“”])) or s:match((['‘’])%s) or s:match(%s(['‘’])) or s:match(^(['‘’])) then -- Otherwise if the string contains any quotemarks at all, or any apostrophes that aren't in the middle of a word (excluding end-of-string, which may be a possessive) , display it unchanged and add a hidden category to flag that the template call is providing something more complex than a single literal translation return s .. "" else -- Otherwise (ie. if the string contains no quotemarks, and any apostrophes are in the middles of words), display it surrounded by additional quotemarks return "\"" .. s .. "\"" end else return "zzz" endend
function p.addquotes(frame) local s = (frame.args['s'] or frame.args[1]) or (frame:getParent.args['s'] or frame:getParent.args[1]) return p._addquotes(s)end
return p