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

@scaler-school-of-technology/bhashini-web-translator

v0.0.27

Published

Webpage Translator for specialized for Regional Languages. Built using Bhashini APIs

Downloads

29

Readme

Web Server

Introduction

This Web Server is a JavaScript web server application that utilizes the Bhashini translation service to translate the content of a given web page from one language to another. This documentation provides an overview of the project structure and key components.

Project Structure

1. index.js

This file serves as the main entry point for the Bhashini Web Translator application. It initializes an Express.js server, handles incoming requests, and utilizes the BhashiniTranslator and fetchHTML modules to translate web content.

Dependencies

  • express: A web application framework for Node.js.
  • @scaler-school-of-technology/bhashini-web-translator: Bhashini translation service client.
  • dotenv: Loads environment variables from a .env file.
  • ./fetchHTML.js: Module for fetching the body element content from a given URL.

2. fetchHTML.js

This module provides functionality to fetch the HTML content of a web page and extract the body element content using Axios for HTTP requests and Cheerio for HTML parsing.

Dependencies

  • axios: A promise-based HTTP client for the browser and Node.js.
  • cheerio: A fast, flexible, and lean implementation of jQuery for the server.

Setup and Configuration

  1. Install dependencies:

    npm install
       
  2. Create a .env file in the project root with the following variables:

    BHASHINI_API_KEY=<Your Bhashini API Key>
    BHASHINI_USER_ID=<Your Bhashini User ID>
       

Running the Server

Start the Bhashini Web Translator server by running the following command:

npm start

The server will be accessible at http://localhost:3000.

Endpoints

1. /

  • Method: GET
  • Description: Welcome message for the Bhashini Web Translator app.

2. /translate

  • Method: GET
  • Description: Send the URL of the website to translate in the JSON format. The response will be the translated website
  • Parameters:
    • url (string): The URL of the web page to be translated.

Usage

  1. Access the homepage:

    GET <http://localhost:3000/>
       
  2. Translate a web page:

    GET <http://localhost:3000/translate?url=><URL_OF_WEB_PAGE>
       

Limitations

  • The web server is not able to translate websites that use client-side rendering
  • The web server is not able to translate websites that use cookies for authentication.
  • The web server is not able to translate websites that use authentication tokens for authentication tokens for authentication.
  • The web server is not able to translate websites that use sessions for authentication.

Important Notes

  • Ensure that the required environment variables (BHASHINI_API_KEY and BHASHINI_USER_ID) are set in the .env file.
  • The server is set to listen on port 3000 by default. Adjust the app.listen method in index.js if a different port is desired.

Conclusion

This Web Server translates web page content using the Bhashini translation service. Developers can extend and modify the application to meet specific requirements or integrate it into other projects.