-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transfer to TS and Functional - Localization (#3012)
- Loading branch information
1 parent
65a4845
commit 64cf90a
Showing
26 changed files
with
839 additions
and
230 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
115 changes: 115 additions & 0 deletions
115
JSDemos/Demos/Localization/UsingGlobalize/React/App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
/* eslint-disable import/no-webpack-loader-syntax */ | ||
import React from 'react'; | ||
import DataGrid, { Column, Editing, FilterRow } from 'devextreme-react/data-grid'; | ||
import SelectBox, { SelectBoxTypes } from 'devextreme-react/select-box'; | ||
|
||
import 'devextreme/localization/globalize/number'; | ||
import 'devextreme/localization/globalize/date'; | ||
import 'devextreme/localization/globalize/currency'; | ||
import 'devextreme/localization/globalize/message'; | ||
|
||
import deMessages from 'devextreme/localization/messages/de.json'; | ||
import ruMessages from 'devextreme/localization/messages/ru.json'; | ||
|
||
import deCldrData from 'devextreme-cldr-data/de.json'; | ||
import ruCldrData from 'devextreme-cldr-data/ru.json'; | ||
import supplementalCldrData from 'devextreme-cldr-data/supplemental.json'; | ||
|
||
import Globalize from 'globalize'; | ||
|
||
import service from './data.ts'; | ||
|
||
const editPopupOptions = { | ||
width: 700, | ||
height: 345, | ||
}; | ||
const amountEditorOptions = { | ||
format: 'currency', | ||
showClearButton: true, | ||
}; | ||
const selectBoxInputAttr = { id: 'selectInput' }; | ||
|
||
Globalize.load( | ||
deCldrData, | ||
ruCldrData, | ||
supplementalCldrData, | ||
); | ||
Globalize.loadMessages(deMessages); | ||
Globalize.loadMessages(ruMessages); | ||
Globalize.loadMessages(service.getDictionary()); | ||
Globalize.locale(sessionStorage.getItem('locale') || 'en'); | ||
|
||
const App = () => { | ||
const [locale, setLocale] = React.useState(sessionStorage.getItem('locale') || 'en'); | ||
const locales = service.getLocales(); | ||
const payments = service.getPayments(); | ||
|
||
const changeLocale = (e: SelectBoxTypes.ValueChangedEvent) => { | ||
setLocale(e.value); | ||
sessionStorage.setItem('locale', e.value); | ||
document.location.reload(); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<DataGrid | ||
dataSource={payments} | ||
keyExpr="PaymentId" | ||
> | ||
<Editing | ||
mode="popup" | ||
allowUpdating={true} | ||
popup={editPopupOptions} | ||
/> | ||
<FilterRow | ||
visible={true} | ||
applyFilter="auto" | ||
/> | ||
<Column | ||
dataField="PaymentId" | ||
caption={Globalize.formatMessage('Number')} | ||
allowEditing={false} | ||
width={100} | ||
/> | ||
<Column | ||
dataField="ContactName" | ||
caption={Globalize.formatMessage('Contact')} | ||
/> | ||
<Column | ||
dataField="CompanyName" | ||
caption={Globalize.formatMessage('Company')} | ||
/> | ||
<Column | ||
dataField="Amount" | ||
caption={Globalize.formatMessage('Amount')} | ||
dataType="number" | ||
format="currency" | ||
editorOptions={amountEditorOptions} | ||
/> | ||
<Column | ||
dataField="PaymentDate" | ||
caption={Globalize.formatMessage('PaymentDate')} | ||
dataType="date" | ||
/> | ||
</DataGrid> | ||
<div className="options"> | ||
<div className="caption">Options</div> | ||
<div className="option"> | ||
<label htmlFor="selectInput">Language</label> | ||
| ||
<SelectBox | ||
items={locales} | ||
valueExpr="Value" | ||
displayExpr="Name" | ||
value={locale} | ||
onValueChanged={changeLocale} | ||
inputAttr={selectBoxInputAttr} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ocalization/UsingGlobalize/React/index.js → ...calization/UsingGlobalize/React/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
JSDemos/Demos/Localization/UsingGlobalize/ReactJs/App.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
/* eslint-disable import/no-webpack-loader-syntax */ | ||
import React from 'react'; | ||
import DataGrid, { Column, Editing, FilterRow } from 'devextreme-react/data-grid'; | ||
import SelectBox from 'devextreme-react/select-box'; | ||
import 'devextreme/localization/globalize/number'; | ||
import 'devextreme/localization/globalize/date'; | ||
import 'devextreme/localization/globalize/currency'; | ||
import 'devextreme/localization/globalize/message'; | ||
import deMessages from 'devextreme/localization/messages/de.json'; | ||
import ruMessages from 'devextreme/localization/messages/ru.json'; | ||
import deCldrData from 'devextreme-cldr-data/de.json'; | ||
import ruCldrData from 'devextreme-cldr-data/ru.json'; | ||
import supplementalCldrData from 'devextreme-cldr-data/supplemental.json'; | ||
import Globalize from 'globalize'; | ||
import service from './data.js'; | ||
|
||
const editPopupOptions = { | ||
width: 700, | ||
height: 345, | ||
}; | ||
const amountEditorOptions = { | ||
format: 'currency', | ||
showClearButton: true, | ||
}; | ||
const selectBoxInputAttr = { id: 'selectInput' }; | ||
Globalize.load(deCldrData, ruCldrData, supplementalCldrData); | ||
Globalize.loadMessages(deMessages); | ||
Globalize.loadMessages(ruMessages); | ||
Globalize.loadMessages(service.getDictionary()); | ||
Globalize.locale(sessionStorage.getItem('locale') || 'en'); | ||
const App = () => { | ||
const [locale, setLocale] = React.useState(sessionStorage.getItem('locale') || 'en'); | ||
const locales = service.getLocales(); | ||
const payments = service.getPayments(); | ||
const changeLocale = (e) => { | ||
setLocale(e.value); | ||
sessionStorage.setItem('locale', e.value); | ||
document.location.reload(); | ||
}; | ||
return ( | ||
<div> | ||
<DataGrid | ||
dataSource={payments} | ||
keyExpr="PaymentId" | ||
> | ||
<Editing | ||
mode="popup" | ||
allowUpdating={true} | ||
popup={editPopupOptions} | ||
/> | ||
<FilterRow | ||
visible={true} | ||
applyFilter="auto" | ||
/> | ||
<Column | ||
dataField="PaymentId" | ||
caption={Globalize.formatMessage('Number')} | ||
allowEditing={false} | ||
width={100} | ||
/> | ||
<Column | ||
dataField="ContactName" | ||
caption={Globalize.formatMessage('Contact')} | ||
/> | ||
<Column | ||
dataField="CompanyName" | ||
caption={Globalize.formatMessage('Company')} | ||
/> | ||
<Column | ||
dataField="Amount" | ||
caption={Globalize.formatMessage('Amount')} | ||
dataType="number" | ||
format="currency" | ||
editorOptions={amountEditorOptions} | ||
/> | ||
<Column | ||
dataField="PaymentDate" | ||
caption={Globalize.formatMessage('PaymentDate')} | ||
dataType="date" | ||
/> | ||
</DataGrid> | ||
<div className="options"> | ||
<div className="caption">Options</div> | ||
<div className="option"> | ||
<label htmlFor="selectInput">Language</label> | ||
| ||
<SelectBox | ||
items={locales} | ||
valueExpr="Value" | ||
displayExpr="Name" | ||
value={locale} | ||
onValueChanged={changeLocale} | ||
inputAttr={selectBoxInputAttr} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default App; |
Oops, something went wrong.