Module:etymology languages/documentation

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module provides etymology-only languages. It has a separate data module, Module:etymology languages/data, which stores information for etymology-only language codes.

It exports only three functions that behave similarly to the ones in Module:languages: getByCode, getByCanonicalName, and makeObject().

However, do not use these functions directly under normal circumstances. Instead, use getByCode(code, ..., true), getByCanonicalName(name, ..., true) in Module:languages, where the third parameter indicates that etymology-only languages can be returned, and if the second parameter is non-nil, an error is thrown if the specified code or name isn't recognized.

Etymology-only language objects returned by getByCode(), getByCanonicalName(), or makeObject() or by the corresponding methods in Module:languages function, for all intents and purposes, exactly like full Language objects. In particular, they support all the same methods, meaning they can for the most part be used as drop-in replacements for full Language objects. The only significant differences are:

  1. Etymology-only languages are nested underneath a full language (or, in rare cases, a full family), i.e. their parent (or parent's parent, etc.) is a full language (or family). This can be returned using getFull(). If you need the code or canonical name of the full language or family under which a given etymology-only language is nested, it is more efficient to use getFullCode() or getFullName() rather than calling getFull():getCode() or similar. (All three methods getFull(), getFullCode() and getFullName() exist on full languages, but the first one just returns back the same object and the others are equivalent to calling getCode() and getName(), respectively.)
  2. The getParent() method on an etymology-only language returns the direct containment parent (a full language, etymology-only language or family) of the etymology-only language. When called on full languages, it returns {nil}.
  3. Some modules that accept language objects are not prepared to accept etymology-only language objects. This particularly relates to categories, because currently only full languages can form poscatboiler or topic categories beginning with a language name or code. Modules that accept etymology-only language objects must be prepared to call getFull() or similar if they construct their own category names.