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

121 - Add locale functionality and locale mixin #255

Merged
merged 24 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0aa83c0
Add locale support (initial with numbers and strings)
tmcconechy May 25, 2021
abb9f77
Merge branch 'main' of github.com:infor-design/enterprise-wc into 503…
tmcconechy May 25, 2021
699cabf
Merge branch 'main' of github.com:infor-design/enterprise-wc into 503…
tmcconechy Jun 24, 2021
39e1e77
Added more fixes after a merge
tmcconechy Jun 24, 2021
5a36974
Add fixes after the merge to get it back running
tmcconechy Jun 24, 2021
0a19149
Sync translations and move some months and days for en and es
tmcconechy Jun 24, 2021
884ae98
Add format and parse date
tmcconechy Jun 24, 2021
1ba1363
Sync more features and tests
tmcconechy Jul 1, 2021
d45a99d
Add more fixes for dates and completed all tests converstin
tmcconechy Jul 6, 2021
6ef0ae9
Merge main on
tmcconechy Jul 6, 2021
7e84408
Merge branch 'main' of github.com:infor-design/enterprise-wc into 503…
tmcconechy Jul 6, 2021
41eee29
Add more tests and fixes and RTL examples
tmcconechy Jul 12, 2021
6116e9b
Correct spacing
tmcconechy Jul 12, 2021
9745d4e
Merge branch 'main' of github.com:infor-design/enterprise-wc into 503…
tmcconechy Jul 12, 2021
20c5964
Add more tests and small fixes
tmcconechy Jul 13, 2021
3e9184d
Add test coverage
tmcconechy Jul 14, 2021
3729480
Add test coverage
tmcconechy Jul 14, 2021
7a31719
Merge branch 'main' of github.com:infor-design/enterprise-wc into 503…
tmcconechy Jul 14, 2021
c13c38e
Add more todos
tmcconechy Jul 14, 2021
e69e606
Run in NY timezone
tmcconechy Jul 14, 2021
32cfc58
Fix spinbox test
tmcconechy Jul 14, 2021
16c5463
Merge branch 'main' into 5037-locale
tmcconechy Jul 16, 2021
2060934
Add fixes for PR comment
tmcconechy Jul 19, 2021
219af16
Merge branch 'main' into 5037-locale
tmcconechy Jul 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
env: {
browser: true,
es6: true // All source code is at least ES6 friendly
es2020: true,
browser: true
},
extends: [
// Import some AirBNB rules and some web component and jsdoc rules
Expand Down Expand Up @@ -79,7 +79,7 @@ module.exports = {
// Allow Arrow functions to be on the next line or below
'no-useless-constructor': ['off', { }],
// Allow assignment of properties from items in `forEach` loops
'no-param-reassign': ['error', { props: false }],
'no-param-reassign': ['off', { props: false }],
// Allow hasOwnProperty
'no-prototype-builtins': ['off', { }],
// Allow functions with no this in them
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "America/New_York"
timezoneMacos: "America/New_York"
timezoneWindows: "America/New_York"

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
Expand Down
34 changes: 26 additions & 8 deletions app/data/books.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"methodSwitch": "Yes",
"trackDeprecationHistory": "Yes",
"useForEmployee": "No",
"deprecationHistory": "Asset Label"
"deprecationHistory": "Asset Label",
"publishDate": "2021-04-23T18:25:43.511Z",
"price": "12.99",
"location": "United States"
},
{
"book": 102,
Expand All @@ -24,7 +27,10 @@
"methodSwitch": "No",
"trackDeprecationHistory": "No",
"useForEmployee": "No",
"deprecationHistory": "Asset Label"
"deprecationHistory": "Asset Label",
"publishDate": "2021-02-23T18:25:43.511Z",
"price": "13.99",
"location": "Canada"
},
{
"book": 103,
Expand All @@ -37,7 +43,9 @@
"methodSwitch": "Yes",
"trackDeprecationHistory": "No",
"useForEmployee": "Yes",
"deprecationHistory": "Asset Label"
"deprecationHistory": "Asset Label",
"publishDate": "2021-12-23T18:25:43.511Z",
"location": "United States"
},
{
"book": 104,
Expand All @@ -51,7 +59,8 @@
"methodSwitch": "No",
"trackDeprecationHistory": "No",
"useForEmployee": "No",
"deprecationHistory": "Asset Label"
"deprecationHistory": "Asset Label",
"location": "Canada"
},
{
"book": 105,
Expand All @@ -65,7 +74,10 @@
"methodSwitch": "Yes",
"trackDeprecationHistory": "No",
"useForEmployee": "Yes",
"deprecationHistory": "Asset Label"
"deprecationHistory": "Asset Label",
"publishDate": "2021-12-12T18:25:43.511Z",
"price": "15.99",
"location": "United States"
},
{
"book": 106,
Expand Down Expand Up @@ -93,7 +105,8 @@
"methodSwitch": "No",
"trackDeprecationHistory": "No",
"useForEmployee": "No",
"deprecationHistory": "Asset Label"
"deprecationHistory": "Asset Label",
"location": "Canada"
},
{
"book": 108,
Expand All @@ -107,7 +120,9 @@
"methodSwitch": "No",
"trackDeprecationHistory": "Yes",
"useForEmployee": "Yes",
"deprecationHistory": "Asset Label"
"deprecationHistory": "Asset Label",
"publishDate": "2020-12-12T18:25:43.511Z",
"price": "15.50"
},
{
"book": 109,
Expand All @@ -121,6 +136,9 @@
"methodSwitch": "Yes",
"trackDeprecationHistory": "No",
"useForEmployee": "No",
"deprecationHistory": "Asset Label"
"deprecationHistory": "Asset Label",
"publishDate": "2019-12-12T18:25:43.511Z",
"price": "29.48",
"location": "United States"
}
]
2 changes: 2 additions & 0 deletions app/ids-container/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{> ../layouts/head.html }}
{{> ../layouts/footer.html }}
1 change: 1 addition & 0 deletions app/ids-container/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import IdsContainer from '../../src/ids-container/ids-container';
235 changes: 137 additions & 98 deletions app/ids-data-grid/example.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,143 @@
// Example for populating the DataGrid
const dataGrid = document.querySelector('#data-grid-1');
const container = document.querySelector('ids-container');

