Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@fiit/localisation

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fiit/localisation

Localisation service by Fiit

latest
npmnpm
Version
1.1.19
Version published
Maintainers
4
Created
Source

Localisation Service

This TypeScript library provides an interface to the AWS Translate service, enabling both single text and batch text translations. It supports dynamic language detection and translation into specified target languages.

Features

  • Translate individual strings.
  • Batch translate arrays of strings while preserving order.
  • Automatically detect source language.

Installation

Install the package using npm. Ensure you have Node.js installed before running the following command:

npm install @fiit/localisation

Configuration

You must provide AWS credentials and a region to use this service. For security, it is recommended to manage credentials through environment variables or AWS IAM roles instead of hard coding them.

Usage

Import the Localisation, Language, and configuration interface from the package:

import { Localisation, Language, LocalisationConfig } from '@fiit/localisation';

const config: LocalisationConfig = {
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  region: process.env.AWS_REGION
};

const localisationService = new Localisation(config);

Translating Text

To translate a single piece of text:

const translation = await localisationService.translateText("Hello, world!", Language.EN);

Batch Translation

To translate multiple texts at once:

const texts = ["Hello, world!", "How are you?"];
const translations = await localisationService.translateBatchText(texts, Language.ES);

FAQs

Package last updated on 06 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts