Diplomatic templates

If you are reading this, you probably found this link at the talk page of one of the templates. If you see any bugs, have questions, feel free to raise a question on the talk page of this page, or on my main User_talk page.

Example Templates created using this script

How can I help?

Embassy naming convention

Wikipedia:Break all rules applies here as well. Below are some case examples of different naming conventions

The script

Locally I have ruby installed (every Mac machine has it by default), which I use to open multiple browser windows at a time, by calling ruby wiki.rb 0..4

the first 5 Template previews and their associated talk pages. The real magic happens inside the templates that are preloaded. You can see the three preloaded templates I created:

  1. For talk pages User:Shushugah/IRTalk
  2. For Diplomatic missions in Country X User:Shushugah/Diplomatic_Missions_In_X
  3. For Diplomatic missions of Country X User:Shushugah/Diplomatic_Missions_Of_X
# named wiki.rb
COUNTRIES = [
    'Afghanistan',
    'Albania',
    'Algeria',
    'Angola',
    'Antigua and Barbuda',
    'Argentina',
    'Armenia',
    'Australia',
    'Austria',
    'Azerbaijan',
    'the Bahamas',
    'Bahrain',
    'Bangladesh',
    'Barbados',
    'Belarus',
    'Belgium',
    'Belize',
    'Benin',
    'Bolivia',
    'Bosnia and Herzegovina',
    'Botswana',
    'Brazil',
    'Brunei',
    'Bulgaria',
    'Burkina Faso',
    'Burundi',
    'Cambodia',
    'Cameroon',
    'Canada',
    'the Central African Republic',
    'Chad',
    'Chile',
    'China',
    'Taiwan',
    'Colombia',
    'the Democratic Republic of the Congo',
    'the Republic of the Congo',
    'Costa Rica',
    'Croatia',
    'Cuba',
    'Cyprus',
    'the Czech Republic',
    'Denmark',
    'Djibouti',
    'the Dominican Republic',
    'East Timor',
    'Ecuador',
    'Egypt',
    'El Salvador',
    'Equatorial Guinea',
    'Eritrea',
    'Estonia',
    'Ethiopia',
    'Finland',
    'France',
    'Gabon',
    'Georgia',
    'Germany',
    'Ghana',
    'Greece',
    'Grenada',
    'Guatemala',
    'Guinea',
    'Guinea-Bissau',
    'Guyana',
    'Holy See',
    'Honduras',
    'Hong Kong',
    'Hungary',
    'Iceland',
    'India',
    'Indonesia',
    'Iran',
    'Iraq',
    'Ireland',
    'Israel',
    'Italy',
    'Ivory Coast',
    'Jamaica',
    'Japan',
    'Jordan',
    'Kazakhstan',
    'Kenya',
    'Kosovo',
    'Kuwait',
    'Kyrgyzstan',
    'Laos',
    'Latvia',
    'Lebanon',
    'Lesotho',
    'Liberia',
    'Libya',
    'Lithuania',
    'Luxembourg',
    'Madagascar',
    'Malawi',
    'Malaysia',
    'Mali',
    'Malta',
    'Mauritania',
    'Mauritius',
    'Mexico',
    'Moldova',
    'Mongolia',
    'Morocco',
    'Mozambique',
    'Myanmar',
    'Namibia',
    'Nepal',
    'the Netherlands',
    'New Zealand',
    'Nicaragua',
    'Niger',
    'Nigeria',
    'North Korea',
    'North Macedonia',
    'Norway',
    'Oman',
    'Pakistan',
    'the State of Palestine',
    'Panama',
    'Papua New Guinea',
    'Paraguay',
    'Peru',
    'the Philippines',
    'Poland',
    'Portugal',
    'Qatar',
    'Romania',
    'Russia',
    'Rwanda',
    'Saudi Arabia',
    'Senegal',
    'Serbia',
    'Seychelles',
    'Sierra Leone',
    'Singapore',
    'Slovakia',
    'Slovenia',
    'Somalia',
    'South Africa',
    'South Korea',
    'South Sudan',
    'Spain',
    'Sri Lanka',
    'Sudan',
    'Suriname',
    'Sweden',
    'Switzerland',
    'Syria',
    'Tajikistan',
    'Tanzania',
    'Thailand',
    'Togo',
    'Trinidad and Tobago',
    'Tunisia',
    'Turkey',
    'Turkmenistan',
    'Uganda',
    'Ukraine',
    'the United Arab Emirates',
    'the United Kingdom',
    'the United States',
    'Uruguay',
    'Uzbekistan',
    'Venezuela',
    'Vietnam',
    'Yemen',
    'Zambia',
    'Zimbabwe'
    ]


def template_talk_link(country)
  country = country.gsub('_', '%20')
  "https://en.wikipedia.org/wiki/Template_talk:Diplomatic_missions_of_#{country}?veaction=editsource&redlink=1&preload=User%3AShushugah%2FIRTalk&preloadparams[]=#{country}"
end

def template_link(country)
  country = country.gsub('_', '%20')
  "https://en.wikipedia.org/wiki/Template:Diplomatic_missions_of_#{country}?veaction=editsource&redlink=1&preload=User%3AShushugah%2FDiplomatic_Missions_Of_X&preloadparams[]=#{country}"
end

Range.new(*ARGV[0].split('..').map(&:to_i)).each do |index|
  country = COUNTRIES[index].split.join('_')
  system("open", template_link(country))
  system("open", template_talk_link(country))
end

See also