Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 0c3f104

Browse files
Danieladufeich-msVishwac Sena Kannanmunozemiliovishwacsena
authored
mslg CLI (#644)
* init mslg * init * init commands * init * init * init * init * align with the lastest doc * add collect api * update * update * update * update * add doc * stash * update * update * init * init * update * update * update * update * add tests * update * update * update * modify path operator * update * add more tests and fix bugs * fix error * update lg package * rename folder lg-cli to lg and revert translate key * adjust translate test cases * updates based on review. * doc updates * Adding commands to readme * update Co-authored-by: Fei Chen <[email protected]> Co-authored-by: Vishwac Sena Kannan <vishwacsenakannan@ALLISONT6-PROBK.northamerica.corp.microsoft.com> Co-authored-by: Emilio Munoz <[email protected]> Co-authored-by: Vishwac Sena Kannan <[email protected]>
1 parent 55e0539 commit 0c3f104

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3233
-411
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 526 additions & 411 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/lg/.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false

packages/lg/.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/lib
2+
/test

packages/lg/.eslintrc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": [
3+
"oclif",
4+
"oclif-typescript"
5+
],
6+
"rules": {
7+
"guard-for-in": "off",
8+
"no-await-in-loop": "off",
9+
"no-negated-condition": "off",
10+
"max-params": "off",
11+
"file-header": [
12+
true,
13+
{
14+
"match": "Copyright \\(c\\) Microsoft Corporation\\.*",
15+
"allow-single-line-comments": false,
16+
"default": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.",
17+
"enforce-trailing-newline": false
18+
}
19+
]
20+
}
21+
}

packages/lg/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*-debug.log
2+
*-error.log
3+
/.nyc_output
4+
/dist
5+
/lib
6+
/tmp
7+
/yarn.lock
8+
node_modules
9+
/.vscode
10+
/**/generated

packages/lg/.nycrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extension": [
3+
".ts",
4+
".js"
5+
],
6+
"include": [
7+
"src"
8+
],
9+
"exclude": [
10+
"**/node_modules/**",
11+
"**/tests/**",
12+
"**/coverage/**",
13+
"**/*.d.ts"
14+
],
15+
"reporter": [
16+
"text",
17+
"html"
18+
],
19+
"all": true,
20+
"cache": true,
21+
"extends": "@istanbuljs/nyc-config-typescript",
22+
"check-coverage": false
23+
}

