Socket
Book a DemoInstallSign in
Socket

@dp-websolutions/laravel-translator

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dp-websolutions/laravel-translator

This module implements a function that can parse laravel localization strings.

latest
npmnpm
Version
2.0.1
Version published
Maintainers
2
Created
Source

laravel-translator

This module implements a function that can parse laravel localization strings.

https://laravel.com/docs/9.x/localization

Installation

npm install @dp-websolutions/laravel-translator

Usage

This module will expose a Translator function that creates a translator instance.

You can load this module in different ways:

Load the script directly into a page

  • <script src="node_modules/@dp-websolutions/laravel-translator/dist/laravel-translator.umd.js"></script>

In a compilation step, that will later generate a javascript bundle and loaded into a page

  • const {Translator} = require('@dp-websolutions/laravel-translator')

Using imports

  • import {Translator} from '@dp-websolutions/laravel-translator'

Then you can initialize the Translator:

const strings = {
  welcome: "Welcome :name",
};
const translator = Translator(strings);
const text = translator.__("welcome", { name: "Carlos" });
console.log(text); // Welcome Carlos

Development

To develop locally, clone the repository and run the following commands from within the directory

  • npm run install
  • npm run dev
  • Go to localhost:8080 any changes will automatically reload the page

Tests

To run tests and watch for file changes

npm run test:dev

For a single test run

npm run test

Coverage

To check the test coverage run

npm run coverage

FAQs

Package last updated on 11 May 2022

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