Module:User:Mr. Stradivarius/Latvian declension/doc

This module creates templates to help with Latvian declensions.

The data page
To use this module, you need to make a data sub-module for each template. This data module can have any name, but you should choose something meaningful. For example, to make a template for month declensions, you could make a new module at the page "/months".

Data modules should have the following format:

Keys like "foo" and "bar" should be lower case. The "n", "g", "d", "a", "i" and "l" keys should also be lower case. Also, if you want to use numbers instead of the "foo" or "bar" keys, then they should be written without speech marks (like [7], not ["7"]).

For our months data page, we might write the following:

The template
You can make any page into a template for use with this module. But it's probably best to choose a page in the template namespace that has a meaningful name. You should create your template with the following code:

&#123;&#123;#invoke:&#124;data module subpage name&#125;&#125;

For our months example, let's say we chose the template name "Template:Latvian month". We would create the template page with the following code:

&#123;&#123;#invoke:&#124;months&#125;&#125;

Note: you can't use the module directly from #invoke; it must be used from a template, otherwise the parameters will not be detected.

Using the template
The templates are used like this:

&#123;&#123;template name&#124;word code&#124;declension code&#125;&#125;

The word codes are the ones you defined in the data module, like "foo" and "bar". When using the template itself, these can be either upper case, lower case, or a mixture. The declension code can be any of "n", "g", "d", "a", "i" and "l" (and "ģ" is an alias for "g"). These can also be upper case. The module will look in the data submodule for a match for these two keys, and if it finds one, it will return it. If not, it will return the text "Invalid".

So for our months example, we would use the following syntax:

&#123;&#123;Latvian month&#124;word code&#124;declension code&#125;&#125;

Here are some examples of how it would work:
 * &rarr; Janvāris
 * &rarr; Janvāra
 * &rarr; ar Februāri