This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
This module depends on the following other modules:
localCountryAdjectiveDemonym={}localCountryAdjectiveDemonymDataLoaded=falselocalcountryAdjectivesToNounsTable={}localcountryNounsToAdjectivesTable={}localcountryDemonymsToNounsTable={}localcountryNounsToDemonymsTable={}localcountriesPrefixedByTheTable={}functionCountryAdjectiveDemonymDoLoadData()countriesPrefixedByTheTable=mw.loadData('Module:CountryAdjectiveDemonym/The')countryNounsToAdjectivesTable=mw.loadData('Module:CountryAdjectiveDemonym/Adjectives')countryNounsToDemonymsTable=mw.loadData('Module:CountryAdjectiveDemonym/Demonyms')localmyNoun,myAdjective-- first, load the adjectives tableformyNoun,myAdjectiveinpairs(countryNounsToAdjectivesTable)docountryAdjectivesToNounsTable[myAdjective]=myNounend-- Now load the denomyms tablelocalmyDemonymformyNoun,myDemonyminpairs(countryNounsToDemonymsTable)docountryDemonymsToNounsTable[myDemonym]=myNounendCountryAdjectiveDemonymDataLoaded=truereturnend-- ############### Publicly accesible functions #######################-- if the country name is prefixed by "the" in running text,-- then return that prefix-- Otherwise just return an empty stringfunctionCountryAdjectiveDemonym.countryPrefixThe(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endif(countriesPrefixedByTheTable[s]==true)thenreturn"the "endreturn""endfunctionCountryAdjectiveDemonym.getCountryFromAdjective(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryAdjectivesToNounsTable[s]ifretval==nilthenifs=="Georgia (country)"thenreturnsendreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getCountryFromString(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalsimilarLongerNouns=mw.loadData('Module:CountryAdjectiveDemonym/LongerNouns')foradjective,nouninpairs(countryAdjectivesToNounsTable)doifstring.find(s,adjective)orstring.find(s,noun)thenforlongerNoun,nameToUseinpairs(similarLongerNouns)doifstring.find(s,longerNoun)thenreturnnameToUseendendreturnnounendendendfunctionCountryAdjectiveDemonym.getCountryFromDemonym(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryDemonymsToNounsTable[s]ifretval==nilthenretval=countryAdjectivesToNounsTable[s]endifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getAdjectiveFromCountry(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretval=countryNounsToAdjectivesTable[s]ifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.getDemonymFromCountry(frame)locals=frame.args[1]ifnotCountryAdjectiveDemonymDataLoadedthenCountryAdjectiveDemonymDoLoadData()endlocalretvalretval=countryNounsToDemonymsTable[s]ifretval==nilthenretval=countryNounsToAdjectivesTable[s]endifretval==nilthenreturn""endreturnretvalendfunctionCountryAdjectiveDemonym.stripThe(frame)locals=frame.args[1]ifs==nilthenreturn""endifmw.ustring.match(s,"^[T]he Gambia$")~=nilthenreturnsendlocalstripped=mw.ustring.gsub(s,"^[tT]he ","")returnstrippedendreturnCountryAdjectiveDemonym