Skip to content

Commit 6ea745f

Browse files
authored
Merge pull request #5 from patternfly/remove-i18n
Cleanup for OS
2 parents 706a766 + eaaba5e commit 6ea745f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+731
-466
lines changed

packages/dev/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@
99
"serve": "serve public"
1010
},
1111
"dependencies": {
12-
"@patternfly/quickstarts": "1.0.0-rc.8",
12+
"@patternfly/quickstarts": "1.0.0-rc.9",
1313
"@patternfly/react-core": "^4.101.3",
1414
"asciidoctor": "^2.2.1",
1515
"react": "^16.14.0",
1616
"react-dom": "^16.14.0",
17-
"react-router-dom": "^5.2.0"
17+
"react-router-dom": "^5.2.0",
18+
"i18next": "^19.8.3",
19+
"i18next-browser-languagedetector": "^6.0.1",
20+
"i18next-parser": "^3.3.0",
21+
"i18next-pseudo": "^2.2.0",
22+
"react-i18next": "^11.7.3",
23+
"showdown": "1.8.6"
1824
},
1925
"devDependencies": {
2026
"@types/react": "^16.8.0",

packages/dev/src/App.tsx

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ import Demos from "./Demos";
1717
import "./App.css";
1818
import {
1919
QuickStartDrawer,
20-
QuickStartContext,
21-
useValuesForQuickStartContext,
2220
useLocalStorage,
21+
QuickStartContextProvider,
22+
QuickStartContextValues,
23+
LoadingBox
2324
} from "@patternfly/quickstarts";
2425
import { allQuickStarts as yamlQuickStarts } from "./quickstarts-data/quick-start-test-data";
2526
import { loadJSONQuickStarts } from "./quickstarts-data/mas-guides/quickstartLoader";
27+
import i18n from './i18n/i18n';
2628

2729
type AppProps = {
2830
children?: React.ReactNode;
@@ -64,22 +66,6 @@ const App: React.FC<AppProps> = ({ children, showCardFooters }) => {
6466
load();
6567
}, []);
6668

67-
const { pathname: currentPath } = window.location;
68-
const quickStartPath = "/quickstarts";
69-
70-
const valuesForQuickstartContext = useValuesForQuickStartContext({
71-
allQuickStarts,
72-
activeQuickStartID,
73-
setActiveQuickStartID,
74-
allQuickStartStates,
75-
setAllQuickStartStates,
76-
footer: {
77-
show: showCardFooters,
78-
showAllLink: currentPath !== quickStartPath,
79-
onShowAllLinkClick: () => history.push(quickStartPath),
80-
},
81-
});
82-
8369
if (!initialized) return <div>Loading</div>;
8470

8571
const AppToolbar = (
@@ -117,16 +103,40 @@ const App: React.FC<AppProps> = ({ children, showCardFooters }) => {
117103

118104
const AppSidebar = <PageSidebar isNavOpen nav={AppNav} />;
119105

106+
const { pathname: currentPath } = window.location;
107+
const quickStartPath = "/quickstarts";
108+
109+
const resourceBundle = i18n.getResourceBundle(localStorage.getItem('bridge/language'), 'quickstart');
110+
111+
const valuesForQuickstartContext: QuickStartContextValues = {
112+
allQuickStarts,
113+
activeQuickStartID,
114+
setActiveQuickStartID,
115+
allQuickStartStates,
116+
setAllQuickStartStates,
117+
footer: {
118+
show: showCardFooters,
119+
showAllLink: currentPath !== quickStartPath,
120+
onShowAllLinkClick: () => history.push(quickStartPath),
121+
},
122+
lng: localStorage.getItem('bridge/language'),
123+
resourceBundle: {
124+
...resourceBundle,
125+
"Start": "Let's goooo"
126+
},
127+
useQueryParams: false
128+
};
129+
120130
return (
121-
<React.Suspense fallback={<div>Loading</div>}>
131+
<React.Suspense fallback={<LoadingBox />}>
122132
{allQuickStartsLoaded && (
123-
<QuickStartContext.Provider value={valuesForQuickstartContext}>
133+
<QuickStartContextProvider value={valuesForQuickstartContext}>
124134
<QuickStartDrawer>
125-
<Page header={AppHeader} sidebar={AppSidebar} isManagedSidebar>
135+
<Page header={AppHeader} sidebar={AppSidebar} isManagedSidebar>
126136
{children}
127-
</Page>
128-
</QuickStartDrawer>
129-
</QuickStartContext.Provider>
137+
</Page>
138+
</QuickStartDrawer>
139+
</QuickStartContextProvider>
130140
)}
131141
</React.Suspense>
132142
);

packages/dev/src/CustomCatalog.tsx

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,23 @@ import {
1212
QUICKSTART_SEARCH_FILTER_KEY,
1313
QUICKSTART_STATUS_FILTER_KEY,
1414
QuickStartCatalogFilterSearchWrapper,
15-
QuickStartCatalogFilterStatusWrapper,
1615
QuickStartCatalogFilterCountWrapper,
1716
clearQuickStartFilters,
1817
QuickStartCatalogHeader,
1918
QuickStartCatalogToolbar,
2019
QuickStartCatalogSection,
2120
} from '@patternfly/quickstarts';
2221
import {
23-
PageSection,
24-
PageSectionVariants,
2522
TextContent,
2623
Text,
2724
Divider,
2825
Gallery,
2926
GalleryItem,
30-
Toolbar,
3127
ToolbarContent,
3228
} from '@patternfly/react-core';
3329

34-
type CustomCatalogProps = {
35-
quickStarts: QuickStart[];
36-
};
37-
38-
export const CustomCatalog: React.FC<CustomCatalogProps> = ({ quickStarts }) => {
39-
const { activeQuickStartID, allQuickStartStates } = React.useContext<QuickStartContextValues>(
30+
export const CustomCatalog: React.FC = () => {
31+
const { activeQuickStartID, allQuickStartStates, allQuickStarts } = React.useContext<QuickStartContextValues>(
4032
QuickStartContext,
4133
);
4234

@@ -50,7 +42,7 @@ export const CustomCatalog: React.FC<CustomCatalogProps> = ({ quickStarts }) =>
5042
const sortFnc = (q1: QuickStart, q2: QuickStart) =>
5143
q1.spec.displayName.localeCompare(q2.spec.displayName);
5244
const initialFilteredQuickStarts = filterQuickStarts(
53-
quickStarts,
45+
allQuickStarts,
5446
initialSearchQuery,
5547
initialStatusFilters,
5648
allQuickStartStates,
@@ -60,12 +52,12 @@ export const CustomCatalog: React.FC<CustomCatalogProps> = ({ quickStarts }) =>
6052
);
6153

6254
const quickStartStatusCount = React.useMemo(
63-
() => getQuickStartStatusCount(allQuickStartStates, quickStarts),
64-
[allQuickStartStates, quickStarts],
55+
() => getQuickStartStatusCount(allQuickStartStates, allQuickStarts),
56+
[allQuickStartStates, allQuickStarts],
6557
);
6658
const onSearchInputChange = (searchValue: string) => {
6759
const result = filterQuickStarts(
68-
quickStarts,
60+
allQuickStarts,
6961
searchValue,
7062
statusFilters,
7163
allQuickStartStates,
@@ -75,7 +67,7 @@ export const CustomCatalog: React.FC<CustomCatalogProps> = ({ quickStarts }) =>
7567
};
7668
const onStatusChange = (statusList: string[]) => {
7769
const result = filterQuickStarts(
78-
quickStarts,
70+
allQuickStarts,
7971
searchInputText,
8072
statusList,
8173
allQuickStartStates,
@@ -92,7 +84,7 @@ export const CustomCatalog: React.FC<CustomCatalogProps> = ({ quickStarts }) =>
9284
<Text component="p">Step-by-step instructions and tasks</Text>
9385
</TextContent>
9486
<Gallery className="co-quick-start-catalog__gallery" hasGutter>
95-
{quickStarts
87+
{allQuickStarts
9688
.filter(
9789
(quickStart) =>
9890
!quickStart.spec.type || quickStart.spec.type.text !== 'Documentation',
@@ -123,7 +115,7 @@ export const CustomCatalog: React.FC<CustomCatalogProps> = ({ quickStarts }) =>
123115
<Text component="p">Technical information for using the service</Text>
124116
</TextContent>
125117
<Gallery className="co-quick-start-catalog__gallery" hasGutter>
126-
{quickStarts
118+
{allQuickStarts
127119
.filter((quickStart) => quickStart.spec.type?.text === 'Documentation')
128120
.map((quickStart) => {
129121
const {
@@ -148,7 +140,7 @@ export const CustomCatalog: React.FC<CustomCatalogProps> = ({ quickStarts }) =>
148140
const clearFilters = () => {
149141
clearQuickStartFilters();
150142
setFilteredQuickStarts(
151-
quickStarts.sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName)),
143+
allQuickStarts.sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName)),
152144
);
153145
};
154146

@@ -169,7 +161,7 @@ export const CustomCatalog: React.FC<CustomCatalogProps> = ({ quickStarts }) =>
169161
<Divider component="div" />
170162
{filteredQuickStarts.length === 0 ? (
171163
<QuickStartCatalogEmptyState clearFilters={clearFilters} />
172-
) : filteredQuickStarts.length !== quickStarts.length ? (
164+
) : filteredQuickStarts.length !== allQuickStarts.length ? (
173165
<QuickStartCatalogSection>
174166
<QuickStartCatalog quickStarts={filteredQuickStarts} />
175167
</QuickStartCatalogSection>

packages/dev/src/Home.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from "react";
22
import { Button, PageSection, Stack, StackItem } from "@patternfly/react-core";
33
import {
4-
QuickStartContext,
5-
QuickStartContextValues,
6-
i18n,
4+
QuickStartContext
75
} from "@patternfly/quickstarts";
6+
import i18n from './i18n/i18n';
87
// import {
98
// ProcedureAsciiDocParser,
109
// getQuickStartStatus,
@@ -15,7 +14,7 @@ import {
1514

1615
export const Home: React.FunctionComponent = () => {
1716
// const [inputValue, setInputValue] = React.useState("");
18-
// const qsContext: QuickStartContextValues = React.useContext(QuickStartContext);
17+
const { setLng, setResourceBundle } = React.useContext(QuickStartContext);
1918

2019
// console.log(getQuickStartStatus(qsContext.allQuickStartStates, 'managing-business-central-data-sources-proc'));
2120
// console.log(getQuickStartStatusCount(qsContext.allQuickStartStates, qsContext.allQuickStarts));
@@ -48,8 +47,11 @@ export const Home: React.FunctionComponent = () => {
4847
// };
4948

5049
const changeLanguage = (lng: string) => {
51-
i18n.changeLanguage(lng)
50+
i18n.changeLanguage(lng);
5251
localStorage.setItem('bridge/language', lng);
52+
const resourceBundle = i18n.getResourceBundle(lng, 'quickstart');
53+
setLng(lng);
54+
setResourceBundle(resourceBundle);
5355
}
5456

5557
return (

packages/dev/src/index.tsx

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import "@patternfly/quickstarts/dist/quickstarts.css";
66
import React from "react";
77
import ReactDOM from "react-dom";
88
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
9+
import './i18n/i18n';
910
import App from "./App";
1011
import {
11-
QuickStartsLoader,
1212
QuickStartCatalogPage,
1313
QuickStart,
1414
LoadingBox,
@@ -26,32 +26,15 @@ ReactDOM.render(
2626
</Route>
2727
<Route exact path="/quickstarts">
2828
<App showCardFooters={false}>
29-
<QuickStartsLoader>
30-
{(quickStarts: QuickStart[], loaded: boolean) =>
31-
loaded ? (
32-
<QuickStartCatalogPage
33-
quickStarts={quickStarts}
34-
showFilter
35-
hint="Learn how to create, import, and run applications with step-by-step instructions and tasks."
36-
/>
37-
) : (
38-
<LoadingBox />
39-
)
40-
}
41-
</QuickStartsLoader>
29+
<QuickStartCatalogPage
30+
showFilter
31+
hint="Learn how to create, import, and run applications with step-by-step instructions and tasks."
32+
/>
4233
</App>
4334
</Route>
4435
<Route exact path="/custom-catalog">
4536
<App showCardFooters>
46-
<QuickStartsLoader>
47-
{(quickStarts: QuickStart[], loaded: boolean) =>
48-
loaded ? (
49-
<CustomCatalog quickStarts={quickStarts} />
50-
) : (
51-
<LoadingBox />
52-
)
53-
}
54-
</QuickStartsLoader>
37+
<CustomCatalog />
5538
</App>
5639
</Route>
5740
</Switch>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"No results found": "No results found",
3+
"No results match the filter criteria. Remove filters or clear all filters to show results.": "No results match the filter criteria. Remove filters or clear all filters to show results.",
4+
"Clear all filters": "Clear all filters",
5+
"Quick Starts": "Quick Starts",
6+
"Complete ({{statusCount, number}})": "Complete ({{statusCount, number}})",
7+
"In progress ({{statusCount, number}})": "In progress ({{statusCount, number}})",
8+
"Not started ({{statusCount, number}})": "Not started ({{statusCount, number}})",
9+
"Filter by keyword...": "Filter by keyword...",
10+
"Select filter": "Select filter",
11+
"Status": "Status",
12+
"{{count, number}} item": "{{count, number}} item",
13+
"{{count, number}} item_plural": "{{count, number}} items",
14+
"Prerequisites ({{totalPrereqs}})": "Prerequisites ({{totalPrereqs}})",
15+
"Prerequisites": "Prerequisites",
16+
"Complete": "Complete",
17+
"In progress": "In progress",
18+
"Not started": "Not started",
19+
"{{duration, number}} minutes": "{{duration, number}} minutes",
20+
"One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.": "One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.",
21+
"Start {{nextQSDisplayName}} quick start": "Start {{nextQSDisplayName}} quick start",
22+
"Start": "Start",
23+
"Continue": "Continue",
24+
"Next": "Next",
25+
"Close": "Close",
26+
"Back": "Back",
27+
"Restart": "Restart",
28+
"In this quick start, you will complete {{count, number}} task": "In this quick start, you will complete {{count, number}} task",
29+
"In this quick start, you will complete {{count, number}} task_plural": "In this quick start, you will complete {{count, number}} tasks",
30+
"{{taskIndex, number}}": "{{taskIndex, number}}",
31+
"Check your work": "Check your work",
32+
"Yes": "Yes",
33+
"No": "No",
34+
"{{index, number}} of {{tasks, number}}": "{{index, number}} of {{tasks, number}}",
35+
"Leave quick start?": "Leave quick start?",
36+
"Cancel": "Cancel",
37+
"Leave": "Leave",
38+
"Your progress will be saved.": "Your progress will be saved.",
39+
"Not available": "Not available",
40+
"No {{label}} found": "No {{label}} found",
41+
"Not found": "Not found"
42+
}

packages/module/src/locales/ja/quickstart.json renamed to packages/dev/src/locales/ja/quickstart.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646
"Any progress you've made will be saved.": "進行状況はすべて保存されます。",
4747
"In Progress": "進行中",
4848
"Start Tour": "ツアーを開始する"
49-
}
49+
}
File renamed without changes.

0 commit comments

Comments
 (0)