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

interlang_app_sdk

v0.0.5

Published

The official SDK for InterLang, the application internalization platform

Downloads

18

Readme

InterLang SDK

Welcome to the InterLang SDK. You can start by creating your InterLang account:

Create Your InterLang Account

This is the official SDK for InterLang. using this SDK, you can create applications in one national language, and other users with a different national language would easily be able to use your application, just by translating the application to their national language. InterLang helps you build international applications.

Get started by installing the dependencies into your project docs folder:

npm install interlang_app_sdk
yarn add interlang_app_sdk
pnpm install interlang_app_sdk

Using the InterLang SDK on the client-side

createDocumentTranslate(args)

createDocumentTranslate(args){lang=ts} is responsible for translating the entire web-page to the specified language in the args props. The request is sent directly to InterLang

  • args refers to the argument expected by the function

apiKey, languageFrom, applicationId, targetLanguage, onProcessing and onTranslated are the arguments expected to be passed as an object.

This is the Typescript type specific example

createDocumentTranslate({
      apiKey: string,
      languageFrom: string | 'auto',
      applicationId?: string | null,
      targetLanguage: string,
      onProcessing: () => void
      onTranslated: () => void
})

This is how it would be used in code, with a react and browser example

import language from 'interlang_app_sdk/dist/supported_languages'
import { createDocumentTranslate } from 'interlang_app_sdk/dist/client'

...

const [selectedLanguage, setSelectedLanguage] = useState('default')
  const handleLanguageTranslate = () => {
    createDocumentTranslate({
      apiKey: /* API Key*/,
      languageFrom: 'auto',
      applicationId: /* Application ID (Optional if using a test API Key) */,
      targetLanguage: selectedLanguage,
      onProcessing: function (): void {
        //what should happen when language has started
      },
      onTranslated: function (): void {
        //what should happen when language is completed
      },
    })
  }

<script src="https://interlang.app/sdk/dist/browser_sdk.min.js"> </script>

...
  const handleLanguageTranslate = () => {
    const language = document.getElementById('language').value;
    createDocumentTranslate({
      apiKey: /* API Key*/,
      languageFrom: 'auto',
      applicationId: /* Application ID (Optional if using a test API Key) */,
      targetLanguage: language,
      onProcessing: function (): void {
        //what should happen when language has started
      },
      onTranslated: function (): void {
        //what should happen when language is completed
      },
    })
  }
  • apiKey This is your InterLang API Key. It is either a Test Key test-... or a Main Key language-....
  • languageFrom The language your are currently translating the page from. Recommended 'auto'
  • applicationId An optional field if you are using a Test API Key, and compulsory if using a Main API Key. This is the id of the current Project you've created in your InterLang account.
  • targetLanguage The language to be translated to.
  • onProcessing Code to run when language translation has started.
  • onTranslated Code to run when translation is completed

setDynamicData(arg1, arg2)

setDynamicData(arg1, arg2){lang=ts} is used to create dynamic data. This function should be the first javascript that runs in the page. if you're using react, it should be in the useEffect hook.

setDynamicData('["Good Morning", "Good Afternoon", "Good Evening"]', { active: 2 });
useEffect(()=>{
    setDynamicData('["Good Morning", "Good Afternoon", "Good Evening"]', { active: 2 });
}, [])

In the HTML or JSX code, the element with the dynamic data should look like this

<div data-key='["Good Morning", "Good Afternoon", "Good Evening"]' id="ab">Good Morning</div>

Then a function that changes the dynamic value would be something like this

const changeText = (update: number) => {
    updateDynamicData('["Good Morning", "Good Afternoon", "Good Evening"]', { active: update });
    var textElement = document.getElementById('ab');
    textElement.innerText = getDynamicTranslationData('["Good Morning", "Good Afternoon", "Good Evening"]', getDynamicData('["Good Morning", "Good Afternoon", "Good Evening"]'));
}
  • updateDynamicData The function takes in two arguments, the dynamic data, and an object of the currently selected index

  • getDynamicTranslationData The function gets the translated text when the page has been translated

  • getDynamicData The function gets the currently active index from the translated result

  • active This field points to the item that is currently visible or in view from the dynamic data

Supported Languages

import language from 'interlang_app_sdk/dist/supported_languages'

You can find the supported languages by using this package. It exports the language object as an array of all the languages that InterLang supports