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

Feat/i18n #167

Merged
merged 3 commits into from
Sep 13, 2024
Merged

Feat/i18n #167

merged 3 commits into from
Sep 13, 2024

Conversation

rustin01
Copy link
Contributor

@rustin01 rustin01 commented Sep 13, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a language selection page for improved localization.
    • Added support for dynamic language switching throughout the application.
  • Enhancements

    • Updated various components to support internationalization, allowing for localized text across the user interface.
    • Improved error messages and button labels to be translatable based on user preferences.
  • Bug Fixes

    • Upgraded dependencies to enhance performance and stability.

These updates aim to enhance user experience by providing a more accessible and customizable interface.

Copy link
Contributor

coderabbitai bot commented Sep 13, 2024

Walkthrough

The changes involve significant updates to the wallet application, primarily focusing on internationalization (i18n) enhancements. Key modifications include the integration of translation functions across various components, the addition of new localization strings for multiple languages, and the introduction of a language selection feature. Dependency versions for localization libraries have been updated, and session management has been improved to support dynamic language switching. Additionally, several components have been modified to utilize these internationalization features, enhancing the overall user experience.

Changes

Files Change Summary
apps/wallet/package.json Updated versions of i18next and react-i18next dependencies.
apps/wallet/src/App.tsx Added a new route for language selection using SelectLangPage.
apps/wallet/src/apis/index.ts Modified queryClient initialization to include default options for query behavior.
apps/wallet/src/components/*.tsx Integrated internationalization support using useTranslation and Trans components, replacing hardcoded strings with translatable keys in multiple components.
apps/wallet/src/i18n/locales/*.json Added numerous new localization strings for English, Japanese, Russian, and Traditional Chinese, enhancing user interface clarity and functionality.
apps/wallet/src/main.tsx Removed runtime-related constants from imports and associated console logs.
apps/wallet/src/pages/*/*.tsx Updated various pages to utilize useTranslation for dynamic text rendering, enhancing localization across the application.
apps/wallet/src/stores/session.ts Enhanced session management to support language settings, added switchLanguage method.
apps/wallet/src/utils/lang.ts Introduced utility functions for language handling and a languages object mapping language codes to names.
packages/sdk/src/lib/*.ts Modified constructors to accept a new lang parameter for supporting multilingual content in iframes and SDK functionalities.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Session
    participant LanguageService

    User->>App: Select Language
    App->>Session: switchLanguage(lang)
    Session->>LanguageService: Update language setting
    LanguageService-->>Session: Language updated
    Session-->>App: Notify language change
    App->>User: Display updated language
Loading

🐇 In the garden, hopping so bright,
New languages bloom, a colorful sight.
With every click, a choice to select,
Our wallet speaks, with perfect respect.
From English to Japanese, all in a row,
A world of words, let the translations flow! 🌼

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Deploy preview for hibit-id ready!

✅ Preview
https://hibit-7xqclnxjr-delandlabs-projects.vercel.app

Built with commit 52cb90b.
This pull request is being automatically deployed with vercel-action

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
apps/wallet/src/utils/lang.ts (1)

15-25: Consider simplifying the getSystemLang function.

The getSystemLang function correctly determines the user's language based on the navigator.language property, but it could be simplified:

  1. The check for Traditional Chinese could be more concise by directly comparing navigator.language with 'zh-TW' and 'zh-HK':
if (['zh-TW', 'zh-HK'].includes(language)) {
  return 'cnt';
}
  1. If the user's specific region is not supported, it might be better to fall back to the language code ('zh', 'ja', etc.) if available, rather than always using 'en' (English):
const [languageCode] = language.split('-');
if (Object.keys(languages).includes(languageCode)) {
  return languageCode as Language;
}

Here's a suggested refactoring of the getSystemLang function:

export const getSystemLang = (): Language => {
  const language = window.navigator.language;
  if (['zh-TW', 'zh-HK'].includes(language)) {
    return 'cnt';
  }
  const [languageCode] = language.split('-');
  if (Object.keys(languages).includes(languageCode)) {
    return languageCode as Language;
  }
  return 'en';
};
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c352adc and 52cb90b.

Files ignored due to path filters (2)
  • apps/wallet/src/assets/blue-check.svg is excluded by !**/*.svg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (31)
  • apps/wallet/package.json (1 hunks)
  • apps/wallet/src/App.tsx (2 hunks)
  • apps/wallet/src/apis/index.ts (1 hunks)
  • apps/wallet/src/components/CopyButton.tsx (1 hunks)
  • apps/wallet/src/components/LogoSection.tsx (2 hunks)
  • apps/wallet/src/components/ReceiveButton.tsx (2 hunks)
  • apps/wallet/src/components/SendButton.tsx (2 hunks)
  • apps/wallet/src/i18n/locales/cnt.json (1 hunks)
  • apps/wallet/src/i18n/locales/en.json (2 hunks)
  • apps/wallet/src/i18n/locales/ja.json (1 hunks)
  • apps/wallet/src/i18n/locales/ru.json (1 hunks)
  • apps/wallet/src/main.tsx (1 hunks)
  • apps/wallet/src/pages/account-manage/index.tsx (1 hunks)
  • apps/wallet/src/pages/login/index.tsx (2 hunks)
  • apps/wallet/src/pages/main/index.tsx (3 hunks)
  • apps/wallet/src/pages/password/create.tsx (4 hunks)
  • apps/wallet/src/pages/password/reset.tsx (6 hunks)
  • apps/wallet/src/pages/password/verify.tsx (5 hunks)
  • apps/wallet/src/pages/receive-token/index.tsx (2 hunks)
  • apps/wallet/src/pages/select-lang/index.tsx (1 hunks)
  • apps/wallet/src/pages/select-network/index.tsx (1 hunks)
  • apps/wallet/src/pages/send-token/confirm-page.tsx (7 hunks)
  • apps/wallet/src/pages/send-token/index.tsx (5 hunks)
  • apps/wallet/src/pages/settings/index.tsx (2 hunks)
  • apps/wallet/src/stores/session.ts (5 hunks)
  • apps/wallet/src/utils/lang.ts (1 hunks)
  • apps/wallet/src/utils/runtime.ts (2 hunks)
  • packages/sdk/src/lib/dom/index.ts (3 hunks)
  • packages/sdk/src/lib/index.ts (1 hunks)
  • packages/sdk/src/lib/types.ts (1 hunks)
  • packages/sdk/src/lib/wallet.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • apps/wallet/src/main.tsx
  • apps/wallet/src/pages/account-manage/index.tsx
