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

Localization: setLanguage(null) throws TS error #6712

Closed
ej612 opened this issue Mar 15, 2023 · 0 comments · Fixed by #6738
Closed

Localization: setLanguage(null) throws TS error #6712

ej612 opened this issue Mar 15, 2023 · 0 comments · Fixed by #6738
Assignees
Labels
bug This issue is a bug in the code TOPIC Core

Comments

@ej612
Copy link

ej612 commented Mar 15, 2023

Bug Description

In our storybook, we have a language picker, that lets us launch our app with any of the supported languages. To reset the language to the default, we used to do this:

import { setLanguage } from '@ui5/webcomponents-base/dist/config/Language';

if (language === 'local') {
  setLanguage(null);
} else {
  setLanguage(language);
}

Where 'local' is a dummy ID that we assigned to the item in the language picker that corresponds to the default language.

This has been working fine for a while. However, with v1.10.3, setLanguage is typed and will only accept a string parameter, meaning we can't call it with null anymore. Even though it still works, as getLocale() resets the language to the browser's default language if lang isn't given.

So my question is: Are the typings wrong, and should the string parameter be made optional so we can call setLanguage() to reset the language? Or what is the new/recommended way to reset the language?

Thanks in advance!

@ej612 ej612 added the bug This issue is a bug in the code label Mar 15, 2023
@ej612 ej612 changed the title Localization: setLanguage(null) throws error Localization: setLanguage(null) throws TS error Mar 15, 2023
@nnaydenow nnaydenow self-assigned this Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug in the code TOPIC Core
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

3 participants