An experiment with creating a Language
object to which only a specified number of the methods in Module:languages are added. This may be less memory-intensive than creating a Language
object with every function (many of which are never used in the module in which the object is generated), as is currently done.
Another issue is that the data in the Language object can be gotten by indexing it – enLanguageObject._rawData.canonicalName -- "English"
, for example – but this is discouraged. It can even be modified: enLanguageObject._rawData.canonicalName = "German" -- now enLanguageObject:getCanonicalName() == "German"
. Storing the data in the metatable and preventing access to it would make both of these impossible.
{{#invoke:User:Erutuon/languages/templates|getByCode|en|getCanonicalName}}
{{#invoke:User:Erutuon/languages/templates|getByCode|en|getFamily}}