Additional comments not posted (139)
apps/wallet/src/components/ReceiveButton.tsx (3)

5-5: LGTM!

The useTranslation hook is correctly imported from the react-i18next library. This import is necessary for using the translation functionality in the component.


9-9: LGTM!

The t function is correctly destructured from the useTranslation hook. This function will be used to translate the button label.


21-21: LGTM!

The button label is correctly translated using the t function with the translation key 'common_receive'. This allows the button label to be dynamically translated based on the user's selected language.

apps/wallet/src/components/LogoSection.tsx (1)

13-18: LGTM!

The changes correctly integrate internationalization support using the react-i18next library. The use of the Trans component with an i18nKey allows for dynamic translation based on the user's language preferences. Wrapping the Web3.0 term in a span ensures that it retains its visual emphasis while being part of the translatable content. These changes enhance the application's accessibility and usability for a broader audience by supporting multiple languages.

apps/wallet/src/components/SendButton.tsx (3)

6-6: LGTM!

The useTranslation hook is correctly imported from the react-i18next library. This is a standard approach to integrate internationalization in React components.


14-14: LGTM!

The t function is correctly destructured from the useTranslation hook. This function is used to translate strings based on the user's selected language.


26-26: Verify the translation key in the localization files.

The hardcoded text "Send" is correctly replaced with a translatable string using the t function.

Ensure that the translation key 'common_send' is defined in the localization files for each supported language. You can use the following script to search for the key in the localization files:

Verification successful

Translation key 'common_send' is correctly defined in multiple language files.

The 'common_send' translation key has been verified and is present in the following localization files:

  • English (en.json)
  • Russian (ru.json)
  • Japanese (ja.json)
  • Chinese (Traditional) (cnt.json)

The translations are appropriate for each language, and the change has been implemented correctly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the translation key `'common_send'` is defined in the localization files.

# Test: Search for the key in JSON files. Expect: At least one match.
rg --type json -e $'"common_send"'

Length of output: 285

apps/wallet/src/components/CopyButton.tsx (3)

6-6: LGTM!

The import statement for the useTranslation hook is correctly added to facilitate internationalization support in the component.


13-14: LGTM!

The t function is correctly destructured from the useTranslation hook to retrieve localized strings for the component.