// Do an ajax request
const xmlhttp = new XMLHttpRequest();
const url = '/api/books';
const columns = [];
(async function init() {
// Set Locale and wait for it to load
await container.setLocale('en-US');

// Set up columns
columns.push({
id: 'selectionCheckbox',
sortable: false,
resizable: false,
formatter: dataGrid.formatters.text,
align: 'center',
width: 20
});
columns.push({
id: 'book',
name: 'Book',
field: 'book',
formatter: dataGrid.formatters.text,
sortable: true,
width: 65
});
columns.push({
id: 'description',
name: 'Description',
field: 'description',
sortable: true,
formatter: dataGrid.formatters.text
});
columns.push({
id: 'ledger',
name: 'Ledger',
field: 'ledger',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'bookCurrency',
name: 'Book Currency',
field: 'bookCurrency',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'transactionCurrency',
name: 'Transaction Currency',
field: 'transactionCurrency',
formatter: dataGrid.formatters.text,
});
columns.push({
id: 'postHistory',
name: 'Post History',
field: 'postHistory',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'active',
name: 'Active',
field: 'active',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'convention',
name: 'Convention',
field: 'convention',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'methodSwitch',
name: 'Method Switch',
field: 'methodSwitch',
formatter: dataGrid.formatters.text,
filterType: 'select'
});
columns.push({
id: 'trackDeprecationHistory',
name: 'Track Deprecation History',
field: 'trackDeprecationHistory',
formatter: dataGrid.formatters.dropdown
});
columns.push({
id: 'useForEmployee',
name: 'Use For Employee',
field: 'useForEmployee',
formatter: dataGrid.formatters.dropdown
});
columns.push({
id: 'deprecationHistory',
name: 'Deprecation History',
field: 'deprecationHistory',
formatter: dataGrid.formatters.dropdown
});
// Do an ajax request
const xmlhttp = new XMLHttpRequest();
const url = '/api/books';
const columns = [];

xmlhttp.onreadystatechange = function onreadystatechange() {
if (this.readyState === 4 && this.status === 200) {
dataGrid.data = JSON.parse(this.responseText);
dataGrid.columns = columns;
}
};
// Set up columns
columns.push({
id: 'selectionCheckbox',
sortable: false,
resizable: false,
formatter: dataGrid.formatters.text,
align: 'center',
width: 20
});
columns.push({
id: 'rowNumber',
name: '#',
formatter: dataGrid.formatters.rowNumber,
sortable: false,
readonly: true,
width: 65
});
columns.push({
id: 'description',
name: 'Description',
field: 'description',
sortable: true,
formatter: dataGrid.formatters.text
});
columns.push({
id: 'ledger',
name: 'Ledger',
field: 'ledger',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'publishDate',
name: 'Pub. Date',
field: 'publishDate',
formatter: dataGrid.formatters.date
});
columns.push({
id: 'publishTime',
name: 'Pub. Time',
field: 'publishDate',
formatter: dataGrid.formatters.time
});
columns.push({
id: 'price',
name: 'Price',
field: 'price',
formatter: dataGrid.formatters.decimal,
formatOptions: { locale: 'en-US' } // Data Values are in en-US
});
columns.push({
id: 'bookCurrency',
name: 'Currency',
field: 'bookCurrency',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'transactionCurrency',
name: 'Transaction Currency',
field: 'transactionCurrency',
formatter: dataGrid.formatters.text,
});
columns.push({
id: 'integer',
name: 'Price (Int)',
field: 'price',
formatter: dataGrid.formatters.integer,
formatOptions: { locale: 'en-US' } // Data Values are in en-US
});
columns.push({
id: 'location',
name: 'Location',
field: 'location',
formatter: dataGrid.formatters.hyperlink,
href: '#'
});
columns.push({
id: 'postHistory',
name: 'Post History',
field: 'postHistory',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'active',
name: 'Active',
field: 'active',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'convention',
name: 'Convention',
field: 'convention',
formatter: dataGrid.formatters.text
});
columns.push({
id: 'methodSwitch',
name: 'Method Switch',
field: 'methodSwitch',
formatter: dataGrid.formatters.text,
filterType: 'select'
});
columns.push({
id: 'trackDeprecationHistory',
name: 'Track Deprecation History',
field: 'trackDeprecationHistory',
formatter: dataGrid.formatters.dropdown
});
columns.push({
id: 'useForEmployee',
name: 'Use For Employee',
field: 'useForEmployee',
formatter: dataGrid.formatters.password
});
columns.push({
id: 'deprecationHistory',
name: 'Deprecation History',
field: 'deprecationHistory',
formatter: dataGrid.formatters.text
});

// Execute the request
xmlhttp.open('GET', url, true);
xmlhttp.send();
xmlhttp.onreadystatechange = function onreadystatechange() {
if (this.readyState === 4 && this.status === 200) {
dataGrid.columns = columns;
dataGrid.data = JSON.parse(this.responseText);
}
};

// Execute the request
xmlhttp.open('GET', url, true);
xmlhttp.send();
}());
5 changes: 5 additions & 0 deletions app/ids-locale/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ids-layout-grid>
<ids-text font-size="12" type="h1">Locale (Translated Strings)</ids-text>
<ids-layout-grid cols="4" gap="sm" id="translation-container">
</ids-layout-grid>
</ids-layout-grid>
22 changes: 22 additions & 0 deletions app/ids-locale/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Use the container to set the language
const container = document.querySelector('ids-container');

// Asyncronously load a language and display the strings
(async function loadMessages() {
let html = '';
// Set language and wait for it to load
const initialLocale = 'zh';
await container.setLanguage(initialLocale);

// Show them in the page
const keys = Object.keys(container.language.messages);
for (let i = 0; i < keys.length; i++) {
html += `<ids-layout-grid-cell col-span="1">
<ids-text font-weight="bold">${keys[i]}</ids-text>
</ids-layout-grid-cell>
<ids-layout-grid-cell col-span="3">
<ids-text translate-text="true" language="${initialLocale}">${keys[i]}</ids-text>
</ids-layout-grid-cell>`;
}
document.querySelector('#translation-container').innerHTML = html;
}());
Loading