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

@viberlab/translate

v7.0.9

Published

Viber Tools for ngx-translate

Downloads

24

Readme

VbrTranslateModule Module

@ngx-viber/translate

Table of Contents

What is it for

This module includes set of tools:

Services:

  • VbrTranslateService
  • VbrLanguageDetectorFromQueryParameter
  • Custom Language Detector
  • VbrLanguageDetector

Misc:

  • Setup Supported Languages
  • Translation for Supported languages
  • RLT and LTR languages support

Pipes:

  • vbrTranslate - use partials in template names as well as supports observable parameters.

Installation

npm install @viberlabs/translate --save

Module

  • Canonical language codes
  • List of allowed Languages
  • VbrTranslateLoader
  • VbrLanguageDetector

In you module:

impors: [
  VbrTranslateModule.forRoot({
  allowedLanguages: ['en', 'he', 'ru'],
  canonicalCodes: {iw => 'he'},
  defaultLanguage: 'en',
  rtlLanguages: ['he']
  }),
]

Module configuration Module configuration should implement interface VbrTranslateModuleConfig

 interface VbrTranslateModuleConfig {
  // array of all supported languages
  allowedLanguages?: Array<string>;
  // Object of canonical languages, used to transform non-canonical codes tho their canonical form
  // For example: if set {'iw' => 'he'}
  // "iw" will be handled as "he"
  canonicalCodes?: { [code: string]: string };
  // Default language
  defaultLanguage?: string;
  // Language Detector
  languageDetector?: Provider;
  // Navigator
  navigator?: Navigator;
  // Array of rtl languages
  rtlLanguages?: Array<string>;
}

Language detectors

In some cases you want to be able to detect default application language We are providing you with the base preset of such language detectors. In case there is no language detector provided we will try to detect supported language from navigate.languages or use default language.

Preset Language Detectors:

  • VbrLanguageDetectorFake - used as fallback in case no Language detector provided
  • VbrLanguageDetectorCommon - Can detect language according to defined parameter or query parameter.
  • VbrLanguageDetectorQueryParam - Detect language from query param
  • VbrLanguageDetectorParam - Detect language from param

Example of preset Language detector usage:

function languageDetector(router: Router): VbrLanguageDetector {
  // look for a "lang" query param and use it as default language
  return new VbrLanguageDetectorQueryParam(router, 'lang');
}

...
// In AppModule imports:

imports: [
  VbrTranslateModule.root({
  languageDetector: {
      provide: VBR_CUSTOM_LANGUAGE_DETECTOR,
      useFactory: (languageDetector),
      deps: [Router]
    } 
  })
]

Also you can create your own language detector by implementing VbrLanguageDetector:

class CustomLanguageDetector implements VbrLanguageDetector {
  public getLanguage(): Observable<string> {
    return of('en');
  }
}

At next step language detector should be provided to VbrTranslateModule

function languageDetector(): VbrLanguageDetector {
  return new CustomLanguageDetector();
}

...
// In AppModule imports:

imports: [
  VbrTranslateModule.root({
  languageDetector: {
      provide: VBR_CUSTOM_LANGUAGE_DETECTOR,
      useFactory: (languageDetector)
    } 
  })
]

VbrTranslateService

Injection Tokens:

  • VBR_TRANSLATE_ALLOWED_LANGUAGES
  • VBR_TRANSLATE_DEFAULT_LANGUAGE
  • VBR_TRANSLATE_CANONICAL_CODES
  • VBR_NAVIGATOR_TOKEN
  • VBR_TRANSLATE_LANGUAGE_DETECTOR

VbrLanguageInfoService

  • RTL and LTR languages support

Injection Tokens:

  • VBR_TRANSLATE_RTL_CODES
  • VBR_TRANSLATE_LANGUAGES_INFO