I noticed there is no differentiation between traditional and simplified Chinese. Is it not necessary to specify zh-hans or zh-hant when I am targeting China and Taiwan? We are using subdomains rather than ccTLDs. I did some digging, but couldn't find a definite answer. From my perspective, my second example seems correct.

According to this wiki article, these are the ISO639-1 codes (http://simple.wikipedia.org/wiki/Chinese#ISO_639_codes), which I would assume would make the code look like this:

However, this wiki article on Language Localization (http://en.wikipedia.org/wiki/Language_localisation#Language_tags_and_codes) seems to imply that tw implies traditional and cn implies simplified, which would make your tool correct.

"For language script variations the proper script is derived from the country. For example, when using zh-TW for users zh-TW, the language script is automatically derived (in this example: Chinese-Traditional). You can also specify the script itself explicitly using ISO 15924, like this:

zh-Hant: Chinese (Traditional)

zh-Hans: Chinese (Simplified)

Alternatively, you can also specify a combination of script and region—for example, use zh-Hans-TW to specify Chinese (Simplified) for Taiwanese users."