1.2.1 • Published 2 years ago

@rove-team/locale v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

How to use

You can see the example folder, if you need and example usage of this library.

Installation

To install this library you need to use the following command:

npm install @rove-team/locale

Create Object Files

It's recommended to create a typescript file for each language and put the object in that file.

Usage

  1. Create an instance of Locale class and call the cache method:
const locale: Locale = new Locale({
    language: 'en-us',
    localeObject: {
      'en-us': // english us object,
      'fa-ir': // farsi it object
    }
  });
  1. Get the text value by using the translate method:
export const englishUSA = {
  hello: "Hi, The {0} is now logged in as {1}",
  goodbye: "Bye",
  user: {
    firstName: "First Name",
    lastName: "Last Name"
  }
}
const helloValue: string = locale.translate('hello', ['user', 'admin']);
const userLocale = locale.getCollection('user');

const firstNameValue: string = userLocale.translate('firstName');
1.2.0

2 years ago

1.2.1

2 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago