Jocys.com Globalization Resources
Introduction
There are some MUST HAVE resources for proper multilanguage development.
I highly recommend to use ISO (International Organizations for
Standardization) as primary source of information (because this is the only way
to go for high quality products and compatibility). Please remmeber that ISO
usualy only manages standards. Behind each ISO standard there are companies
which supplies databases and updates to commercial users. Internet is also good source of information so I've colected globalization data from various resources and placed into 6 tables. If you have some suggestions
then please contact me by email: Evaldas Jocys <evaldas@jocys.com>
Data for these tables are required to produce full multilingual support:
- Languages - information about all languages.
- Cultures - information about all cultures (Language + Country).
- Encodings - information about all encodings.
- Ranges - can help to get customer's culture by IP.
- Currencies - business information about each country.
- Currencies by Country- currencies used in country.
Requirements
- Microsoft SQL Server 2005
- Microsoft .NET Framework 3.5
Installation
- Download ZIP file specified above.
- Extract ZIP contents into temp folder.
- Navigate to WebApp\Projects\Globalization\SQL\ folder.
- Open Globalization-SqlDataImport.bat file
- Go to line 5 and update srv value with your SQL Server name
- Go to line 6 and update cat value with your Database name
- Save and close Globalization-SqlDataImport.bat file.
- Execute Globalization-SqlDataImport.bat to recreate [Globalization_*] tables and to import data into them.
Note: Import script will ask for database login and password. Hit [Enter] key if you want to use trusted connection.
Using The Code
Archive contains .zip\Engine folder with LINQ to SQL classes and some
methods. You can extract content of this folder into your C# project.
For example Engine\Globalization\Ranges.cs file contains two functions...
/// <summary>
/// Convert IP Address string to long number.
/// </summary>
/// <param name="ipString">IP Address string: 64.233.167.99</param>
/// <returns>Numeric representation of IP Address</returns>
public long IpToInt(string ipString)
{
System.Net.IPAddress address = System.Net.IPAddress.Parse(ipString);
return (long)BitConverter.ToUInt32(address.GetAddressBytes().Reverse().ToArray(), 0);
}
/// <summary>
/// Get Alpha 3 Code of country by IP Address.
/// </summary>
/// <param name="ipString">IP Address string: 64.233.167.99</param>
/// <returns>ISO 3166-1 Alpha-3 Code. For example: LTU</returns>
public string GetCountryByIp(string ipString)
{
Data.GlobalizationDataContext db = new Data.GlobalizationDataContext();
long ip = IpToInt(ipString);
Data.Range range = db.Ranges.SingleOrDefault(item => item.RangeStart <= ip && ip <= item.RangeEnd);
return (range == null) ? string.Empty : range.CountryA3;
}
So you can get country code of visitor and redirect him to specific web page:
// Get visitor's IP Address.
string ipString = Request.ServerVariables["REMOTE_ADDR"];
// Get ISO 3166-1 Alpha-3 Code of Country by IP Address.
string countryA3 = Engine.AppContext.Current.Globalization.Ranges.GetCountryByIp(ipString);
// Define default language of user: Lithuanian if user came from Lithuania or English for all other countries.
string language = (countryA3 == "LTU") ? "ltu" : "enu";
// Redirect user to specific page.
System.Web.HttpContext.Current.Response.Redirect("Default_" + language + ".htm", true);
Countries
ISO 3166 - Codes for the representation of names of countries and their subdivisions:
http://www.iso.org/iso/search.htm?qt=3166&published=on&active_tab=standards
ISO 3166-1 (published)
- Part 1: Country codes (CHF 154.00)
http://www.iso.org/iso/country_codes/iso_3166_databases.htm
ISO 3166-2 (published)
- Part 2: Country subdivision code (CHF 202.00)
http://www.iso.org/iso/country_codes/iso_3166_databases.htm
Alternative/Free Data Source:
http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm
Cultures
Cultures also called "Language Identifiers" (RFC 3066). Culture represents information
about people who speaks one language in one region. Culture code represents combination
of language and country/region.
ISO 639 - Codes for the representation of names of languages
http://www.iso.org/iso/search.htm?qt=639&published=on&active_tab=standards
ISO 639-5:2008 (published) -
Language Families and Groups - Part 2: Alpha-3 code (CHF 102.00)
http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=39536
Alternative/Free Data Source: Microsoft Windows 2003 Server Internal Resources.
Currencies
Provides: Latest information about currency info in each country with all latest
exchange rates.
ISO 4217:2001 - Codes for the representation of currencies and funds (CHF
126.00)
http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=34749
Alternative/Free Data Source: WebserviceX.NET -
http://www.webservicex.net/country.asmx
Currencies by Country
Provides: Latest information about currency info in each country.
ISO 4217:2001 - Codes for the representation of currencies and funds (CHF
126.00)
http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=34749
Alternative/Free Data Source: WebserviceX.NET -
http://www.webservicex.net/country.asmx
Encodings
Alternative/Free Data Source: Microsoft Windows 2003 Server Internal Resources
Languages
ISO 639 - Codes for the representation of names of languages
http://www.iso.org/iso/search.htm?qt=639&published=on&active_tab=standards
ISO 639-1:2002 (published) -
Language Codes - Part 1: Alpha-2 code (CHF 132.00)
http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=22109
ISO 639-3:2007 (published) - Language
Codes - Part 2: Alpha-3 code (CHF 72.00)
http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=39534
Alternative/Free Data Source:
If you have good free source please send me a link and I will post it here.
Ranges
This database will help automatically detect user country and then language by IP
or by domain of email. Culture can be detected by using email encoding.
IP To Country Database
http://ip-to-country.webhosting.info/
http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip
Regions
Provides: Latest information about World Regions from United Nations.
M29 - Standard country or area codes for statistical use.
https://unstats.un.org/unsd/methodology/m49/overview