-
-
Notifications
You must be signed in to change notification settings - Fork 448
fix geoip chi and zho not return chinese translation #2335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Good catch! Can we be sure that the mmdb always contains the zh-CN locale? It might be safer to check that and fallback properly if not. |
If it is confirmed that the simplified Chinese language code of mmdb is "zh-CN", would it be better to modify the variable code directly? Even if mmdb does not contain the "zh-CN" language, we can return "en" as a fallback. if (translator->GetLanguageInfo(langid, &code, NULL))
{
if (strcmp(code, "chi") == 0)
{
code = "zh-CN";
}
else if (strcmp(code, "zho") == 0)
{
code = "zh-TW";
}
for (size_t i = 0; i < mmdb.metadata.languages.count; i++)
{
if (strcmp(code, mmdb.metadata.languages.names[i]) == 0)
{
return code;
}
}
} |
sourcemod default mmdb version didnt contain zh-TW, so it will cause error. i not sure if mmdb is customizable. |
This does not cause an error, but returns the default language "en". See line 196: sourcemod/extensions/geoip/geoip_util.cpp Lines 186 to 197 in 20642a8
I checked GeoLite2-City_20250610 and it doesn't include zh-TW either.
|
ye i miss the final return. and i think mmdb must include zh-cn. |
GeoLite2-City.mmdb supports zh-CN, but does not support chi and zho in sourcemod
The Chinese translation cannot be returned.

This is a fix when GetLanguageInfo got chi or zho, convert to zh-CN to match GeoLite2-City.mmdb