Locale*
Locale::CreateLocale(const char* l, const char* c, const char* v)
{
	ListIter<Locale> iter = locales;
	while (++iter) {
		Locale* loc = iter.value();
		if (!_stricmp(l, loc->GetLanguage())) {
			if (c && *c) {
				if (!_stricmp(c, loc->GetCountry())) {
					if (v && *v) {
						if (!_stricmp(v, loc->GetVariant())) {
							return loc;
						}
					}
					else {
						return loc;
					}
				}
			}
			else {
				return loc;
			}
		}
	}

	if (l[0]) {
		if (c[0]) {
			if (v[0]) {
				return new(__FILE__,__LINE__) Locale(l, c, v);
			}
			return new(__FILE__,__LINE__) Locale(l, c);
		}
		return new(__FILE__,__LINE__) Locale(l);
	}

	return 0;
}