22-22: LGTM!

The hardcoded strings for the success and error messages in the toaster notifications are correctly replaced with calls to the t function to retrieve localized strings. This enhances the user experience by displaying messages in the user's preferred language.

Please ensure that the translation keys 'common_copySuccess' and 'common_copyFailed' are correctly defined in the translation files for all supported languages.

Run the following script to verify the presence of these keys:

Also applies to: 25-25

Verification successful

Translation keys are correctly defined in all supported language files

The verification process confirms that the translation keys "common_copySuccess" and "common_copyFailed" are properly defined in all the localization files (Chinese Traditional, English, Japanese, and Russian) located in the apps/wallet/src/i18n/locales/ directory. This ensures that the copy success and failure messages will be correctly localized for all supported languages.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the presence of translation keys in the localization files.

# Test: Search for the translation keys in the localization files. Expect: At least one match for each key.
fd -e json | xargs -I {} sh -c "cat {} | jq 'has(\"common_copySuccess\") and has(\"common_copyFailed\")'" | uniq

Length of output: 251


Script:

#!/bin/bash
# Description: Further investigate translation files and their contents

# List all JSON files
echo "All JSON files in the repository:"
fd -e json

# Display content of JSON files containing either of the required keys
echo -e "\nContent of JSON files with required keys:"
fd -e json | xargs -I {} sh -c "if jq 'has(\"common_copySuccess\") or has(\"common_copyFailed\")' {} > /dev/null 2>&1; then echo '{}:'; jq '.' {}; fi"

# Check for malformed JSON files
echo -e "\nMalformed JSON files:"
fd -e json | xargs -I {} sh -c "if ! jq '.' {} > /dev/null 2>&1; then echo '{}'; fi"

Length of output: 26634

packages/sdk/src/lib/index.ts (1)

8-8: LGTM!

The addition of the Language type to the list of exported types is a straightforward change that enhances the module's interface. This change makes the Language type available for import, which can be utilized in other parts of the application to define or enforce language-related functionalities. The change does not alter existing logic or control flow but expands the module's capabilities by providing access to a new type.

apps/wallet/src/pages/receive-token/index.tsx (3)

7-7: LGTM!

The useTranslation hook is correctly imported from the react-i18next library. This import is necessary for using the translation functionality in the component.


11-11: LGTM!

The t function is correctly destructured from the useTranslation hook. This function will be used to translate strings in the component.


25-25: LGTM!

The title prop of the PageHeader component and the description paragraph are correctly updated to use translated strings. The t function is used with the appropriate translation keys (page_receive_title and page_receive_desc). The chainName variable is also passed as a dynamic value to the page_receive_desc translation string. These changes are consistent with the AI-generated summary and enhance the internationalization support of the component.

Also applies to: 27-27

apps/wallet/src/pages/select-lang/index.tsx (4)

1-9: LGTM!

The imports are correctly specified and the required dependencies are being imported.


10-12: LGTM!

The functional component is correctly defined and the required hooks are being used.


13-38: LGTM!

The language selection page is being rendered correctly and the required functionality is being implemented.


40-40: LGTM!

The component is being exported correctly.

apps/wallet/src/utils/runtime.ts (4)

4-4: LGTM!

The import statement for the Language type is correct and necessary for using it in this file.


12-12: LGTM!

The variable declaration for runtimeLang is correct and will be used to store the language setting retrieved from the URL query string.


35-35: LGTM!

The code correctly retrieves the lang parameter from the URL query string, casts it to the Language type, and assigns it to runtimeLang. Setting runtimeLang to undefined when the lang parameter is not present is a good fallback mechanism.


42-47: LGTM!

Exporting RUNTIME_LANG makes the language setting available to other parts of the application. The debug statements provide visibility into the runtime environment's configuration, including the language setting.

apps/wallet/src/pages/login/index.tsx (3)

13-13: LGTM!

The useTranslation hook is correctly imported from the react-i18next library. This is a standard way to integrate internationalization in React components.


19-19: LGTM!

The t function is correctly destructured from the useTranslation hook. This is the recommended way to translate strings in the component.


30-30: LGTM!

The static text is correctly replaced with a translatable string using the t function. The translation key 'page_login_loginBy' follows a consistent naming convention, which is important for maintainability.

apps/wallet/src/pages/select-network/index.tsx (1)

29-29: LGTM!

