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

Add support for client-side localisation #1456

Open
Badgerati opened this issue Nov 22, 2024 · 0 comments
Open

Add support for client-side localisation #1456

Badgerati opened this issue Nov 22, 2024 · 0 comments
Assignees

Comments

@Badgerati
Copy link
Owner

Pode currently has support for localisation on server-side strings - primarily errors and some informational text displayed on the terminal.

This will include the other side to this, which is to allow localised values - strings, dates, times, numbers - but for the client-side.

The plan is to leverage the AutoImport feature, which will automatically import any locale files found in a /locales folder found at the root of your server - similar to /views. The path can be customised, or the auto-importing disabled. And there will also be an Import-PodeLocaleData to do this manually, as well as an Add-PodeLocale to fully do it programmatically via a hashtable.

The structure of the folder will be the same as what Import-LocalizedData expects - where sub-directories are the names of the locales/cultures, and they then each contain .psd1 files.

/locales
    /en
        /Locales1.psd1
        /Locales2.psd1
    /fr
        /Locales1.psd1
        /Locales2.psd1

During a web request, Pode will automatically calculate which culture the request should use via:

  • Cookies - such as pode.culture
  • Headers - such as X-PODE-CULTURE
  • Session (such as $WebEvent.Session.Data.Culture)
  • Authenticated User (such as $WebEvent.Auth.User.Culture)
  • Accept-Language header
  • Server default culture - either custom or from $PSUICulture
  • en

There will also be new scoped variables to help:

  • $locale:
  • $datetime:
  • $date:
  • $time:
  • $number:

The latter ones for datetimes and numbers will help localise variables containing datetimes/numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

1 participant