-
-
Notifications
You must be signed in to change notification settings - Fork 572
tolgee-localisation #41
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: main
Are you sure you want to change the base?
Conversation
WalkthroughInternationalization support was added to several React components by replacing hardcoded UI strings with translation function calls. A new JSON configuration file was introduced to track the migration status of localization keys for these components, documenting their translation metadata and progress. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ReactComponent
participant TolgeeTranslation
User->>ReactComponent: Interacts with UI (e.g., opens form, views message)
ReactComponent->>TolgeeTranslation: Requests translation for UI string
TolgeeTranslation-->>ReactComponent: Returns localized string
ReactComponent-->>User: Renders UI with localized text
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm warn old lockfile ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 6
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.tolgee/migration-status.json(1 hunks)src/components/LoginForm.jsx(2 hunks)src/components/MessageForm.jsx(2 hunks)src/components/MyMessage.jsx(2 hunks)src/components/TheirMessage.jsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/components/MessageForm.jsx (1)
src/components/LoginForm.jsx (1)
useTranslate(8-8)
src/components/LoginForm.jsx (1)
src/components/MessageForm.jsx (1)
useTranslate(9-9)
🔇 Additional comments (3)
src/components/MessageForm.jsx (1)
4-4: LGTM! Proper translation implementation.The translation integration is implemented correctly:
- Proper import of
useTranslatehook- Correct usage of the hook to obtain the
tfunction- Appropriate use of translation function for the placeholder text
This serves as a good reference implementation for the other components.
Also applies to: 9-9, 37-38
src/components/LoginForm.jsx (2)
3-3: LGTM! Proper translation setup.The translation imports and setup are implemented correctly with both the
Tcomponent anduseTranslatehook properly imported and used.Also applies to: 8-8
38-41: Translation keys need to be defined.The placeholder translations use keys that have empty names in the migration status file (
username-input-placeholder,password-input-placeholder). Ensure these keys are properly defined in the translation configuration.
| "name": "start-chatting-button", | ||
| "description": "Title of the chat application displayed at the top of the login form", | ||
| "default": "Chat Application" |
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.
Fix mismatched key name and description.
The key name "start-chatting-button" doesn't match the description "Title of the chat application displayed at the top of the login form". The description should align with the actual usage of the key.
🤖 Prompt for AI Agents
In .tolgee/migration-status.json around lines 11 to 13, the key name
"start-chatting-button" does not match the description about the chat
application title. Update either the key name to reflect a title-related key or
revise the description to accurately describe the button's purpose, ensuring
both align with the actual usage context.
| "name": "chat-application-title", | ||
| "description": "Error message shown when login credentials are incorrect", | ||
| "default": "Oops, incorrect credentials." |
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.
Fix mismatched key name and description.
The key name "chat-application-title" doesn't match the description "Error message shown when login credentials are incorrect". This appears to be a data integrity issue in the migration configuration.
🤖 Prompt for AI Agents
In .tolgee/migration-status.json around lines 6 to 8, the key name
"chat-application-title" does not match the description about an error message
for incorrect login credentials. Update the key name to accurately reflect the
description, such as renaming it to something like "login-error-message" or
another appropriate identifier that matches the error message context.
| "name": "", | ||
| "description": "Placeholder text for the username input field", | ||
| "default": "Username" |
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.
Complete migration by adding key names.
Multiple translation entries have empty key names, indicating incomplete migration. This will prevent proper localization functionality.
These entries need proper key names assigned:
- Username placeholder (line 16)
- Password placeholder (line 21)
- Start chatting button (line 26)
- Message input placeholder (line 36)
- Message attachment alt text (lines 46, 56)
Also applies to: 21-23, 26-28, 36-36, 46-46, 56-56
🤖 Prompt for AI Agents
In .tolgee/migration-status.json around lines 16 to 18 and the other specified
ranges, several translation entries have empty "name" fields which breaks
localization. Assign meaningful and unique key names to each entry, such as
"username_placeholder" for the username input field, "password_placeholder" for
the password input, "start_chatting_button" for the button,
"message_input_placeholder" for the message input, and appropriate keys for the
message attachment alt texts. Ensure all entries have non-empty, descriptive key
names to complete the migration properly.
| alt={ | ||
| t('message-attachment-alt')} |
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.
Add missing translation imports.
The component uses t('message-attachment-alt') but is missing the required imports for the translation function. This will cause a runtime error.
Add the missing import and hook usage:
+import { useTranslate } from '@tolgee/react';
+
const TheirMessage = ({ lastMessage, message }) => {
+ const { t } = useTranslate();
const isFirstMessageByUser = !lastMessage || lastMessage.sender.username !== message.sender.username;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| alt={ | |
| t('message-attachment-alt')} | |
| import { useTranslate } from '@tolgee/react'; | |
| const TheirMessage = ({ lastMessage, message }) => { | |
| const { t } = useTranslate(); | |
| const isFirstMessageByUser = !lastMessage || lastMessage.sender.username !== message.sender.username; | |
| // … |
🤖 Prompt for AI Agents
In src/components/TheirMessage.jsx around lines 16 to 17, the translation
function `t` is used without importing it, causing a runtime error. Import the
translation hook (e.g., `useTranslation` from the i18n library) at the top of
the file and initialize `t` by calling the hook inside the component before
using it. This will ensure the translation function is properly defined and
available.
| alt={ | ||
| t('message-attachment-alt')} |
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.
Add missing translation imports.
The component uses t('message-attachment-alt') but is missing the required imports for the translation function. This will cause a runtime error.
Add the missing import and hook usage:
+import { useTranslate } from '@tolgee/react';
+
const MyMessage = ({ message }) => {
+ const { t } = useTranslate();
if (message.attachments && message.attachments.length > 0) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| alt={ | |
| t('message-attachment-alt')} | |
| import { useTranslate } from '@tolgee/react'; | |
| const MyMessage = ({ message }) => { | |
| const { t } = useTranslate(); | |
| if (message.attachments && message.attachments.length > 0) { | |
| return ( | |
| <img | |
| src={message.attachments[0].url} | |
| alt={t('message-attachment-alt')} | |
| /> | |
| ); | |
| } | |
| return null; | |
| }; | |
| export default MyMessage; |
🤖 Prompt for AI Agents
In src/components/MyMessage.jsx around lines 6 to 7, the translation function
`t` is used without importing it, causing a runtime error. Import the
translation hook (e.g., `useTranslation` from 'react-i18next') at the top of the
file and initialize the `t` function by calling the hook inside the component
before using it.
| setError( | ||
| t('incorrect-credentials-error')); |
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.
💡 Verification agent
🧩 Analysis chain
Verify translation key consistency.
The code uses t('incorrect-credentials-error') but the migration status file has this mapped incorrectly under the key "chat-application-title". Ensure the translation key matches the intended usage.
🏁 Script executed:
#!/bin/bash
# Verify translation key usage consistency across components and migration status
echo "Checking for 'incorrect-credentials-error' key usage..."
rg -A 2 -B 2 "incorrect-credentials-error"
echo "Checking migration status for error message configuration..."
jq '.["src/components/LoginForm.jsx"].keys[] | select(.description | contains("Error message"))' .tolgee/migration-status.jsonLength of output: 817
Translation key mismatch in migration-status.json
The LoginForm.jsx uses:
t('incorrect-credentials-error')but in .tolgee/migration-status.json the entry under ["src/components/LoginForm.jsx"].keys[] is named "chat-application-title":
{
"name": "chat-application-title",
"description": "Error message shown when login credentials are incorrect",
"default": "Oops, incorrect credentials."
}Please update it to:
{
- "name": "chat-application-title",
+ "name": "incorrect-credentials-error",
"description": "Error message shown when login credentials are incorrect",
"default": "Oops, incorrect credentials."
}This will ensure the translation key in code and migration status stay in sync.
🤖 Prompt for AI Agents
In src/components/LoginForm.jsx around lines 27 to 28, the translation key used
in the t() function is 'incorrect-credentials-error', but the
migration-status.json file lists the key as 'chat-application-title'. Update the
translation key in the code to 'chat-application-title' to keep it consistent
with the migration status file.
Tolgee Localization Migration
Migration tool: Tolgee AI Migrator
Summary by CodeRabbit