The change to use the translation function for the page title is a good practice for internationalization. It allows the title to be rendered in different languages based on the user's locale.

apps/wallet/package.json (1)

35-35: Dependency updates look good!

The minor version updates to i18next and react-i18next should bring in bug fixes, performance improvements, and potentially new features while maintaining backward compatibility. These updates align with the goal of enhancing internationalization in the wallet application.

Also applies to: 40-40

apps/wallet/src/apis/index.ts (1)

8-16: LGTM! The changes enhance query behavior and error handling.

The modifications to the queryClient initialization improve control over query execution and error handling:

  • Setting retry to 1 allows a single retry for failed queries, which can help recover from temporary network issues or server errors.
  • Setting retryDelay to 3000 ms introduces a delay before retrying, preventing overwhelming the server with immediate retries.
  • Setting refetchOnWindowFocus to false prevents automatic refetching of queries when the window regains focus, optimizing performance and reducing unnecessary network requests.

These changes align with the goal of improving the user experience by managing query behavior under certain conditions.

apps/wallet/src/pages/main/index.tsx (3)

16-16: LGTM!

The import statement for the useTranslation hook from the react-i18next library is correct and necessary for integrating internationalization support in the component.


19-19: LGTM!

The destructuring assignment for the t function from the useTranslation hook is correct and necessary for using the translation functionality in the component.


58-58: LGTM!

The usage of the t function to replace hardcoded strings with translatable strings is correct and consistent with the internationalization (i18n) support. This change improves the accessibility and localization of the application, enabling it to support multiple languages more effectively.

Also applies to: 68-68

apps/wallet/src/pages/settings/index.tsx (2)

10-10: LGTM!

The import statement is correct and necessary for the language selection feature.


70-82: Excellent work on adding the language selection feature!

The code changes are well-structured, follow the existing coding style, and implement the language selection functionality correctly. The use of the languages object and hibitIdSession.config.lang is appropriate for displaying the current language. The navigation to the /lang-select page is implemented correctly using the navigate function. The translation function t is used appropriately for the section title.

Great job!

packages/sdk/src/lib/types.ts (2)

6-6: LGTM!

The new Language type definition is a good addition for supporting internationalization. The chosen language codes follow the ISO 639-1 standard, which is a best practice.


12-12: LGTM!

The lang property is a good addition to the HibitIdWalletOptions interface for supporting internationalization. Marking it as optional is the correct approach as users may choose not to specify a language preference.

apps/wallet/src/i18n/locales/cnt.json (13)

54-55: LGTM!

The added localization strings for "logout" and "unlock" actions are appropriate and consistent with the existing format.


56-57: LGTM!

The added localization strings for "copy success" and "copy failed" messages are appropriate and consistent with the existing format.


58-60: LGTM!

The added localization strings for "send", "receive", and "close" actions are appropriate and consistent with the existing format.


62-66: LGTM!

The added localization strings for the logo section description, net worth, and tokens on the home page are appropriate and consistent with the existing format.


68-68: LGTM!

The added localization string for the network selection page title is appropriate and consistent with the existing format.


70-83: LGTM!

The added localization strings for the send page, including field labels, placeholders, error messages, and transaction status messages, are appropriate and consistent with the existing format. They cover various scenarios and provide clear guidance to the user.


85-86: LGTM!

The added localization strings for the receive page title and description are appropriate and consistent with the existing format.


89-89: LGTM!

The added localization string for the current login status message is appropriate and consistent with the existing format.


90-96: LGTM!

The added localization strings for password-related actions, such as setting a password, unlocking the wallet, changing the wallet password, and confirming the password, are appropriate and consistent with the existing format. They cover various password-related scenarios.


97-102: LGTM!

The added localization strings for password-related error messages, such as minimum character requirement, password required, new password required, password mismatch, and incorrect password, are appropriate and consistent with the existing format. They cover various password validation scenarios and provide clear error messages to the user.


110-110: LGTM!

The added localization string for the language setting in the settings page is appropriate and consistent with the existing format.


112-112: LGTM!

The added localization string for the linked accounts status message is appropriate and consistent with the existing format.


113-113: LGTM!

The added localization string for the language selection page title is appropriate and consistent with the existing format.

apps/wallet/src/i18n/locales/ja.json (23)

54-54: LGTM!

The Japanese translation "ログアウト" accurately conveys the meaning of "logout".


55-55: LGTM!

The Japanese translation "ロック解除" accurately conveys the meaning of "unlock".


