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

FEATURE: Adding Internationalization (i18n) #174

Open
ram-prasad23 opened this issue Jun 12, 2024 · 0 comments
Open

FEATURE: Adding Internationalization (i18n) #174

ram-prasad23 opened this issue Jun 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ram-prasad23
Copy link

Describe the Feature

Feature Request: Internationalization (i18n) Support

Summary

Add support for Internationalization (i18n) to the backend to handle requests in multiple languages. When a request comes with a query parameter lg=ta (Tamil) or lg=en (English), the response should be in the requested language. If the query parameter is not present or the requested language is not supported, the response should default to English.

Description

The goal is to implement i18n support in the Node.js backend to enhance user experience by providing responses in their preferred language. This feature will detect the language from the query parameter lg in the request URL and send the response in the corresponding language. If the requested language is not supported or the lg parameter is not provided, the response will default to English.

Implementation Steps

  1. Add Dependencies:

    • Use a library like i18n or i18next to handle translation files and middleware setup.
    • Ensure to update package.json with the new dependencies.
  2. Set Up Middleware:

    • Create middleware to detect the lg parameter from the request URL.
    • Load the appropriate language file based on the lg parameter or default to English.
  3. Create Translation Files:

    • Set up translation JSON files for supported languages (e.g., en.json for English, ta.json for Tamil).
    • Place translation files in a directory structure that the i18n library can easily access.
  4. Update Responses:

    • Modify existing endpoints to use the i18n library to return translated responses.
    • Ensure that dynamic content in responses also gets translated.

Use Case

  • In frontend we support internationalization. So it will be usefull if we implement it and get the response in the language the requested.

Example

Response (Tamil)

{
  "status":200,
  "message": "வணக்கம், இது உங்கள் கோரிக்கைக்கு பதிலாக இருக்கும்."
}

### Additional Information

_No response_

### Suggested Tools

i18n

### Additional Context or Information

_No response_
@ram-prasad23 ram-prasad23 added the enhancement New feature or request label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant