Skip to content

Commit e273249

Browse files
committed
Merge master into release
2 parents 315e784 + 108a67b commit e273249

4 files changed

Lines changed: 119 additions & 32 deletions

File tree

.github/workflows/lighthouse.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: Lighthouse CI
22

33
on:
4-
workflow_run:
5-
workflows: ["Build and Deploy"]
6-
types:
7-
- completed
4+
# Disabling automatic runs for now since it is always failing and we aren't prioritizing fixing it.
5+
# workflow_run:
6+
# workflows: ["Build and Deploy"]
7+
# types:
8+
# - completed
89
workflow_dispatch: # Allows manual triggering of the workflow
910

1011
jobs:

.vscode/settings.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"workbench.colorCustomizations": {
3-
"statusBar.background": "#49d668",
4-
"statusBar.debuggingBackground": "#49d668",
3+
"statusBar.background": "#549d3e",
54
"statusBar.noFolderBackground": "#49d668",
6-
"statussBar.prominentBackground": "#D65649"
5+
"statussBar.prominentBackground": "#D65649",
6+
"statusBar.foreground": "#e7e7e7",
7+
"statusBarItem.hoverBackground": "#6bbb53",
8+
"statusBarItem.remoteBackground": "#549d3e",
9+
"statusBarItem.remoteForeground": "#e7e7e7"
710
},
811
"editor.formatOnSave": true,
912
"editor.defaultFormatter": "esbenp.prettier-vscode",
@@ -29,5 +32,6 @@
2932
"uilang",
3033
"voca",
3134
"yagni"
32-
]
35+
],
36+
"peacock.color": "#549d3e"
3337
}

src/components/LanguageCard.tsx

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { css } from "@emotion/react";
22

33
import React from "react";
44
import { CheapCard } from "./CheapCard";
5-
import { ILanguage, getDisplayNamesForLanguage } from "../model/Language";
5+
import {
6+
ILanguage,
7+
getDisplayNamesForLanguage,
8+
kTagForNoLanguage,
9+
} from "../model/Language";
610
import { commonUI } from "../theme";
711
import { useResponsiveChoice } from "../responsiveUtilities";
812
import { FormattedMessage } from "react-intl";
@@ -43,13 +47,48 @@ export const LanguageCard: React.FunctionComponent<
4347
...propsToPassDown
4448
} = props; // Prevent React warnings
4549

46-
const { primary, secondary } = getDisplayNamesForLanguage(props);
50+
const displayNames = getDisplayNamesForLanguage(props);
4751
const getResponsiveChoice = useResponsiveChoice();
4852
const { cardWidthPx, cardHeightPx } = useLanguageCardSpec(props.larger);
4953
const urlPrefix = props.targetPrefix ?? "/language:";
5054
const showCount = !useIsAppHosted();
5155
const cardSpacing = useBaseCardSpec().cardSpacingPx;
5256

57+
const isPictureBook = isoCode === kTagForNoLanguage;
58+
59+
// BL-15812 Prefer the autonym as the primary label; fall back to existing display logic
60+
// for picture books or other special cases where autonym can be empty.
61+
const primary = isPictureBook
62+
? displayNames.primary
63+
: displayNames.autonym.trim()
64+
? displayNames.autonym
65+
: displayNames.primary;
66+
67+
// Build the gray header labels explicitly so English and the tag can be separate lines.
68+
const secondaryLinesToRender: string[] = [];
69+
if (isPictureBook) {
70+
// Preserve the historical duplication for picture-book cards.
71+
secondaryLinesToRender.push(displayNames.primary);
72+
} else {
73+
if (englishName && englishName !== primary) {
74+
secondaryLinesToRender.push(englishName);
75+
}
76+
// The logic that generates otherSecondaryNames makes sure it is not the same
77+
// as primary or english names. Currently, it will be the language tag if
78+
// getDisplayNamesForLanguage decides it adds something useful to the english name.
79+
if (displayNames.otherSecondaryNames) {
80+
secondaryLinesToRender.push(displayNames.otherSecondaryNames);
81+
}
82+
}
83+
const secondaryLineText = secondaryLinesToRender.join(" ");
84+
const hasMultipleSecondaryLines = secondaryLinesToRender.length > 1;
85+
// Only used for the single-line case, where we can allow two lines of wrap.
86+
const shouldTruncateSecondary = secondaryLineText.length >= 18;
87+
const [
88+
secondaryPrimaryLine,
89+
...secondaryRemainingLines
90+
] = secondaryLinesToRender;
91+
5392
// In the main website, we want language cards to be responsive: smaller and with smaller text on small screens.
5493
// In the language chooser intended to be embedded in BloomReader, we want larger sizes.
5594
// The description said "about a third larger" which happens to be, for most measurements, what the large-screen
@@ -119,12 +158,25 @@ export const LanguageCard: React.FunctionComponent<
119158
line-height: 1em;
120159
`}
121160
>
122-
<SmartTruncateMarkup
123-
condition={(secondary ?? "").length >= 18}
124-
lines={2}
125-
>
126-
<span>{secondary}</span>
127-
</SmartTruncateMarkup>
161+
{secondaryLinesToRender.length > 0 &&
162+
(hasMultipleSecondaryLines ? (
163+
<React.Fragment>
164+
{/* Clamp the first line so the tag line always stays visible. */}
165+
<SmartTruncateMarkup condition={true} lines={1}>
166+
<span>{secondaryPrimaryLine}</span>
167+
</SmartTruncateMarkup>
168+
{secondaryRemainingLines.map((line, index) => (
169+
<div key={`${line}-${index}`}>{line}</div>
170+
))}
171+
</React.Fragment>
172+
) : (
173+
<SmartTruncateMarkup
174+
condition={shouldTruncateSecondary}
175+
lines={2}
176+
>
177+
<span>{secondaryPrimaryLine}</span>
178+
</SmartTruncateMarkup>
179+
))}
128180
</div>
129181
</div>
130182
<h2

src/model/Language.ts

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,28 @@ export function getDisplayNamesForLanguage(
4747
primary: string;
4848
secondary: string | undefined;
4949
combined: string;
50+
autonym: string;
51+
otherSecondaryNames: string;
5052
} {
5153
// don't bother showing "zh-CN"... it's not a variant, it's the norm
5254
if (language.isoCode === "zh-CN") {
53-
return navigator.language === "zh-CN"
54-
? {
55-
secondary: "Chinese",
56-
primary: "简体中文",
57-
combined: "简体中文 (Chinese)",
58-
}
59-
: {
60-
primary: "Chinese",
61-
secondary: "简体中文",
62-
combined: "Chinese (简体中文)",
63-
};
55+
const result =
56+
navigator.language === "zh-CN"
57+
? {
58+
secondary: "Chinese",
59+
primary: "简体中文",
60+
combined: "简体中文 (Chinese)",
61+
}
62+
: {
63+
primary: "Chinese",
64+
secondary: "简体中文",
65+
combined: "Chinese (简体中文)",
66+
};
67+
return {
68+
...result,
69+
autonym: "简体中文",
70+
otherSecondaryNames: "",
71+
};
6472
}
6573

6674
// Handle picture books
@@ -73,12 +81,16 @@ export function getDisplayNamesForLanguage(
7381
primary: localizedLabel,
7482
secondary: localizedLabel,
7583
combined: localizedLabel,
84+
autonym: localizedLabel,
85+
// should never contain autonym or englishName. Currently holds the language
86+
// tag if it looks like a variant, otherwise empty.
87+
otherSecondaryNames: "",
7688
};
7789
}
7890

7991
// this may not be needed for long. We are working on some fixes in BL-11754
8092
if (language.isoCode === "ase-ML") {
81-
return navigator.language.startsWith("fr")
93+
const result = navigator.language.startsWith("fr")
8294
? {
8395
primary:
8496
"Langue des Signes des Écoles pour Déficients Auditifs au Mali",
@@ -95,6 +107,11 @@ export function getDisplayNamesForLanguage(
95107
combined:
96108
"Sign Language of Schools for the Hearing Impaired in Mali",
97109
};
110+
return {
111+
...result,
112+
autonym: language.name,
113+
otherSecondaryNames: "",
114+
};
98115
}
99116
let primary: string;
100117
let secondary: string | undefined;
@@ -114,18 +131,31 @@ export function getDisplayNamesForLanguage(
114131
primary = language.name;
115132
}
116133

117-
// if it looks like this is a variant, add that to the secondary
134+
// Determine if the tag should be included in secondary and otherSecondaryNames
135+
// We want to include tags that look like variants
136+
let otherSecondaryNames = "";
118137
if (
119138
language.isoCode &&
120139
language.isoCode.indexOf("-") > -1 &&
121140
language.isoCode !== language.englishName &&
122141
language.isoCode !== language.name
123-
)
124-
secondary = [secondary, language.isoCode].join(" ").trim();
142+
) {
143+
otherSecondaryNames = language.isoCode;
144+
}
145+
146+
if (otherSecondaryNames) {
147+
secondary = [secondary, otherSecondaryNames].join(" ").trim();
148+
}
125149

126150
const combined = primary + (secondary ? ` (${secondary})` : "");
127151

128-
return { primary, secondary, combined };
152+
return {
153+
primary,
154+
secondary,
155+
combined,
156+
autonym: language.name,
157+
otherSecondaryNames,
158+
};
129159
}
130160

131161
export function getCleanedAndOrderedLanguageList(

0 commit comments

Comments
 (0)