56-56: LGTM!

The Japanese translation "コピー成功" accurately conveys the meaning of "copy success".


57-57: LGTM!

The Japanese translation "コピー失敗" accurately conveys the meaning of "copy failed".


58-58: LGTM!

The Japanese translation "送信" accurately conveys the meaning of "send".


59-59: LGTM!

The Japanese translation "受信" accurately conveys the meaning of "receive".


60-60: LGTM!

The Japanese translation "閉じる" accurately conveys the meaning of "close".


62-62: LGTM!

The Japanese translation "Web3.0の富を解き放つ" accurately conveys the meaning of "Unlock the wealth of Web3.0".


63-63: LGTM!

The Japanese translation "次の方法でログイン" accurately conveys the meaning of "Login by".


65-65: LGTM!

The Japanese translation "純資産" accurately conveys the meaning of "Net Worth".


66-66: LGTM!

The Japanese translation "トークン" accurately conveys the meaning of "Tokens".


68-68: LGTM!

The Japanese translation "ネットワークを選択" accurately conveys the meaning of "Select Network".


70-70: LGTM!

The Japanese translation "送信" accurately conveys the meaning of "Send".


71-71: LGTM!

The Japanese translation "送信先" accurately conveys the meaning of "Send To".


72-72: LGTM!

The Japanese translation "受取人のアドレス" accurately conveys the meaning of "Recipient's address".


73-73: LGTM!

The Japanese translation "数量" accurately conveys the meaning of "Amount".


74-74: LGTM!

The Japanese translation "ネットワーク手数料推定" accurately conveys the meaning of "Estimated network fee".


75-75: LGTM!

The Japanese translation "アドレスが必要です" accurately conveys the meaning of "Address is required".


76-76: LGTM!

The Japanese translation "無効なアドレス" accurately conveys the meaning of "Invalid address".


77-77: LGTM!

The Japanese translation "数量が必要です" accurately conveys the meaning of "Amount is required".


78-78: LGTM!

The Japanese translation "数量は0より大きくなければなりません" accurately conveys the meaning of "Amount must be greater than 0".


79-79: LGTM!

The Japanese translation "残高不足" accurately conveys the meaning of "Insufficient balance".


80-80: LGTM!

The Japanese translation "ウォレットのガス不足(最低でも{{atLeast}}必要)"

apps/wallet/src/pages/password/create.tsx (4)

23-30: LGTM!

The changes to the formSchema object correctly utilize the t function from the useTranslation hook to provide translated error messages for form validation. The translation keys used are descriptive and follow a consistent naming convention, enhancing the user experience by displaying error messages in the user's preferred language.


78-80: LGTM!

The change to the label text for the password input field correctly utilizes the t function from the useTranslation hook to provide a translated label. The translation key used is descriptive and follows a consistent naming convention, enhancing the user experience by displaying the label in the user's preferred language.


98-100: LGTM!

The change to the label text for the confirm password input field correctly utilizes the t function from the useTranslation hook to provide a translated label. The translation key used is descriptive and follows a consistent naming convention, enhancing the user experience by displaying the label in the user's preferred language.


123-123: LGTM!

The change to the submit button text correctly utilizes the t function from the useTranslation hook to provide a translated label. The translation key used is descriptive and follows a consistent naming convention, enhancing the user experience by displaying the button text in the user's preferred language.

apps/wallet/src/pages/password/verify.tsx (6)

22-22: LGTM!

The useTranslation hook is correctly imported from the react-i18next library to enable internationalization in the component.


26-26: LGTM!

The translation function t is correctly destructured from the useTranslation hook to enable string translations in the component.


31-35: LGTM!

The password field schema in the formSchema object is correctly updated to use the t function for error messages. This enables localized error messages for the password field.


66-66: LGTM!

The error message for the INVALID_PASSWORD error code is correctly updated to use the t function with the translation key page_password_errorPwdIncorrect. This enables a localized error message for the invalid password error.


79-85: LGTM!

The PageHeader component's title prop and the span element's text are correctly updated to use the t function with the respective translation keys. This enables localized text for the page header title and the current login provider message. The authName variable is also passed as a parameter to display the current login provider name.


95-95: LGTM!

The logout button text, password input label text, and submit button text are correctly updated to use the t function with the respective translation keys. This enables localized text for these UI elements.

Also applies to: 103-105, 129-129

apps/wallet/src/i18n/locales/en.json (5)

