-
-
Notifications
You must be signed in to change notification settings - Fork 4
feat(i18n): localize quiz anti-cheat, header and blog filters #175
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| export const SITE_LINKS = [ | ||
| { href: '/q&a', label: 'Q&A' }, | ||
| { href: '/quizzes', label: 'Quizzes' }, | ||
| { href: '/leaderboard', label: 'Leaderboard' }, | ||
| { href: '/blog', label: 'Blog' }, | ||
| { href: '/about', label: 'About' }, | ||
| { href: '/contacts', label: 'Contacts' }, | ||
| { href: '/shop', label: 'Shop' }, | ||
| { href: '/q&a', labelKey: 'qa' }, | ||
| { href: '/quizzes', labelKey: 'quizzes' }, | ||
| { href: '/leaderboard', labelKey: 'leaderboard' }, | ||
| { href: '/blog', labelKey: 'blog' }, | ||
| { href: '/about', labelKey: 'about' }, | ||
| { href: '/contacts', labelKey: 'contacts' }, | ||
| { href: '/shop', labelKey: 'shop' }, | ||
| ] as const; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
next-intl t.raw() method missing keys error handling behavior💡 Result:
Short answer: when t.raw(...) (or any t(...) call) can't find a message next-intl logs an i18n error and returns the message id (namespace.key) so the app keeps running. You can customize this via getMessageFallback and onError (e.g., return a different fallback string or change logging/throwing). [1][2]
Relevant docs:
If you want the runtime to behave differently for t.raw specifically (e.g., throw or return null), implement getMessageFallback/onError in your request/provider config to handle IntlErrorCode.MISSING_MESSAGE. [1][3]
🌐 Web query:
next-intl t.has() method documentation and usage💡 Result:
Short answer
Example
const t = useTranslations('About');
if (t.has('title')) {
return
{t('title')}
;} else {
return
Fallback
;}
Notes
Sources
[1] next-intl docs — "Optional messages" / translations usage.
[2] amannn/next-intl GitHub — issue discussing optional translations and t.has.
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 144
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 115
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 98
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 98
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 98
🏁 Script executed:
# Check the i18n config files cat -n frontend/i18n/config.tsRepository: DevLoversTeam/devlovers.net
Length of output: 393
🏁 Script executed:
# Check the i18n request file cat -n frontend/i18n/request.tsRepository: DevLoversTeam/devlovers.net
Length of output: 566
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 3426
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 4597
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 116
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 382
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 1281
🏁 Script executed:
# Look at message files to see what translations exist for categories ls -la frontend/messages/Repository: DevLoversTeam/devlovers.net
Length of output: 363
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 53
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 157
🏁 Script executed:
Repository: DevLoversTeam/devlovers.net
Length of output: 909
The fallback logic in
getCategoryLabeldoesn't work as intended; uset.has()to properly check translation existence.The
typeof translated === 'string'check will always pass becauset.raw()returns a string regardless—either the translation value or the message id (e.g.,"categories.career") when the key is missing. This means missing translations return the message id instead of falling back to the original category name.Use
t.has()to check if the translation exists before accessing it:♻️ Suggested fix
const getCategoryLabel = (categoryName: string): string => { const key = categoryName.toLowerCase(); const translationKey = `categories.${key}`; - // Try to get translation, fallback to original name - const translated = t.raw(translationKey); - return typeof translated === 'string' ? translated : categoryName; + return t.has(translationKey) ? t(translationKey) : categoryName; };This same pattern appears in
BlogCategoryLinks.tsx(lines 30–35) and should be updated there as well.🤖 Prompt for AI Agents