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(mobile): init i18n support #3377

Merged
merged 7 commits into from
Mar 31, 2025
Merged

feat(mobile): init i18n support #3377

merged 7 commits into from
Mar 31, 2025

Conversation

hyoban
Copy link
Member

@hyoban hyoban commented Mar 31, 2025

Description

PR Type

  • Feature
  • Bugfix
  • Hotfix
  • Other (please describe):

Screenshots (if UI change)

Demo Video (if new feature)

Linked Issues

part of FOL-1847

Additional context

Changelog

  • I have updated the changelog/next.md with my changes.

Copy link

vercel bot commented Mar 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
follow ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2025 3:15pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
follow-external-ssr ⬜️ Ignored (Inspect) Visit Preview Mar 31, 2025 3:15pm

@follow-reviewer-bot
Copy link

Suggested PR Title:

feat(i18n): integrate i18next for improved localization

Change Summary:
This PR enhances the mobile app's localization by integrating i18next, adding support for multiple languages through dynamic resource loading and configuration. Key changes include new translation-related files, updates to settings for language management, and optimizations in user interfaces to reflect localized content.

Code Review:

Code Review: Change Requests

  1. File: apps/mobile/src/@types/constants.ts

    • Lines: 1–48
    • Issue: currentSupportedLanguages includes language codes without clear documentation or context. This could lead to confusion for future developers. Consider adding comments or documentation explaining the purpose and scope of this list.
    • Change Request: Add inline comments or link to documentation that details the rationale for including specific language codes.
  2. File: apps/mobile/src/@types/default-resource.ts

    • Lines: 1–324
    • Issue: This file imports a vast number of language resources, resulting in bloated code. Hardcoding imports for all locales reduces scalability and makes maintenance cumbersome.
    • Change Request: Consider using dynamic imports and a configuration file (e.g., a JSON or YAML file) to define supported locales. This will reduce file size and improve maintainability.
  3. File: apps/mobile/src/lib/i18n.ts

    • Lines: 1–19
    • Issue: The logic for determining device language (getDeviceLanguage) is functional but not fully extensible. Specifically, the possibleDeviceLanguage array assumes specific formats for locale detection without fallback mechanisms for edge cases.
    • Change Request: Add a more robust fallback mechanism or logging to identify unsupported devices that might lead to incorrect data defaults.
  4. File: apps/mobile/src/modules/settings/routes/General.tsx

    • Lines: 18–38
    • Issue: Duplication of logic for language selection across different settings keys (language and actionLanguage) increases code repetition. The LanguageSelect function is useful but can be further optimized to avoid redundancy.
    • Change Request: Refactor the LanguageSelect component to better handle shared functionality across settings keys, possibly through props or context.
  5. File: apps/mobile/src/main.tsx

    • Lines: 43–81
    • Issue: The initialization logic for the i18n instance is asynchronous (initializeI18n()), but there's no error handling in case of initialization failure. If initializeI18n fails, the app might crash unexpectedly when referencing the RootComponent.
    • Change Request: Wrap initializeI18n in a try-catch block or add error logging to handle failed initialization gracefully.
  6. File: apps/mobile/tsconfig.json

    • Lines: 4–11
    • Issue: Setting the module type to "commonjs" may create compatibility issues with ESModule imports. This might conflict with how dependencies such as i18next are imported and used elsewhere (e.g., dynamic imports in codebase).
    • Change Request: Test whether commonjs conflicts with ESModule dependencies. If issues arise, consider switching to "module": "esnext" and testing the application for consistency.

Summary

These issues collectively address scalability, maintainability, and error handling in the localization framework and infrastructure setup. Making these changes will improve the project's robustness and readiness for future updates.

Copy link

linear bot commented Mar 31, 2025

FOL-1847 i18n for mobile

@hyoban hyoban enabled auto-merge (squash) March 31, 2025 15:12
@hyoban hyoban merged commit f1e34e9 into dev Mar 31, 2025
15 checks passed
@hyoban hyoban deleted the feat/03-31-init-i18n branch March 31, 2025 15:16
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