55-61: LGTM!

The added entries for common actions like "Logout", "Unlock", "Send", "Receive", etc. are appropriate and consistent with the existing localization keys.


64-65: LGTM!

The modified description for the logo section personalizes the experience by mentioning "Web3.0". The change is appropriate.


66-106: Excellent work on enhancing the user experience!

The added entries for various pages significantly improve the usability and security features of the wallet application:

  • The "Send" section includes detailed error messages for various scenarios, which will help users understand issues during transactions.
  • The "Receive" section description personalizes the experience by including the chain name.
  • The password management section includes prompts and error messages, guiding users through password creation, confirmation, and error handling. This covers critical aspects like password length requirements and matching.

These changes make the wallet more user-friendly and informative. Great job!


115-115: LGTM!

The added entry for language selection in the settings page is a great addition. It allows users to choose their preferred language, enhancing accessibility.


118-120: LGTM!

The added entries for the account linking and language selection pages are appropriate and consistent with the page titles.

apps/wallet/src/i18n/locales/ru.json (13)

54-54: LGTM!

The localization string for logging out is appropriate and consistent with the existing strings.


55-55: LGTM!

The localization string for unlocking is appropriate and consistent with the existing strings.


56-57: LGTM!

The localization strings for copy success and failure are appropriate and consistent with the existing strings.


58-60: LGTM!

The localization strings for sending, receiving, and closing are appropriate and consistent with the existing strings.


62-62: LGTM!

The localization string for the logo section description is appropriate and consistent with the existing strings.


63-66: LGTM!

The localization strings for login, net worth, and tokens are appropriate and consistent with the existing strings.


68-68: LGTM!

The localization string for selecting a network is appropriate and consistent with the existing strings.


70-83: LGTM!

The localization strings for the send page, including field labels, placeholders, and error messages, are appropriate and consistent with the existing strings.


85-86: LGTM!

The localization strings for the receive page title and description are appropriate and consistent with the existing strings.


89-96: LGTM!

The localization strings for the password page, including field labels and actions, are appropriate and consistent with the existing strings.


97-102: LGTM!

The localization strings for password error messages are appropriate and consistent with the existing strings.


110-110: LGTM!

The localization string for language in the settings page is appropriate and consistent with the existing strings.


112-113: LGTM!

The localization strings for the account page and language page titles are appropriate and consistent with the existing strings.

apps/wallet/src/pages/password/reset.tsx (8)

21-30: LGTM!

The formSchema object is correctly updated to use the t function from the useTranslation hook for error messages. This enables internationalization of the error messages.


58-58: LGTM!

The success message for password change confirmation is correctly updated to use the t function from the useTranslation hook. This enables internationalization of the success message.


62-62: LGTM!

The error message for incorrect password is correctly updated to use the t function from the useTranslation hook. This enables internationalization of the error message.


79-79: LGTM!

The title prop of the PageHeader component is correctly updated to use the t function from the useTranslation hook. This enables internationalization of the page header title.


84-86: LGTM!

The label text for the password input field is correctly updated to use the t function from the useTranslation hook. This enables internationalization of the label text.


104-106: LGTM!

The label text for the new password input field is correctly updated to use the t function from the useTranslation hook. This enables internationalization of the label text.


123-125: LGTM!

The label text for the confirm password input field is correctly updated to use the t function from the useTranslation hook. This enables internationalization of the label text.


148-148: LGTM!

The text for the confirm button is correctly updated to use the t function from the useTranslation hook. This enables internationalization of the button text.

apps/wallet/src/App.tsx (2)

30-30: LGTM!

The lazy loading of the SelectLangPage component is implemented correctly and follows the existing code conventions.


117-117: LGTM!

The new route for the SelectLangPage component is added correctly within the Routes component and is conditionally rendered for logged-in users, which aligns with the expected behavior for a language selection feature.

apps/wallet/src/pages/send-token/index.tsx (10)

18-18: LGTM!

The import statement for the useTranslation hook from the react-i18next library is correct and aligns with the PR objective of adding internationalization support.


25-25: LGTM!

The destructuring assignment for the t function from the useTranslation hook is correct and will enable using the translation function in the component.


33-33: LGTM!

The required validation message for the toAddress field is correctly updated to use the t function for translation, aligning with the PR objective of internationalizing validation messages.


34-34: LGTM!

The custom validation message for the toAddress field is correctly updated to use the t function for translation, aligning with the PR objective of internationalizing validation messages.


