Skip to content

Commit

Permalink
fix: Revert "add ability to localize common characters (#208)" (#211)
Browse files Browse the repository at this point in the history
This reverts commit 61b0161.
  • Loading branch information
dlockhart authored Nov 18, 2024
1 parent 6fdd827 commit 44d0587
Show file tree
Hide file tree
Showing 25 changed files with 10 additions and 434 deletions.
6 changes: 0 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,5 @@
"rules": {
"no-console": 0
}
},
{
"files": "./lang/*.js",
"rules": {
"quotes": 0
}
}]
}
52 changes: 7 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Overview

This library consists of APIs to format and parse numbers, dates, times and file sizes for use in D2L Brightspace. It also provides localization for common terms.
This library consists of APIs to format and parse numbers, dates, times and file sizes for use in D2L Brightspace.

> Looking for the older `d2l-intl` library? It's still here [in the `v2.x` branch](https://github.com/BrightspaceUI/intl/tree/v2.x).
Expand All @@ -28,9 +28,7 @@ import { formatNumber, formatPercent } from '@brightspace-ui/intl/lib/number.js'

All of the APIs will automatically detect the document's language via the `lang` attribute on the `<html>` element. They'll also look for various `data-` attributes that will be present in Brightspace pages to access override and timezone information.

## Numbers

### Number Formatting
## Number Formatting

Integer and decimal numbers can be formatted in the user's locale using `formatNumber`. Percentages can be formatted using `formatPercent`. Use the optional `options` parameter for rounding.

Expand Down Expand Up @@ -67,7 +65,7 @@ const value = formatPercent(0.333, {
}); // -> '33.30 %' in en-US
```

### Number Parsing
## Number Parsing

The `parseNumber` method can be used to parse an integer or decimal number written in the user's locale.

Expand All @@ -77,9 +75,7 @@ import { parseNumber } from '@brightspace-ui/intl/lib/number.js';
const value = parseNumber('-8 942,39'); // -> -8942.39 in fr-CA
```

## Dates & Times

### Date & Time Formatting
## Date/Time Formatting

Dates and times can be formatted in the user's locale using `formatDate`, `formatTime`, `formatDateTime`, and `formatRelativeDateTime`.

Expand Down Expand Up @@ -187,7 +183,7 @@ const relativeDateTime = formatRelativeDateTime(
); // If today is 2024-08-22, -> 'last week' in en-US
```

### Date Parsing
## Date Parsing

To parse a date written in the user's locale, use `parseDate`:

Expand All @@ -200,7 +196,7 @@ date.getMonth(); // -> 8 (months are 0-11)
date.getDate(); // -> 23
```

### Time Parsing
## Time Parsing

To parse a time written in the user's locale, use `parseTime`:

Expand All @@ -212,7 +208,7 @@ date.getHours(); // -> 14
date.getMinutes(); // -> 5
```

### Date/Time Conversion based on user timezone
## Date/Time Conversion based on user timezone

To convert an object containing a UTC date to an object containing a local date corresponding to the `data-timezone` attribute:
```javascript
Expand Down Expand Up @@ -376,41 +372,7 @@ In addition to the Basic Formatting elements, these additional elements may also
* `<d2l-link>`
* `<d2l-tooltip-help>`

### Common Resources

Some localization resources are common and shared across D2L applications. To use these resources, set the `loadCommon` option:

```javascript
import { Localize } from '@brightspace-ui/intl/lib/localize.js';

const localizer = new Localize({
loadCommon: true
});
```

#### localizeCharacter

The localized value of the following characters can be accessed using `localizeCharacter(char)`:
* `'` (apostrophe)
* `&` (ampersand)
* `*` (asterisk)
* `\` (backslash)
* `:` (colon)
* `,` (comma)
* `>` (greater-than sign)
* `<` (less-than sign)
* `#` (number sign)
* `%` (percent sign)
* `|` (pipe)
* `?` (question mark)
* `"` (quotation mark)

```javascript
const value = localizer.localizeCharacter('&'); // -> 'ampersand' in en-US
```

### `onResourcesChange`

Provide an `onResourcesChange` callback function to perform tasks when the document language is changed and updated resources are available:

```javascript
Expand Down
9 changes: 0 additions & 9 deletions intl.serge.json

This file was deleted.

15 changes: 0 additions & 15 deletions lang/ar.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/cy.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/da.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/de.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/en-gb.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/en.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/es-es.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/es.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/fr-fr.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/fr.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/hi.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/ja.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/ko.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/nl.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/pt.js

This file was deleted.

15 changes: 0 additions & 15 deletions lang/sv.js

This file was deleted.

Loading

0 comments on commit 44d0587

Please sign in to comment.