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

Fetch the user's UI language with Puter.js #1103

Open
Zac0511 opened this issue Feb 3, 2025 · 1 comment
Open

Fetch the user's UI language with Puter.js #1103

Zac0511 opened this issue Feb 3, 2025 · 1 comment
Labels
idea An idea for a feature/improvement

Comments

@Zac0511
Copy link
Contributor

Zac0511 commented Feb 3, 2025

I thought it would be useful to have a Puter.js function that returns the user's UI language.

This could allow apps that support multi-language to automatically set their language to the same one the user set for Puter's UI.

This could be added in Puter.js as 2 things :

  • puter.language : works just like puter.env, simply returns the language code like en or fr
  • puter.ui.fetchLanguage() : could show more advanced info on the user's language, including code (ex : fr), name (ex : Français) and english name (ex : French).

The functions above are only examples and idk if they should be implemented like that or in another way.

@Zac0511 Zac0511 added the idea An idea for a feature/improvement label Feb 3, 2025
@Pranavjeet-Naidu
Copy link

Proposal: Add a Function to Retrieve User's UI Language

I’d like to work on this feature. I can think of two possible approaches:

1. Using the Intl.DisplayNames API

Pros:

  • Dynamically retrieves language names without maintaining a static list.
  • Supports many languages automatically.
  • Built into modern browsers.

Cons:

  • Not supported in older browsers (fallback required).

2. Using a Hardcoded Lookup Table

Pros:

  • Works everywhere, including older browsers.

Cons:

  • Requires manual updates to support more languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea An idea for a feature/improvement
Projects
None yet
Development

No branches or pull requests

2 participants