39-39: LGTM!

The required validation message for the amount field is correctly updated to use the t function for translation, aligning with the PR objective of internationalizing validation messages.


41-41: LGTM!

The custom validation message for the amount field is correctly updated to use the t function for translation when the amount is too small, aligning with the PR objective of internationalizing validation messages.


47-47: LGTM!

The custom validation message for the amount field is correctly updated to use the t function for translation when the balance is insufficient, aligning with the PR objective of internationalizing validation messages.


94-94: LGTM!

The title prop of the PageHeader component and the label text for the "Send To" field are correctly updated to use the t function for translation, aligning with the PR objective of internationalizing UI text.

Also applies to: 99-101


104-104: LGTM!

The placeholder text for the "Send To" field, the label text for the "Amount" field, and the "Max" button text are correctly updated to use the t function for translation, aligning with the PR objective of internationalizing UI text.

Also applies to: 118-120, 129-129


185-185: LGTM!

The "Send" button text is correctly updated to use the t function for translation, aligning with the PR objective of internationalizing UI text.

packages/sdk/src/lib/dom/index.ts (2)

3-3: LGTM!

The import statement for the Language type is correct. It's likely used in the code changes below.


159-159: Looks good!

The code changes to the HibitIdIframe constructor and the iframe.src URL construction are implemented correctly. The changes enable passing a language parameter to load language-specific content in the iframe.

A few additional observations:

  • The default value of an empty string for the lang parameter ensures backward compatibility.
  • The Language type is imported correctly at the top of the file.

Great job on enhancing the internationalization capabilities of the iframe!

Also applies to: 170-170

apps/wallet/src/pages/send-token/confirm-page.tsx (12)

18-18: LGTM!

The import statement for the useTranslation hook from the react-i18next library is correct and necessary for using the translation functionality in the component.


24-24: LGTM!

The destructuring of the useTranslation hook to get the t function is correct and necessary for using the t function to translate strings in the component.


67-69: LGTM!

The usage of the translation key and the interpolation of the atLeast variable for the insufficient gas error message is correct and improves the localization of the error message.


115-115: LGTM!

The usage of the translation key for the text "Awaiting confirmation" is correct and improves the localization of the text.


127-127: LGTM!

The usage of the translation key for the text "Transfer finished" is correct and improves the localization of the text.


130-130: LGTM!

The usage of the translation key for the text "View in explorer" is correct and improves the localization of the text.


138-138: LGTM!

The usage of the translation key for the text "Close" is correct and improves the localization of the text.


146-146: LGTM!

The usage of the translation key for the page header title is correct and improves the localization of the title.


151-153: LGTM!

The usage of the translation key for the label text "Send to" is correct and improves the localization of the label.


164-166: LGTM!

The usage of the translation key for the label text "Amount" is correct and improves the localization of the label.


177-179: LGTM!

The usage of the translation key for the label text "Network fee estimation" is correct and improves the localization of the label.


207-207: LGTM!

The usage of the translation keys for the button text "Cancel" and "Confirm" is correct and improves the localization of the buttons.

Also applies to: 214-214

apps/wallet/src/stores/session.ts (5)

5-5: LGTM!

The import is correctly added and is likely used for handling language settings based on the runtime environment.


16-16: LGTM!

The imports are correctly added. getSystemLang is likely used to get the system language and Language is likely an enum or type representing supported languages.


25-25: LGTM!

The lang property is correctly added to the SessionConfig interface to store the language setting. This change aligns with the list of alterations provided.


Line range hint 35-57: LGTM!

The changes correctly initialize the lang property based on the system language and prioritize the RUNTIME_LANG over the stored configuration. Calling i18n.changeLanguage ensures that the language is updated in the internationalization framework when the configuration is loaded.


128-133: LGTM!

The switchLanguage method is correctly implemented to allow dynamically switching the language. It updates the language in the internationalization framework, the session configuration, and local storage. This change aligns with the list of alterations provided.

packages/sdk/src/lib/wallet.ts (1)

284-289: LGTM!

The change to include the lang parameter in the HibitIdIframe constructor aligns with the PR objective of implementing internationalization (i18n) for the wallet application. The modification is straightforward and does not introduce any correctness, security, or performance issues.

@rustin01 rustin01 merged commit 52799ff into main Sep 13, 2024
2 checks passed
@rustin01 rustin01 deleted the feat/i18n branch September 13, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant