# nv-remote-translate

> nv-remote-translate ============ - cli tool - create a translate json file server - support dynamic-modify-config through unix\_sock OR http

Latest version **1.0.1** (published 2022-02-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install nv-remote-translate
pnpm add nv-remote-translate
yarn add nv-remote-translate
bun add nv-remote-translate
```

Provides the command `nv_rtrans_srv`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-02-15 |
| First published | 2022-02-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | ihgazni2 |

## Links

- npm: https://www.npmjs.com/package/nv-remote-translate
- npm.io page: https://npm.io/package/nv-remote-translate

## Dependencies (2)

- [nv-cli-basic](https://npm.io/package/nv-cli-basic.md) ^1.0.5
- [nv-facutil-basic](https://npm.io/package/nv-facutil-basic.md) ^1.2.13

## Recent versions

- 1.0.1 (latest) — 2022-02-15

## README

nv-remote-translate
============
- cli tool
- create a translate json file server
- support dynamic-modify-config through unix\_sock OR http

install
=======
- npm install nv-remote-translate 

usage
=====
    
     #  npm install nv-remote-translate -g
     
        nv_rtrans_srv -H
        Usage: nv_rtrans_srv [options]
        Options:
            -p, --port           server port or unix_sock, default ./___usock___
            -d, --workdir        work dir, default ./
            -H, --help           usage



HTTP
-------

### init

      # mkdir trans-srv
      # cd trans-srv/
      # nv_rtrans_srv -p 18888
        
        //...wait install node_modules

        trans-srv# ls -l | egrep -v "node_modules|package"
        total 16
        -rw-r--r--  1 root root  297 Feb 15 03:25 srv.js
        -rw-r--r--  1 root root  225 Feb 15 03:25 translate.json
        trans-srv#


    
        trans-srv# cat srv.js

        const S = require("nv-remote-translate-srv");
        const path = require("path");
        module.exports = async ()=> {
            await S(18888,path.join("/mnt/sdb/JS/BUSINESS-LIB_/nv-remote-translate/TEST/trans-srv",'translate.json'),"/mnt/sdb/JS/BUSINESS-LIB_/nv-remote-translate/TEST/trans-srv");
            return(S)
        }
        trans-srv#





 
### edit tbl 

     
     # vim translate.json 
     /*
        {
            "cnl": [
                "c0",
                "c1",
                "c2"
            ],
            "tbl": [
                [
                    "A",
                    "B",
                    "C"
                ],
                [
                    "a",
                    "b",
                    "c"
                ]
            ]
        }

     */ 

### start srv


        > const S = await require("./srv")()
        listen on: 18888
        
        > S.CFG         //this is a getter, for dynamic-change-from-remote
        >



### get config from remote

          # nv_rtrans_cli -S -p 18888

            _T {
              '#cnl': [ 'c0', 'c1', 'c2' ],
              '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ] ]
            }



### change config from remote when server running
- CFG is  keywords

#### add

        nv_rtrans_client -m "CFG.add(['cA','cB','cC'])" -p 18888 

        before:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ] ]
        }
        ------------
        after:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }



### check it on server AFTER change from client


        > S.CFG
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }
        >


### check the cfg file AFTER change from client


        cat translate.json
        {
            "cnl": [
                "c0",
                "c1",
                "c2"
            ],
            "tbl": [
                [
                    "A",
                    "B",
                    "C"
                ],
                [
                    "a",
                    "b",
                    "c"
                ],
                [
                    "cA",
                    "cB",
                    "cC"
                ]
            ]
        }

### delete

        nv_rtrans_client -m "CFG.del('cA')" -p 18888

### others


        //see readme of https://www.npmjs.com/package/nv-facutil-simple-translate


        nv_rtrans_client -m "console.log(Object.getOwnPropertyNames(CFG))" -p 18888
        before:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }
        ------------
        [
          '#cnl',         '#tbl',
          'col_c0',       'col_c1',
          'col_c2',       'dict_c0_to_c1',
          'map_c0_to_c1', 'dict_c1_to_c0',
          'map_c1_to_c0', 'dict_c0_to_c2',
          'map_c0_to_c2', 'dict_c2_to_c0',
          'map_c2_to_c0', 'dict_c1_to_c2',
          'map_c1_to_c2', 'dict_c2_to_c1',
          'map_c2_to_c1'
        ]
        after:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }


        # nv_rtrans_client -m "console.log(CFG.constructor.prototype)" -p 18888
        before:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }
        ------------
        {
          add: [Function (anonymous)],
          del: [Function (anonymous)],
          dump: [Function (anonymous)],
          get: [Function (anonymous)],
          get_all: [Function (anonymous)],
          slct: [Function (anonymous)]
        }
        after:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }


        # nv_rtrans_client -m "console.log(CFG.dict_c1_to_c0)" -p 18888
        before:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }
        ------------
        { B: 'A', b: 'a', cB: 'cA' }
        after:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }

        # nv_rtrans_client -m "console.log(CFG.dict_c0_to_c1)" -p 18888
        before:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }
        ------------
        { A: 'B', a: 'b', cA: 'cB' }
        after:
        _T {
          '#cnl': [ 'c0', 'c1', 'c2' ],
          '#tbl': [ [ 'A', 'B', 'C' ], [ 'a', 'b', 'c' ], [ 'cA', 'cB', 'cC' ] ]
        }


UNIX\_SOCK
-----------
- for security

### server

     # vim ./srv
     //change the port to undefined
        const S = require("nv-remote-translate-srv");
        const path = require("path");
        module.exports = async ()=> {
            await S(
                undefined, //===>
                path.join("/mnt/sdb/JS/BUSINESS-LIB_/nv-remote-translate/TEST/trans-srv",'translate.json'),
                "/mnt/sdb/JS/BUSINESS-LIB_/nv-remote-translate/TEST/trans-srv"
            );
            return(S)
        }


     > const S = await require("./srv")()
         listen on: /mnt/sdb/JS/BUSINESS-LIB_/nv-remote-translate/TEST/trans-srv/___usock___


### client 

     //JUST without -p if in dir-of-translate.json , others same as http
     nv_rtrans_client -S -p /mnt/sdb/JS/BUSINESS-LIB_/nv-remote-translate/TEST/trans-srv/___usock___

     nv_rtrans_client -S
     nv_rcfg_client -m "..."


LICENSE
=======
- ISC

---
_Source: https://npm.io/package/nv-remote-translate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
