Jump to content

Module:Sandbox/Gnosygnu

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 69.126.182.12 (talk) at 16:05, 24 February 2019 (Return both values). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
--This Module is for Lua experimentation. No other pages refer to it.

local p = {}

function p.siteinfo(frame)
  return mw.site.siteName .. '--' .. '(' .. mw.site.server .. ')'
end

function p.getEntity(frame)
  local v = mw.wikibase.getEntity();
  if v == nil then
  	return 'nil'
  else
  	return v.id
  end
end

--[[
Test with:
* Debug console
** Code:
:: =p.ustring_find({args={[1]='abab', [2]='b', [3]=3, [4]='true'}})
** Returns -> 4 (2nd b, not 1st b)
* https://en.wikipedia.org/wiki/Project:Sandbox
** Code:
:: {{#invoke:Sandbox/Gnosygnu|ustring_find|abab|b|3|true}}
** Returns -> 4 (2nd b, not 1st b)
--]]
function p.ustring_find(frame)
	local args = frame.args;
	local rv1, rv2 = mw.ustring.find(args[1], args[2], tonumber(args[3]), args[4] == 'true')
	return rv1 .. ';' .. rv2;
end

function p.test18(frame)
  return mw.language.fetchLanguageName(frame.args[1], 'en');	
--  return mw.language.fetchLanguageName(frame.args[1]);
end

return p