adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
13.07k stars 1.14k forks source link

Additional Region Support for select locales #7413

Open rgeraghty opened 3 days ago

rgeraghty commented 3 days ago

Provide a general summary of the feature here

We would like to support some additional locales for region support, in same way as exists for French (Canada)

Meaning....

Example...

New locales requested...

πŸ€” Expected Behavior?

However, if intl string files added for any of the above, at later stage, then use matching strings files (eg: en-AU string files + region). Looking at current code seems already supported, just need the locales list updated for above,

😯 Current Behavior

These will all revert to en-US only

πŸ’ Possible Solution

From looking at the code, looks like it might be just updating language tables: https://github.com/adobe/react-spectrum/blob/main/.chromatic-fc/constants.js https://github.com/adobe/react-spectrum/blob/main/packages/dev/docs/pages/react-aria/home/I18n.tsx https://github.com/adobe/react-spectrum/blob/main/packages/%40internationalized/message/src/MessageDictionary.ts https://github.com/adobe/react-spectrum/blob/main/packages/%40internationalized/string/src/LocalizedStringDictionary.ts

and some related files like storybook and tests: https://github.com/adobe/react-spectrum/blob/main/.storybook/constants.js https://github.com/adobe/react-spectrum/blob/main/.storybook-s2/constants.js https://github.com/adobe/react-spectrum/blob/main/packages/%40internationalized/date/tests/DateFormatter.test.js https://github.com/adobe/react-spectrum/blob/main/packages/%40internationalized/date/tests/queries.test.js

MessageDictinary looks to already support this functionality, with just adding language codes to support. es-419 might need extra handling as not xx-XX format.

πŸ”¦ Context

Match other Adobe areas (pls contact rgeraght, lreis any question)

πŸ’» Examples

No response

🧒 Your Company/Team

Adobe

πŸ•· Tracking Issue

No response

dannify commented 3 days ago

Should en-AU: display en-GB translations, but use en-AU region?? @rgeraghty

rgeraghty commented 3 days ago

@dannify en-AU would fall back to en-US strings (as no en-AU strings present, like en-GB falls back to en-US) but use the en-AU region (https://github.com/adobe/react-spectrum/blob/main/packages/%40internationalized/message/src/MessageDictionary.ts#L59)

We have option at any time to add strings for en-AU, en-GB, fr-CA, es-MX etc.... if feel its needed, but not required for this this issue request, which is just add additional locales to current lang supported list, to get the region support.

I updated expected behaviour (just now) in issue description to add note for this,