Àdàkọ:Infobox former country/autocat

Lát'ọwọ́ Wikipedia, ìwé ìmọ̀ ọ̀fẹ́
Ìwé-alàyé àdàkọ

This subtemplate of {{Infobox country}} is used to automatically add categories to articles which transclude this template. It should not be used directly

Establishment dates

First the template tests to see if "Category:States and territories established in the {{{year_start}}}" exists. If so, it is added, otherwise, the template tests to see if "Category:States and territories established in {{{year_start}}}" exists. If so, it is added.

The reason for these two cases is to cases like "the 820s" or "the 18th century", before trying precise dates like "1820".

Disestablishment dates

First the template tests to see if "Category:{{{year_end}}} disestablishments" exists. If so, it is added, otherwise it checks to see if {{{year_end}}} is "1st century", "2nd century", ..., "23rd century". If so, it adds "Category:1st-century disestablishments", or "Category:2nd-century disestablishments", ...

The reason for the large switch statement is to add the missing hyphen, due to the category naming convention. However, we avoid the switch statement if the simple test works first.

This switch statement will be slow, especially if there are a large number of cases, so it may be advisable to just remove this and add the categories manually for these cases in the future.