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

ngx-localizer

v0.0.3

Published

ngx-localizer is a easy Angular internationalization tool which can help you make your app available in multiple languages.

Downloads

7

Readme

ngx-localizer

ngx-localizer is a easy Angular internationalization tool which can help you make your app available in multiple languages.

Features

  • Custom type json translation files to translate between languaes.
  • Simple html attribute to markdown html tags to translate.
  • Quick rendering.
  • Single route hosting.

Upcoming Features

  • More customization options.
  • Google translator support.
  • Currencey, Date, number localization support.

Installation

ngx-localizer requires Angular v4.3+ to run.

Install the library using npm.

$ npm install ngx-localizer

Usage

1. Import the NgxLocalizerModule

You have to import NgxLocalizerModule in the root NgModule of your application in order to use the library.

import { NgModule } from "@angular/core";
import { NgxLocalizerModule } from "ngx-localizer";
 
 @NgModule({
  imports: [ NgxLocalizerModule]
})
2. Define html localizer attribute to mark translations

Once you've imported the NgxLocalizerModule, You can mark html tags which will be used to translate using localizer attributte. string value passed to the localizer will be used to identify the translation.

app.component.html
<h1 class="header" [localizer]="'greeting1'">Good Morning</h1>
<h1 [localizer]="'greeting2'">Good Afternoon</h1> 
3. Define the translations

You can put your translations in a json file located in a path as "/assets/localizer/localize.[lang].json" (default path). ([lang] is the lang that you're using, for english it could be en).

JSON structure

json strucure of the language file will be an array with a tag, value object model. Where tag will be used to identify the html tag. Value will be the translation text.

Example : localize.en.json file

[
    {
        "tag": "greeting1",
        "value": "Good Morning"
    },
    {
        "tag": "greeting2",
        "value": "Good Afternoon"
    }
]

Example : localize.fr.json file

[
    {
        "tag": "greeting1",
        "value": "Bonjour"
    },
    {
        "tag": "greeting2",
        "value": "Bonsoir"
    }
]
4. Using the NgxLocalizerService to change the language

After configuring the translation you can use NgxLocalizerService to change the language. In following example fr is the [lang] prefix used to define the tranlate json file prefix.

app.component.ts
import { Component } from '@angular/core';
import { NgxLocalizerService } from 'ngx-localizer';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  constructor(private localizer:NgxLocalizerService){
  }

  change(): void{
    this.localizer.setLocale('fr');
  }
}
NgxLocalizerService Methods
  • setDefautLocale(lang: string): Used to set the default language as the fallback language.
  • setLocale('fr'): Changes the displayed language.
  • setPath(path: string) : Set a differnet path folder other than the default folder path.
  • setPrefix(prefix: string): Set a diffrenet file prefix. (Default : localize)

Changelog

0.0.3

  • Fixed an issue with fallback language;

0.0.2

  • Added service methods to change defult paths;

0.0.1

  • Inital release;

Todos

  • Sample plunker project will be added soon

License

MIT