Skip to content

Commit

Permalink
Improved the naming for some properties in I18XS class
Browse files Browse the repository at this point in the history
  • Loading branch information
3adel-bassiony committed Dec 27, 2023
1 parent c5b5433 commit e464b8c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,16 @@ The I18XS package comes with a comprehensive set of features designed to make in
i18xs.fallbackLocale // -> 'en'
```
- **isLTR**: Check if the current locale is Left-To-Right (LTR) or not
- **isCurrentLocaleLTR**: Check if the current locale is Left-To-Right (LTR) or not
```javascript
i18xs.isLTR // -> True || False
i18xs.isCurrentLocaleLTR // -> True || False
```
- **isRTL**: Check if the current locale is Right-To-Left (RTL) or not
- **isCurrentLocaleRTL**: Check if the current locale is Right-To-Left (RTL) or not
```javascript
i18xs.isLTR // -> True || False
i18xs.isCurrentLocaleLTR // -> True || False
```
- **isDebugEnabled**: Check if the debug mode is enabled or not
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "i18xs",
"version": "1.0.0",
"version": "1.1.0",
"description": "A lightweight and simple package for i18n and localization for node.js",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ export default class I18XS {
* @example
* const i18n = new I18nService();
* i18n.setLocale('en');
* console.log(i18n.isLTR); // Output: true
* console.log(i18n.isCurrentLocaleLTR); // Output: true
* i18n.setLocale('ar');
* console.log(i18n.isLTR); // Output: false
* console.log(i18n.isCurrentLocaleLTR); // Output: false
*/
get isLTR(): boolean {
get isCurrentLocaleLTR(): boolean {
return !this._rtlLocales.includes(this._currentLocale)
}

Expand All @@ -176,11 +176,11 @@ export default class I18XS {
* @example
* const i18n = new I18nService();
* i18n.setLocale('ar');
* console.log(i18n.isRTL); // Output: true
* console.log(i18n.isCurrentLocaleRTL); // Output: true
* i18n.setLocale('en');
* console.log(i18n.isRTL); // Output: false
* console.log(i18n.isCurrentLocaleRTL); // Output: false
*/
get isRTL(): boolean {
get isCurrentLocaleRTL(): boolean {
return this._rtlLocales.includes(this._currentLocale)
}

Expand Down
10 changes: 5 additions & 5 deletions src/tests/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ describe('I18XS', () => {
expect(i18xs.currentLocale).toBe('ar')
expect(i18xs.supportedLocales).toEqual(['ar', 'fr'])
expect(i18xs.localization).toEqual({ Hello_World: 'مرحبا بالعالم' })
expect(i18xs.isRTL).toBe(true)
expect(i18xs.isLTR).toBe(false)
expect(i18xs.isCurrentLocaleRTL).toBe(true)
expect(i18xs.isCurrentLocaleLTR).toBe(false)
expect(i18xs.isDebugEnabled).toBe(true)
expect(i18xs.t('Hello_World')).toBe('مرحبا بالعالم')
expect(i18xs.t('Old_Hello_World')).toBe('Old_Hello_World')
Expand Down Expand Up @@ -257,17 +257,17 @@ describe('I18XS', () => {

test('It should check if the current locale is LTR or not', async () => {
const i18xs = new I18XS({ currentLocale: 'en', supportedLocales: ['en', 'ar'] })
expect(i18xs.isLTR).toBe(true)
expect(i18xs.isCurrentLocaleLTR).toBe(true)
})

test('It should check if the current locale is RTL or not', async () => {
const i18xs = new I18XS({ currentLocale: 'ar', supportedLocales: ['en', 'ar'] })
expect(i18xs.isRTL).toBe(true)
expect(i18xs.isCurrentLocaleRTL).toBe(true)
})

test('It should customize rtlLocales and check if the current locale is LTR or not', async () => {
const i18xs = new I18XS({ currentLocale: 'he', supportedLocales: ['en', 'ar'], rtlLocales: ['ar'] })
expect(i18xs.isRTL).toBe(false)
expect(i18xs.isCurrentLocaleRTL).toBe(false)
})

// test('It should enable debug mode', async () => {
Expand Down

0 comments on commit e464b8c

Please sign in to comment.