Homepage
Games
News
News βΎ
All
Transfers
Drama
Business
Sponsors
Mergers
Investors
Hires
Companies
More
People
Tournaments
Brands
Brands βΎ
Companies
Organizations
Sponsors
Other
Locations
Search
Editing
Module:Localisation
From TwogPedia
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local Class = require('Module:Class') local Localisation = {} local String = require('Module:StringUtils') local Logic = require('Module:Logic') function Localisation.getCountryName(country, noentry) local data = mw.loadData('Module:Localisation/data/country') -- clean the entered country value country = Localisation._cleanCountry(country) -- First try to look it up local countryname = data[country] -- Return message if none is found if countryname == nil then mw.log('No country found in Module:Localisation/data/country: ' .. country) -- set category unless second argument is set if noentry ~= '' then countryname = '' else countryname = mw.getCurrentFrame() :expandTemplate{title = 'Flag/invalidcountry', args = {country}} end end return countryname end function Localisation.getLocalisation(options, country) --in case no options are entered the country is the first var --so we need to adjust for that --in that case it will be a string so we catch it via this --it also catches cases where country and options are switched if type(options) == 'string' then local tempForSwitch = country country = options options = tempForSwitch end --avoid indexing nil options = options or {} local displayNoError = Logic.readBool(options.displayNoError) local shouldReturnSimpleError = Logic.readBool(options.shouldReturnSimpleError) local dataModuleName = 'Module:Localisation/data/localised' local data = mw.loadData(dataModuleName) -- clean the entered country value country = Localisation._cleanCountry(country) -- First try to look it up local localised = data[country] -- Return message if none is found if localised == nil then mw.log('No country found in ' .. dataModuleName .. ': ' .. country) -- set category unless second argument is set if displayNoError then localised = '' elseif shouldReturnSimpleError then localised = 'error' else localised = 'Unknown country "[[lpcommons:' .. dataModuleName .. '|' .. country .. ']][[Category:Pages with unknown countries]]' end end return localised end function Localisation._cleanCountry(country) if String.isEmpty(country) then country = 'nocountry' end -- Remove whitespace country = mw.text.trim(country) country = mw.text.unstripNoWiki(country) country = string.upper(country) return country end return Class.export(Localisation, {frameOnly = true})
Summary:
Please note that all contributions to TwogPedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TwogPedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Localisation/doc
(
edit
)
No categories
Edit