|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "os" |
| 6 | + "path/filepath" |
| 7 | + "runtime" |
| 8 | + |
| 9 | + "github.com/WindMillCode/vscode-extension-libraries/windmillcode-extension-pack-0/task_files/go_scripts/utils" |
| 10 | +) |
| 11 | + |
| 12 | +func main() { |
| 13 | + |
| 14 | + utils.CDToWorkspaceRooot() |
| 15 | + workspaceRoot, _ := os.Getwd() |
| 16 | + i18nLocation := filepath.Join(workspaceRoot, "apps", "frontend", "AngularApp", "src", "assets", "i18n") |
| 17 | + settings, err := utils.GetSettingsJSON(workspaceRoot) |
| 18 | + if err != nil { |
| 19 | + return |
| 20 | + } |
| 21 | + |
| 22 | + openAIAPIKey := utils.GetInputFromStdin( |
| 23 | + utils.GetInputFromStdinStruct{ |
| 24 | + Prompt: []string{"provide the open ai api key"}, |
| 25 | + ErrMsg: "an open ai key is required to translate the app", |
| 26 | + Default: settings.ExtensionPack.OpenAIAPIKey0, |
| 27 | + }, |
| 28 | + ) |
| 29 | + langCodes := utils.GetInputFromStdin( |
| 30 | + utils.GetInputFromStdinStruct{ |
| 31 | + Prompt: []string{" Provide a list of lang codes to run \n translation script. \n Provide them in comma separated format according to the options below. \n Example: 'zh, es, hi, bn' \n It's best to do 4 at a time. \n Options: zh, es, hi, uk, ar, bn, ms, fr, de, sw, am"}, |
| 32 | + ErrMsg: "Lang codes are required", |
| 33 | + Default: settings.ExtensionPack.LangCodes0, |
| 34 | + }, |
| 35 | + ) |
| 36 | + |
| 37 | + os.Setenv("OPENAI_API_KEY_0", openAIAPIKey) |
| 38 | + utils.CDToLocation(filepath.Join(workspaceRoot, "ignore", "Windmillcode", "go_scripts", "i18n_script_via_ai")) |
| 39 | + // pathSeparator := string(filepath.Separator) |
| 40 | + i18nScriptLocation, _ := os.Getwd() |
| 41 | + switch os := runtime.GOOS; os { |
| 42 | + case "windows": |
| 43 | + sitePackages := filepath.Join(i18nScriptLocation, "site-packages", "windows") |
| 44 | + // sitePackages = strings.Join([]string{".",sitePackages},pathSeparator) |
| 45 | + if utils.FolderExists(sitePackages) == false { |
| 46 | + |
| 47 | + utils.RunCommand("pip", []string{"install", "-r", "requirements.txt", "--target", sitePackages}) |
| 48 | + } |
| 49 | + case "linux", "darwin": |
| 50 | + sitePackages := filepath.Join(i18nScriptLocation, "site-packages", "linux") |
| 51 | + // sitePackages = strings.Join([]string{".",sitePackages},pathSeparator) |
| 52 | + if utils.FolderExists(sitePackages) == false { |
| 53 | + utils.RunCommand("pip", []string{"install", "-r", "requirements.txt", "--target", sitePackages}) |
| 54 | + } |
| 55 | + |
| 56 | + default: |
| 57 | + fmt.Println("Unknown Operating System:", os) |
| 58 | + } |
| 59 | + |
| 60 | + utils.RunCommand("python", []string{ |
| 61 | + "index.py", |
| 62 | + "-c", langCodes, "--location", i18nLocation, "--source-file", "en.json", |
| 63 | + }) |
| 64 | +} |
0 commit comments