@redocly/theme 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -44,8 +44,12 @@ const LanguagePicker = (props) => {
|
|
|
44
44
|
if (locales.length < 2) {
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
|
+
const locale = locales.find((l) => l.code === currentLocale);
|
|
48
|
+
if (!locale) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
47
51
|
return (react_1.default.createElement(Dropdown, { "data-component-name": "I18n/LanguagePicker", ref: dropdownRef, isOpen: isOpen, onClick: () => setIsOpen(!isOpen), onBlur: () => setIsOpen(false) },
|
|
48
|
-
react_1.default.createElement(DropdownValue, { role: "link" },
|
|
52
|
+
react_1.default.createElement(DropdownValue, { role: "link" }, locale.name || locale.code),
|
|
49
53
|
react_1.default.createElement(DropdownMenu, null, locales.map((locale) => (react_1.default.createElement(MenuItem, { onClick: () => {
|
|
50
54
|
const newLangPathname = (0, utils_1.withPathPrefix)((0, utils_1.getPathnameForLocale)(location.pathname, defaultLocale, locale.code, locales));
|
|
51
55
|
const newUrlWithLanguage = `${newLangPathname}${location.search}${location.hash}`;
|
package/package.json
CHANGED
|
@@ -23,6 +23,11 @@ export const LanguagePicker = (props: { onChangeLanguage: (newLang: string) => v
|
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
const locale = locales.find((l) => l.code === currentLocale);
|
|
27
|
+
if (!locale) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
return (
|
|
27
32
|
<Dropdown
|
|
28
33
|
data-component-name="I18n/LanguagePicker"
|
|
@@ -31,7 +36,7 @@ export const LanguagePicker = (props: { onChangeLanguage: (newLang: string) => v
|
|
|
31
36
|
onClick={() => setIsOpen(!isOpen)}
|
|
32
37
|
onBlur={() => setIsOpen(false)}
|
|
33
38
|
>
|
|
34
|
-
<DropdownValue role="link">{
|
|
39
|
+
<DropdownValue role="link">{locale.name || locale.code}</DropdownValue>
|
|
35
40
|
<DropdownMenu>
|
|
36
41
|
{locales.map((locale) => (
|
|
37
42
|
<MenuItem
|