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[ATLAS-113]: add locale apis in core module #62
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: b5e1eb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Bundle Size Report
|
🟢 No Change | 🗑 File Deleted | 🆕 New File | 📈 Size Increased | 👍 Size Reduced |
---|
Parsed (kb) | |||||
---|---|---|---|---|---|
🚦 | File Name | Base | PR | Diff | % |
📈 | cjs/index.js |
160.1 |
168.14 |
|
5.02 |
📈 | esm/index.min.js |
50.96 |
54.53 |
|
7.01 |
📈 | umd/index.js |
176.26 |
185.19 |
|
5.07 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #62 +/- ##
==========================================
+ Coverage 95.00% 95.39% +0.38%
==========================================
Files 44 49 +5
Lines 501 543 +42
Branches 128 133 +5
==========================================
+ Hits 476 518 +42
Misses 24 24
Partials 1 1 ☔ View full report in Codecov by Sentry. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
.changeset/silver-zoos-raise.md
Outdated
@@ -0,0 +1,5 @@ | |||
--- | |||
"@razorpay/i18nify-js": patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be minor.
packages/i18nify-js/README.md
Outdated
|
||
#### getDefaultLocaleByCountry(countryCode) | ||
|
||
📌 Pinpoint Precision. When precision matters, getDefaultLocaleByCountry is your meticulous matchmaker, pairing country codes with their default locales. This function is like having a linguistic concierge for each country, ensuring you deliver the right cultural context straight out of the box. From the bustling streets of Tokyo to the serene fjords of Norway, setting the scene for your users has never been more accurate. 🎯✨ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this more crips and technical.
packages/i18nify-js/README.md
Outdated
|
||
// Reset everything! | ||
resetState(); | ||
``` | ||
|
||
#### getAllLocales() | ||
|
||
🌍 The Global Gathering. Dive into the diversity of our planet with getAllLocales! This function is your atlas, mapping out a rich array of locales for each country. With a simple call, embark on a journey through countries and their multiple locales, from the peaks of Peru to the sands of Saudi Arabia. Whether it's for localization, cultural exploration, or linguistic curiosity, getAllLocales is your ticket to a world tour of languages! 🗺️✨ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more crips and technical.
@@ -0,0 +1,98 @@ | |||
// A map of countries to their default locale. | |||
export const COUNTRY_TO_DEFAULT_LOCALES = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to have another config, utilise COUNTRY_TO_ALL_LOCALES
and keep the default locale at 0th index for all countries. Create the config dynamically from there.
* @returns A map where the key is the country code and the value is an array of locale strings. | ||
*/ | ||
const getAllLocales = (): typeof COUNTRY_TO_ALL_LOCALES => { | ||
return COUNTRY_TO_ALL_LOCALES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to dynamically import this.
* @returns The default locale string for the given country. | ||
* @throws An error if the provided country code does not exist in the map. | ||
*/ | ||
const getDefaultLocaleByCountry = (countryCode: keyof typeof COUNTRY_TO_DEFAULT_LOCALES): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dynamic import.
|
||
``` | ||
import { setState } from "@razorpay/i18nify-js/core"; | ||
##### Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can include 1 more API.. getLocale
which detects locale from browser and returns it. This can be a sync utility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have this utility in .internal
. Reusing that.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Unit Test Results0 files 0 suites 0s ⏱️ Results for commit b5e1eb1. |
Description
This PR adds locale apis in
core
module. Below are the details:Changes Made
List the main changes made in this pull request.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Additional Notes
Any additional information that would be helpful for the reviewer.
Checklist:
Reviewer Checklist
PR Title Format
Format:
<type>: <subject>
Types can be as follows:
feat
: (new feature for the user, not a new feature for build script)fix
: (bug fix for the user, not a fix to a build script)docs
: (changes to the documentation)style
: (formatting, missing semi colons, etc; no production code change)refactor
: (refactoring production code, eg. renaming a variable)test
: (adding missing tests, refactoring tests; no production code change)chore
: (updating grunt tasks etc; no production code change)