How can I convert state codes or country codes to the name

For province / state codes refer to the state_name template function
For country codes use the country_name template function