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

@elham-oss/light-localize-router

v0.13.0

Published

> An implementation of routes localization for Angular without rewriting the router configuration. > This project was generated using [Nx](https://nx.dev).

Downloads

11

Readme

Light Localize Router for ngx-translate

An implementation of routes localization for Angular without rewriting the router configuration.

This project was generated using Nx.

🔎 Created By Nrwl/Nx inspired by angular-l10n & Greentube/localize-router & gilsdav/ngx-translate-router.

for demo please refer to the source code => apps/documentation, also the demo app has been deployed to netlify demo app for api documentations click here

Table of contents:

Installation

using npm:

npm install --save @elham-oss/light-localize-router

using yarn:

yarn add --save @elham-oss/light-localize-router

Usage

In order to use @elham-oss/light-localize-router you must initialize it with following information:

  • Localization Config along with loader.

Initialize module

import { LightLocalizeRouterModule } from '@elham-oss/light-localize-router';

import { Location } from '@angular/common';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { HttpBackend, HttpClient, HttpClientModule } from '@angular/common/http';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AbstractParser, HttpLoader, LightLocalizeRouterModule } from '@elham-oss/light-localize-router';

imports: [
    TranslateModule.forRoot({
        defaultLanguage: 'en',
        loader: {
          provide: TranslateLoader,
          useFactory: HttpLoaderFactory,
          deps: [HttpClientTrans]
        }
    }),
    RouterModule.forRoot(routes),
    LightLocalizeRouterModule.forRoot({
        parser: {
          provide: AbstractParser,
          useFactory: (translate, location, injector, platformId, http) => {
            return new HttpLoader(translate, location, http, injector, platformId)
          },
          deps: [TranslateService, Location, Injector, PLATFORM_ID, HttpClient]
        }
    })
]

How it works

after you add @elham-oss/light-localize-router to your project it will work like angular-l10n routing but for ngx-translate/core:

A prefix containing the language is added to the path of each navigation, creating a semantic URL:

baseHref/[language][-script][-region]/path

https://example.com/en/home
https://example.com/en-US/home

If the localized link is called, the locale is also set automatically.

To achieve this, the router configuration in your app is not rewritten: the URL is replaced, in order to provide the different localized contents both to the crawlers and to the users that can refer to the localized links.

If you don't want a localized routing for default locale, you can enable it during the configuration:

{
    "defaultRouting": true
}

you can also create your own loader instead of http loader and provide the configuration for the library.