How to set the language according to URL

Our website has two URL, when access the www.xx.com , it default access the english website, when customers access www.xx.cn , it default display Chinese, how to achieve?

Is your website based on neos or a standalone flow application?

If the latter:
You could just use a base controller that sets the current locale depending on the current requests host like so:

abstract class AbstractBaseController extends \TYPO3\Flow\Mvc\Controller\ActionController {

	/**
	 * @var \TYPO3\Flow\I18n\Service
	 * @Flow\Inject
	 */
	protected $i18nService;

	protected initializeAction() {
		if ($this->request->getHttpRequest()->getUri()->getHost() === 'www.xxx.cn') {
			$this->i18nService->getConfiguration()->setCurrentLocale(new Locale('cn'));
		}
		...
	}

}

Then just have all your application controllers extend that base controller.

I don’t know how to " have all your application controllers extend that base controller."?

Hm, that might become a problem. Maybe this helps: http://flowframework.readthedocs.org/en/stable/TheDefinitiveGuide/PartI/Object-OrientedProgramming.html

And/or go and read http://php.net/manual/en/language.oop5.php