-
Notifications
You must be signed in to change notification settings - Fork 7
Update README: elaborate all usage methods (browser, Node.js, JS apps) #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update README: elaborate all usage methods (browser, Node.js, JS apps) #37
Conversation
paramsiddharth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions, some changes requested. Please take a look. Thank you!
| Aksharamukha in your browser and Node.js! | ||
|
|
||
| ## Description | ||
| This project aspires to be a browser-compatible version of the [Aksharamukha](https://www.aksharamukha.com/) and its [Python library](https://github.com/virtualvinodh/aksharamukha-python), which is a transliteration tool for Indic scripts. | ||
| This project aspires to be a browser-compatible version of the [Aksharamukha](https://www.aksharamukha.com/) and its [Python library](https://github.com/virtualvinodh/aksharamukha-python), which is a transliteration tool for Indic scripts. The goal is to enable users to perform script conversions directly in their web browsers or Node.js applications without needing to rely on server-side processing. | ||
|
|
||
| The goal is to enable users to perform script conversions directly in their web browsers without needing to rely on server-side processing. | ||
| #### Aksharamukha.js can be used in multiple ways: directly in the browser via CDN, as a Node.js library, or imported in frontend JS apps using modern bundlers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can mostly skip these changes. The goal and intention don't change – we just want to specify other ways the package can be used.
| #### Aksharamukha.js can be used in multiple ways: directly in the browser via CDN, as a Node.js library, or imported in frontend JS apps using modern bundlers. | ||
|
|
||
| ## Plug & Play | ||
| ## 1. **Plug-n-Play(Browser via CDN)** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to bold the text or to add a numeral.
| ## 1. **Plug-n-Play(Browser via CDN)** | |
| ## Plug-&-Play (Browser via CDN) |
| </script> | ||
| </body> | ||
| </html> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code block not terminated here.
| ``` |
| yarn add aksharamukha | ||
| ``` | ||
|
|
||
| ESM example (Node with "type": "module" or .mjs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a level 3 header.
| </html> | ||
|
|
||
|
|
||
| ## 2. Node.js Usage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
|
|
||
| ESM example (Node with "type": "module" or .mjs): | ||
|
|
||
| > **Note:** Top-level `await` requires Node.js v14.8+ and `"type": "module"` in your `package.json`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to mention this. :) This is irrelevant to the package.
| Notes: | ||
| - Wrap usage in an async function (or use top-level await where supported). | ||
| - Choose ESM vs CommonJS according to your project's configuration. | ||
| - Check your Node version and bundler settings if you encounter import issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be skipped for the same reason.
| ## 3. Import in JS apps | ||
|
|
||
| Install the package for your app: | ||
|
|
||
| ```bash | ||
| # npm | ||
| npm install aksharamukha | ||
|
|
||
| # yarn | ||
| yarn add aksharamukha | ||
|
|
||
| # pnpm | ||
| pnpm add aksharamukha | ||
| ``` | ||
|
|
||
| Basic ESM usage (bundlers like Vite, Webpack, Rollup): | ||
|
|
||
| ```javascript | ||
| // src/main.js | ||
| import Aksharamukha from 'aksharamukha'; | ||
|
|
||
| async function run() { | ||
| const ak = await Aksharamukha.new(); | ||
| const out = await ak.process('autodetect', 'Devanagari', 'namaste'); | ||
| console.log(out); | ||
| } | ||
|
|
||
| run().catch(console.error); | ||
| ``` | ||
|
|
||
| CommonJS usage: | ||
|
|
||
| ```javascript | ||
| // src/main.cjs | ||
| const Aksharamukha = require('aksharamukha'); | ||
|
|
||
| (async () => { | ||
| const ak = await Aksharamukha.new(); | ||
| console.log(await ak.process('autodetect', 'Malayalam', 'śrī')); | ||
| })().catch(console.error); | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is repeated, I think.
| Next.js note: | ||
| - Use the component client-side only (disable SSR) if the package relies on browser APIs or WASM. Example: | ||
|
|
||
| ```javascript | ||
| // pages/index.js (Next.js) | ||
| import dynamic from 'next/dynamic'; | ||
| const TransliterateClient = dynamic(() => import('../components/TransliterateClient'), { ssr: false }); | ||
|
|
||
| export default function Page() { | ||
| return <TransliterateClient text="praNAm." />; | ||
| } | ||
| ``` | ||
|
|
||
| Bundler / WASM considerations: | ||
| - If the package includes a WASM asset, ensure your bundler is configured to load it (Vite/webpack may need asset rules or a plugin). If you encounter import errors, check your bundler docs for handling .wasm and async module initialization. | ||
| That’s it — import normally according to your project's module system and run Aksharamukha.new() before calling process(). | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed at the moment, either.
| React (client-side) example: | ||
|
|
||
| ```jsx | ||
| // components/TransliterateClient.jsx | ||
| import React, { useEffect, useState } from 'react'; | ||
| import Aksharamukha from 'aksharamukha'; | ||
|
|
||
| export default function TransliterateClient({ text }) { | ||
| const [out, setOut] = useState(''); | ||
|
|
||
| useEffect(() => { | ||
| let alive = true; | ||
| (async () => { | ||
| const ak = await Aksharamukha.new(); | ||
| const result = await ak.process('autodetect', 'Tamil', text); | ||
| if (alive) setOut(result); | ||
| })(); | ||
| return () => { alive = false; }; | ||
| }, [text]); | ||
|
|
||
| return <div>{out}</div>; | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain the relevance of alive here? Also, please use React Fragments instead of the div in this example.
Title:
Update README with all usage methods for Aksharamukha.js
Description:
This pull request updates the README to provide a comprehensive guide for using Aksharamukha.js.
Changes include:
1)Plug-n-play browser usage via CDN
2)Node.js backend usage with ESM and CommonJS examples
3)Importing in frontend JS apps with modern bundlers (Vite, Webpack, Rollup)
4)React and Next.js client-side usage examples