npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@logo-software/language

v11.0.0

Published

With this module you can easily translate any text to specified language on the fly. Over HTTP or LOCAL file resource can be usable.

Downloads

8

Readme

Language Module

With this module you can easily translate any text to specified language on the fly. Set configuration properties, if default language is different from English. For example, import section on you NgModule and set configuration

Click here for demo

Installation

All public npm packages of Logo Software is at https://www.npmjs.com/~logofe. To install Language Module:

$ npm set registry https://registry.npmjs.org/
$ npm install @logo-software/language -s

Just import it to your project of @NgModule import section.

@NgModule({
 imports: [
   CommonModule,
   LanguageModule.forRoot({ abbr: 'en', readFromFile: false, extension: 'json', path: 'languages' }),
 ],
})
export class AppModule {
}

There are three steps:

  • Install package using npm install @logo-software/language
  • add it to your AppModule imports code block using LanguageModule.forRoot(languageConf)
  • Put your language files to your src/assets/languages folder (src/assets/language/en-En.json etc.).

Configuration

Before AppModule bootstrap, configuration constants must be set. The configuration file type is a LanguageInitSetting object type. There are several parameters for configuration:

  • abbr: Codes for the Representation of Names of Languages are described at ISO 639-1 Code.
  • path: HTTP request path that contains language files. Note: When readFromFile is true, you must put your language files under your src/assets/languages folder. And this property will not effect the project. If readFromFile is false, You can set your language files path anywhere you request with path option.
  • readFromFile: If set readFromFile to true data will be load from file system and HTTP request will not call. Otherwise data will be requested over HTTP protocol. Default value is false.
  • extension: The file extension will be download. Default is json. If change to another it will add to end of line this extension. With Following code, HTTP request will be send to the http(s)://.../path/of/lang/en-GB.xyz address.
// path will look to 'src/assets/`languages`' with this option
const lang = {abbr: 'ro', readFromFile: false, extension: 'json', path: 'languages',}

####Usage Example

Just as below you can easily translate language.

some.component.html

<span>{{"some_text_from_lang_json" | translate}}</span>

Change Language

If you decide to use multiple language and change it using button to another one, just paste below sample to your code base.

import {Component} from '@angular/core';
import {LanguageService} from '@logo-software/language';

@Component({
  selector: 'lbs-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'logo-ng-library';

  constructor(private languageService: LanguageService) {
    this.addLanguage();
  }
  
  // change application language to tr
  setLanguage(lang: string = 'tr') {
    this.languageService.setLanguage(lang);
  }
  
  // adds new language to app
  addLanguage() {
    this.languageService.addLanguage({abbr: 'ro', code: 'ro-RO', display: 'Romain'});
  }
}

Add Language

If you desire, There are not enough language exist for me then you can add more languages to your scope. First add your language file to assetsPath (For example: /src/assets/languages). After that call newly created language definition from code. Example usage:

this.languageService.addLanguage({abbr: 'ro', code: 'ro-RO', display: 'Romain'});

For API details, please visit http://design.logo.com.tr/#/docs/components/components-overview