-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Improve i18n support and add missing translations #6070
base: main
Are you sure you want to change the base?
Conversation
- Add missing translations for all supported languages - Add i18n test utilities and translation tests - Fix duplicate key detection in tests - Update UI components to use translations
- Add missing translation keys for browser, user avatar, and suggestions - Add translations for all supported languages - Create test to catch hardcoded English strings - Fix components to use translation system properly
- Remove CHAT$WHAT_DO_YOU_WANT_TO_BUILD and LANDING$BUILD_PROMPT in favor of SUGGESTIONS$WHAT_TO_BUILD - Remove unused keys: - STATUS$CONNECTED_TO_SERVER - BROWSER$SCREENSHOT and BROWSER$SCREENSHOT_ALT - SUGGESTIONS$AUTO_MERGE and SUGGESTIONS$AUTO_MERGE_PRS - USER$AVATAR_PLACEHOLDER (duplicate)
- Remove WORKSPACE$LABEL (unused) - Remove CONNECT_TO_GITHUB_BY_TOKEN_MODAL$TERMS_OF_SERVICE (unused)
…penHands into add-japanese-translations
@amanape , apologies that this is a huge PR but hopefully the logic is relatively straightforward. |
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.
About time! This is going to cause some open PRs to have to resolve some conflicts 😭 but definitely worth it.
If you could just address / answer the comments first 😃
expect(uniqueDuplicates).toHaveLength(0); | ||
}); | ||
|
||
it('should have consistent translations for each key', () => { |
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.
What does this mean?
describe('Translations', () => { | ||
describe('Translation Coverage', () => { |
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.
Nested describe, we can unpack to have under a single describe since there are no other describe suites present.
const { container } = render( | ||
<InteractiveChatBox | ||
onSubmit={() => {}} | ||
onStop={() => {}} | ||
/> | ||
); | ||
|
||
// Get all text content | ||
const text = container.textContent; | ||
|
||
// List of English strings that should be translated | ||
const hardcodedStrings = [ | ||
"What do you want to build?", | ||
]; | ||
|
||
// Check each string | ||
hardcodedStrings.forEach(str => { | ||
expect(text).not.toContain(str); | ||
}); |
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.
const { container } = render( | |
<InteractiveChatBox | |
onSubmit={() => {}} | |
onStop={() => {}} | |
/> | |
); | |
// Get all text content | |
const text = container.textContent; | |
// List of English strings that should be translated | |
const hardcodedStrings = [ | |
"What do you want to build?", | |
]; | |
// Check each string | |
hardcodedStrings.forEach(str => { | |
expect(text).not.toContain(str); | |
}); | |
render(<InteractiveChatBox onSubmit={() => {}} onStop={() => {}} />); | |
expect(screen.queryByText("What do you want to build?")).not.toBeInTheDocument(); |
It is not necessary to introduce an array since it contains a single value only, and I doubt this test will be extended in the foreseeable future.
@@ -0,0 +1,47 @@ | |||
import { render } from "@testing-library/react"; |
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.
import { render } from "@testing-library/react"; | |
import { render, screen } from "@testing-library/react"; |
const { container } = render( | ||
<ChatInput | ||
onSubmit={() => {}} | ||
/> | ||
); | ||
|
||
// The placeholder should be a translation key, not English text | ||
const textarea = container.querySelector("textarea"); | ||
expect(textarea?.placeholder).toBe("SUGGESTIONS$WHAT_TO_BUILD"); |
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.
const { container } = render( | |
<ChatInput | |
onSubmit={() => {}} | |
/> | |
); | |
// The placeholder should be a translation key, not English text | |
const textarea = container.querySelector("textarea"); | |
expect(textarea?.placeholder).toBe("SUGGESTIONS$WHAT_TO_BUILD"); | |
render(<ChatInput onSubmit={() => {}} />); | |
screen.getByPlaceholderText("SUGGESTIONS$WHAT_TO_BUILD"); |
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.
Added by mistake, should remove
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.
Added by mistake, should remove
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.
Are these changes necessary? They seem repetitive and it previously worked without them
This PR improves the internationalization (i18n) support in the frontend by:
Adding missing translations for all supported languages (zh-CN, zh-TW, ko-KR, de, no, it, pt, es, ar, fr, tr) for:
Adding i18n test utilities and translation tests:
Updating UI components to use translations consistently
Fixes #6066
Fixes #4280
Here are examples of the localized screens. I have confirmed that all settings menus, etc. are localized.
To run this PR locally, use the following command: