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

angular-translate-numbers

v0.0.3

Published

📙 A light-weight utility to translate numbers from one Type to another that are dependent on `DECIMAL SYSTEM` but as default it converts from `Arabic(Western)` numbers like `(1,2,251,..)` into `Arabic(Eastern)` like ` (١,٢,٢٥١,..) `

Downloads

389

Readme

📙 A light-weight utility to translate numbers from one Type to another that are dependent on DECIMAL SYSTEM but as default it converts from Arabic(Western) numbers like (1,2,251,..) into Arabic(Eastern) like (١,٢,٢٥١,..)

demo

📌 Supported Numeral systems

Arabic, Gujarati, Gurmukhi, Bengali, Assamese, Kannada, Odia, Malayalam, Telugu, Burmese, Tibetan, Mongolian, Sinhala, Khmer, Thai, Lao, Javanese, Arabic_Weste Latin, Cyrillic, Greek, Arabic_Hindi Arabic_Easte Persian, Pashto, Dari, Urdu, Shahmukhi, Brahmi, Devanagari

📌 Installation

$ npm i angular-translate-numbers

📌 Usage

1- add AngularTranslateNumbersModule to imports in NgModule

@NgModule({
  imports: [
    AngularTranslateNumbersModule,
    //here any other imports modules
    ]

2- import TranslateNumbersService Service and NumberType Numeral systems Enum in a Component

import {TranslateNumbersService,NumberType } from 'angular-translate-numbers';

3- inject TranslateNumbersService in any constructor and init Enum In the Component so you can easily use the supported Number types

  NumberTypes = NumberType;
 constructor(private service: TranslateNumbersService) {
  }

📌 Coding

⚙️ Using Service (TranslateNumbersService)

👋 for typeScript Files using .

Translate(value : string, to?: NumberType , `from`?: NumberType ): string;

value -the value that has numbers and wanted to be translated

to -The Numeral systems that the value will be translated to -Optional
-Default is Arabic / Arabic_Hindi / Arabic_Eastern /

from -the Numeral systems that is the input is already in -Optional -Default is Digit s/ Arabic_Western / Latin / Cyrillic / Greek

Number( value : string, from : NumberType): number;

value -the value that Already Translated And Want to Convert it To Number

from -the Numeral systems that is the input is already in

📌 Examples

Defaults

this.service.Translate("i am 28 years old");
//result => i am ٢٨ years old

this.service.Translate("i am 28 years old",NumberType.Arabic);
//result => i am ٢٨ years old

this.service.Translate("i am 28 years old",NumberType.Arabic,NumberType.Digits);
//result => i am ٢٨ years old

From type to another

this.service.Translate("i am 28 years old",NumberType.Assamese);
//result => i am ২৮ years old

this.service.Translate("i am 28 years old",NumberType.Malayalam,NumberType.Digits);
//result => i am ൨൮ years old

this.service.Translate("i am ൨൮ years old",NumberType.Digits,NumberType.Malayalam);
//result => i am 28 years old  

this.service.Translate("i am 28 years old",NumberType.Malayalam,NumberType.Assamese);
//result => i am 28 years old  
//>was not translated as the 'from' input was wrong

From type to number value

let number_Malayalam_Type = this.service.Translate("28",NumberType.Malayalam);
//result =>  ൨൮
let number_Assamese_Type = this.service.Translate(number_Malayalam_Type,NumberType.Assamese,NumberType.Malayalam);
//result =>  ২৮
let digitsValueAsNumber = this.service.Number(number_Assamese_Type,NumberType.Assamese);
//result =>  28
let digitsValueAsNumber = this.service.Number(number_Assamese_Type+"hi",NumberType.Assamese);
//result =>  NAN
//was not converted to number as the 'input value' contained un number characters 
let digitsValueAsNumber2 = this.service.Number(number_Assamese_Type,NumberType.Javanese);
//result =>  NAN
//was not converted to number as the 'from' Number Type was not correct

⚙️ Using Pipe (TranslateNumbersPipe)

👋 for template using .


{{ 123456 | translateNumbers }}<!-- default converts to aranic-->
<!-- Result  ١٢٣٤٥٦ -->
{{ 123456 | translateNumbers: NumberTypes.Arabic }} <!-- example to change 'to' Type -->
<!-- Result  ١٢٣٤٥٦ -->
{{ "١٢٣٤٥٦" | translateNumbers: NumberTypes.Assamese: NumberTypes.Arabic}}<!-- example to change 'to' Type from another type-->
<!-- Result  ১২৩৪৫৬ -->
{{ "১২৩৪৫৬" | translateNumbers: NumberTypes.Digits:NumberTypes.Assamese }})<!-- example to change 'to' Digits from another type-->
<!-- Result  123456 -->

📌 Demo & github

demo github

👋 In upcoming versions, we might add more Numeral Types so please feedback for issues or wanted Numeral systems .