packages/lg/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
@microsoft/bf-lg-cli
2+
======================
3+
4+
This package is intended for Microsoft use only and should be consumed through @microsoft/botframework-cli. It is not designed to be consumed as an independent package.
5+
6+
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7+
[![Version](https://img.shields.io/npm/v/@microsoft/bf-luis-cli.svg)](https://npmjs.org/package/@microsoft/bf-luis-cli)
8+
9+
# Relevant docs
10+
- [.lg file format][1]
11+
- [translating .lg files][2]
12+
13+
14+
# Commands
15+
<!-- commands -->
16+
* [`bf lg`](#bf-lg)
17+
* [`bf lg:expand`](#bf-lgexpand)
18+
* [`bf lg:translate`](#bf-lgtranslate)
19+
* [`bf lg:verify`](#bf-lgverify)
20+
21+
## `bf lg`
22+
23+
Parse, collate, expand and translate lg files.
24+
25+
```
26+
USAGE
27+
$ bf lg
28+
29+
OPTIONS
30+
-h, --help lg command help
31+
```
32+
33+
_See code: [src/commands/lg/index.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/lg/src/commands/lg/index.ts)_
34+
35+
## `bf lg:expand`
36+
37+
Expand one or all templates in .lg file(s). Expand an inline expression.
38+
39+
```
40+
USAGE
41+
$ bf lg:expand
42+
43+
OPTIONS
44+
-f, --force If --out flag is provided with the path to an existing file, overwrites that file
45+
-h, --help lg:expand help
46+
-i, --in=in (required) .lg file or folder that contains .lg file.
47+
-o, --out=out Output file or folder name. If not specified stdout will be used as output
48+
-r, --recurse Consider sub-folders to find .lg file(s)
49+
--all When set, all templates in the .lg file be expanded.
50+
--expression=expression Inline expression provided as a string to evaluate.
51+
--interactive Interactively prompt for all missing entity value references required for expansion.
52+
--template=template Name of the template to expand. Template names with spaces must be enclosed in quotes.
53+
--testInput=testInput Path to a JSON file containing test input for all variable references.
54+
```
55+
56+
_See code: [src/commands/lg/expand.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/lg/src/commands/lg/expand.ts)_
57+
58+
## `bf lg:translate`
59+
60+
Machine translate .lg files using Microsoft Translator Text API.
61+
62+
```
63+
USAGE
64+
$ bf lg:translate
65+
66+
OPTIONS
67+
-f, --force If --out flag is provided with the path to an existing file, overwrites that file
68+
-h, --help lg:translate help
69+
-i, --in=in (required) .lg file or folder that contains .lg file.
70+
-o, --out=out Output file or folder name. If not specified stdout will be used as output
71+
-r, --recurse Consider sub-folders to find .lg file(s)
72+
--srclang=srclang Source lang code. Auto detect if missing.
73+
--tgtlang=tgtlang (required) Comma separated list of target languages.
74+
--translate_comments Machine translate all comments found in .lg file
75+
--translate_link_text Machine translate link description in .lg file
76+
--translatekey=translatekey (required) Machine translation endpoint key.
77+
```
78+
79+
_See code: [src/commands/lg/translate.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/lg/src/commands/lg/translate.ts)_
80+
81+
## `bf lg:verify`
82+
83+
Verify .lg file(s) and collate them into a single file.
84+
85+
```
86+
USAGE
87+
$ bf lg:verify
88+
89+
OPTIONS
90+
-f, --force If --out flag is provided with the path to an existing file, overwrites that file
91+
-h, --help lg:verify help
92+
-i, --in=in (required) .lg file or folder that contains .lg file.
93+
-o, --out=out Output file or folder name. If not specified stdout will be used as output
94+
-r, --recurse Considere sub-folders to find .lg file(s)
95+
```
96+
97+
_See code: [src/commands/lg/verify.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/lg/src/commands/lg/verify.ts)_
98+
<!-- commandsstop -->
99+
100+
[1]:https://aka.ms/lg-file-format
101+
[2]:./docs/translate-command.md

packages/lg/bin/run

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
3+
require('@oclif/command').run()
4+
.catch(require('@oclif/errors/handle'))

packages/lg/bin/run.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\run" %*
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Translate command
2+
Often times you might want to target a multi-lingual bot. You can of course use Machine Translation as an integral part of your bot like documented [here](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-translation?view=azure-bot-service-4.0&tabs=cs).
3+
4+
In other cases, you might want to manage the translation and localization for the language generation content for your bot independently.
5+
6+
Translate command in the @microsoft/bf-lg-cli library takes advantage of the [Microsoft text translation API](https://docs.microsoft.com/en-us/azure/cognitive-services/translator/) to automatically machine translate .lg files to one or more than [60+ languages](https://aka.ms/translate-langs) supported by the Microsoft text translation cognitive service.
7+
8+
## What is translated?
9+
- An .lg file and optionally translate
10+
- Comments in the lg file
11+
- LG reference link texts
12+
- List of .lg files under a specific path.
13+
14+
When translating .lg file,
15+
- [Template](https://aka.ms/lg-file-format) names are not translated
16+
- [Property](https://aka.ms/lg-file-format) names in structured response templates are not translated
17+
18+
```
19+
>bf lg:translate
20+
21+
OPTIONS
22+
-f, --force If --out flag is provided with the path to an existing file, overwrites that file
23+
-h, --help lg:translate help
24+
-i, --in=in (required) .lg file or folder that contains .lg file.
25+
-o, --out=out Output file or folder name. If not specified stdout will be used as output
26+
-r, --recurse Consider sub-folders to find .lg file(s)
27+
--srclang=srclang Source lang code. Auto detect if missing.
28+
--tgtlang=tgtlang (required) Comma separated list of target languages.
29+
--translate_comments Machine translate all comments found in .lg file
30+
--translate_link_text Machine translate link description in .lg file
31+
--translatekey=translatekey (required) Machine translation endpoint key.
32+
```
33+
34+
## Getting keys
35+
lg:translate command expects a Machine translation subscription key. You can obtain one [here](https://aka.ms/translate-key)

0 commit comments

Comments
 (0)