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-google-translate-ui

v2.0.0

Published

Angular Material Google Translate UI

Downloads

43

Readme

ngx-google-translate-ui

Angular Material UI library for Google Translate based on Google Cloud Translation API.

Maintenance code style: prettier FOSSA Status

Features

  • Text translation
  • Auto language detection
  • Multiple language translation
  • Fast and reliable – uses the Google translate servers
  • Copy translation result copied to clipboard per language or
  • Copy all translations to clipboard as raw JSON data

View live demo on StackBlitz

Install


npm install ngx-google-translate-ui

Usage

Google Translation API key is required to use this library. Google cloud console

The translation process is analogous to Google Translate.

Standalone component

<ngx-google-translate-ui></ngx-google-translate-ui>

Library can be used as an standalone component without requiring any input values.

Dialog component

This library can be used as a dialog component.

Use INgxGoogleTranslateUiDialogData interface to provide initial dialog data.


import { NgxGoogleTranslateUiComponent } from 'ngx-google-translate-ui';

openDialog () {
  const dialogConfig: INgxGoogleTranslateUiDialogData = {
    googleApiKey: '<YOUR_GOOGLE_API_KEY>',
    translationText: 'How you doin?'
  };

  const dialogRef = this.dialog.open(NgxGoogleTranslateUiComponent, {
			data: dialogConfig,
			minWidth: '600px'
	})
}

Google translation service

Library exports GoogleTranslationService so it can be used separately from components.

The getTranslation$ method is used to fetch translations. It requires three parameters:

  • apiKey - User's Google API key.
  • targetLang - Language code used in translation - ISO-639 codes.
  • text - Text to translate - one or multiple strings.
  • errorCallback - Optional, custom error callback function. Defaulted to snackbar message and rethrow error.

import { GoogleTranslationService } from 'ngx-google-translate-ui';

constructor (private googleTranslationService: GoogleTranslationService){}

this.googleTranslationService.getTranslations$(
			'<YOUR_GOOGLE_API_KEY>',
			'en',
			['Whats up?', 'Nothing much!']
)

Exposed resources

Following resources can be imported from library:

  • NgxGoogleTranslateUiModule
    • Exports the NgxGoogleTranslateUiComponent
  • NgxGoogleTranslateUiComponent
    • Used outside templates
  • INgxGoogleTranslateUiDialogData
    • Used when component is a dialog component
  • GoogleTranslationService
    • Fetching Google translations
  • IGoogleTranslationsData
    • The response of fetching translations
  • IGoogleTranslation
    • The Google translations object

Contributing

Contributions are welcome!

License

Apache License

Copyright (c) 2023 Dino Klicek