🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

com.hydroper.fluent

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

com.hydroper.fluent

Work with Fluent Project translation lists.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

Fluent Project rapid integration

Rapidly support Fluent Project's translation in your web application. Both client-side and server-side applications are supported.

That is an updated version of com.hydroper.ftl.

Getting Started

Install dependency:

npm install com.hydroper.fluent

Example TypeScript:

import { FluentBox } from "com.hydroper.fluent";

class Main
{
    fluentBox: FluentBox;

    constructor()
    {
        this.fluentBox = new FluentBox({
            locales: ["en"],
            fallbacks: {
                // "pt-BR": ["en"],
            },
            defaultLocale: "en",

            source: "res/lang",
            files: [
                "_", // res/lang/LANG/_.ftl
            ],

            clean: true,

            // specify either 'http' or 'fileSystem' as load method
            method: "fileSystem",
        });
        this.initialize();
    }

    async initialize()
    {
        if (!(await this.fluentBox.load()))
        {
            // failed to load
            return;
        }

        console.log(this.fluentBox.getMessage("hello", { to: "Diantha" }));
    }
}

new Main();

Example FTL file at res/lang/en/_.ftl:

hello = Hello, { $to }!

Server Usage

Usually, for server applications, set the clean option to false and clone the FluentBox object when necessary by invoking fluentBox.clone(); to change the current locale.

The fluentBox.clone(); method clones the FluentBox object, but still re-uses resources from the original object, avoiding resource duplication.

Keywords

fluent

FAQs

Package last updated on 14 Mar 2025

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