Skip to content
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

Fix: AiHelper malfunction when site's locale is Simplified Chinese #705

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

pangbo13
Copy link
Contributor

@pangbo13 pangbo13 commented Jul 5, 2024

The latest AI plugin encounters an error when using the editor AI assistant's translation feature if the site setting or user custom language is set to Simplified Chinese (zh_CN).

I noticed a similar issue being reported on meta: NoMethodError after upgrade.

The error originates from:

locale_hash = LocaleSiteSetting.language_names[locale]

The cause of the problem is that Simplified Chinese is coded as "zh_CN" in the site settings, but the key in LocaleSiteSetting is "zh", leading to a mismatch.

This PR fixes the issue by copying the approach used in Discourse core:

https://github.com/discourse/discourse/blob/bb0daa33cd93eeffb230689d1daacd737f61b2e7/app/models/locale_site_setting.rb#L11

@ZogStriP ZogStriP merged commit 4ebbdc0 into discourse:main Jul 5, 2024
5 checks passed
@pangbo13 pangbo13 deleted the fix/locale_hash branch July 5, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants