Skip to content

Conversation

@LeandraH
Copy link
Contributor

@LeandraH LeandraH commented Oct 16, 2025

Short Description

I rewrote the language selection to use Mui Autocomplete, in order to make it easier to find languages when there are a lot of them.

Proposed Changes

  • Used Mui Autocomplete for the language selection in desktop
  • The user can search for a language in the language's own name, the current language, or the fallback language, i.e. German
  • Made the language selection in mobile functionally similar (it didn't look good with the Autocomplete)
  • Removed the language selection from the CityContentHeader if there are no languages (which shouldn't be the case)
  • Removed the Dropdown which wasn't used anywhere else
  • Removed the SelectorItemModel which wasn't used anywhere else

Side Effects

  • Hopefully none

Testing

Change the language on lots of pages

Resolved Issues

Fixes: #3349


expect(getAllByText('English')[0]?.closest('a')).toHaveAttribute('href', poi0.availableLanguages.en)
expect(getAllByText('Deutsch')[0]?.closest('a')).toHaveAttribute('href', poi0.availableLanguages.de)
// Pathname is not correctly updated, therefore the pathname does not include the slug
expect(getAllByText('اَللُّغَةُ اَلْعَرَبِيَّة')[1]?.closest('a')).toHaveAttribute('href', '/augsburg/ar/locations')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anybody know why we're testing for the Arabic translation when there isn't one in the PoiModelBuilder?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think English, German and Arabic where just the three default languages and its always good to test with an RTL language/different alphabet as well (obviously doesn't matter in this case but I think it also doesnt really hurt?).

Copy link
Contributor Author

@LeandraH LeandraH Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that this is a poorly written test, that half-tests something that doesn't work (I also don't really understand the comment, how is the pathname not correctly updated? Is that because there is no Arabic translation in the poi?) If we want to test for Arabic, then I think we should add Arabic test data to the test 🤷

@steffenkleinle
Copy link
Member

Nice! I think we should carefully consider this, perhaps we can combine this with the previous design + the search box somehow?

I think without German aliases for the languages this perhaps even worsens the language selection. As e.g. counselor, I would not want to have to type Farsi in Farsi in another alphabet to find the language. While its still possible to just select the language from the list, I think it was easier/more overseeable before.

@steffenkleinle steffenkleinle linked an issue Oct 17, 2025 that may be closed by this pull request
Base automatically changed from 3231-design-system-web to main October 20, 2025 15:16
@bahaaTuffaha
Copy link
Contributor

bahaaTuffaha commented Oct 22, 2025

🤔 check this out https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames#language_display_names
So I think we can pass available language codes and retrun all possible language names in different languages like arabic or العربية

@steffenkleinle steffenkleinle added the Web Affects the web project label Nov 3, 2025
@LeandraH LeandraH force-pushed the 3349-improve-language-selection branch from 6a3d29a to b19b980 Compare November 6, 2025 10:56
@LeandraH
Copy link
Contributor Author

LeandraH commented Nov 6, 2025

🤔 check this out https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames#language_display_names So I think we can pass available language codes and retrun all possible language names in different languages like arabic or العربية

Thank you, the Intl object is really very cool! Unfortunately, it's not fully implemented in react-native, and the DisplayNames are one of the things that aren't 😢

@bahaaTuffaha
Copy link
Contributor

bahaaTuffaha commented Nov 6, 2025

🤔 check this out https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames#language_display_names So I think we can pass available language codes and retrun all possible language names in different languages like arabic or العربية

Thank you, the Intl object is really very cool! Unfortunately, it's not fully implemented in react-native, and the DisplayNames are one of the things that aren't 😢

check this out https://www.npmjs.com/package/@formatjs/intl-displaynames?activeTab=readme what do you think of this?

  • I realized how big this package is unless we tree shake the rest or somthing

@bahaaTuffaha
Copy link
Contributor

Also we have https://github.com/unicode-org/cldr-json/tree/main/cldr-json/cldr-localenames-full

we can take what we need (each folder has languages.json).

@LeandraH
Copy link
Contributor Author

LeandraH commented Nov 7, 2025

I played around a bit with the polyfills from FormatJS and got a first draft running. Since getting the actual size of the app when downloading from the app store requires uploading it to said app store (there's lots of additional caching also between different apps), these absolute numbers are not reliable, but I assume that the relative change in size is somewhat accurate, at least on iOS. For a release version on iOS, it went up from 59.1 MB to 59.5 MB. For a debug version on Android, the size stayed at 234.3 MB, I'll check if the polyfill is necessary there at all (when I'm back from vacation in a week).

Either way, I would say that it's worth adding the polyfill in. Other opinions?

@steffenkleinle
Copy link
Member

I played around a bit with the polyfills from FormatJS and got a first draft running. Since getting the actual size of the app when downloading from the app store requires uploading it to said app store (there's lots of additional caching also between different apps), these absolute numbers are not reliable, but I assume that the relative change in size is somewhat accurate, at least on iOS. For a release version on iOS, it went up from 59.1 MB to 59.5 MB. For a debug version on Android, the size stayed at 234.3 MB, I'll check if the polyfill is necessary there at all (when I'm back from vacation in a week).

Either way, I would say that it's worth adding the polyfill in. Other opinions?

Sounds good, perhaps we can double check the actual size change in the stores afterwards again. This polyfill only adds the language names though, correct? So all the other intl stuff that does not yet work in react-native does not get fixed by this?

@LeandraH
Copy link
Contributor Author

This polyfill only adds the language names though, correct? So all the other intl stuff that does not yet work in react-native does not get fixed by this?

The polyfill also needs Intl.Locale (polyfill and real deal) but it's not enough to replace the other stuff. It's a good idea to check on polyfills for those, I'll create a ticket for it.

@LeandraH LeandraH force-pushed the 3349-improve-language-selection branch from 2622fc3 to cf8e028 Compare November 27, 2025 15:02
@LeandraH LeandraH force-pushed the 3349-improve-language-selection branch from 56e9383 to e5e3643 Compare November 28, 2025 12:35
@LeandraH LeandraH marked this pull request as ready for review November 28, 2025 12:36
@LeandraH
Copy link
Contributor Author

LeandraH commented Nov 28, 2025

Alright, this is only the changes for the web, I'll open a separate PR branch off of the redesign for the native changes, including the polyfills.

Copy link
Contributor

@bahaaTuffaha bahaaTuffaha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! ✨
Tested on Chrome and Firefox ✅

Left some comments...

Copy link
Contributor

@f1sh1918 f1sh1918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine 👍
Just have some general question to the auto complete.
It should also be possible to use that mobile with some styling adjustments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Web Affects the web project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve language selection

5 participants