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

Conversation

lnquy065
Copy link

@lnquy065 lnquy065 commented Jun 6, 2023

Hi, thank you for an awesome library.

Changes

This PR allows users to change the locale:

Here is an example:

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)
))
  • By default, the second parameter of TextRenderer will be 'en-us'.
  • The locale format follows ISO 639-1 standard language codes.

Testing

  • Added test/i18n.spec.js

Supported languages

  • List of supported locales can be found in ./src/locales.js.

Note

I'm not sure if this PR affects performance, we can consider separating locales from the main package and letting users import them themselves.🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant