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

feat(i18n): add locales #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,25 @@ console.log(r1.formatNumber(Math.PI))
A renderer could produce any type of output, e.g. an image, a HTML formatted text, or render it on a canvas.

Many more usage examples can be found in `./test/*.spec.js`.


### Internationalization

The renderer can be configured to use a different locale, the locale is used to format dates.

The locale format follows ISO 639-1 standard language codes

```javascript
const {TextRenderer} = require('@datadocs/rose-formatter')

const r1 = new TextRenderer('dddd, dd of mmmm of yyyy', 'vi')
console.log(r1.formatDate(
new Date(2021, 7, 5, 14, 3, 9, 256)
))
```

```text
thứ 5, 05 of tháng 8 of 2021
```

List of supported locales can be found in `./src/locales.js`.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './parse-format'
export * from './text-renderer'
export * from './text-renderer'
export * from './locales'
Loading