当前位置:网站首页>Operation instructions of star boundary automatic text translator (advanced version)

Operation instructions of star boundary automatic text translator (advanced version)

2022-04-23 14:11:00 Senzhiqianshou

Preface

The advanced version of automatic text translator has finally been developed , Previously, pure html Develop the graphical interface of , But it's not automatic enough , Need to manually locate file copy overwrite . Theories like this can be used python Development , But I only know the front end and Android . So I found a compromise , use nodeJS Development .

Tool features

Cross platform

Support multiple operating systems , Include WindowsLinuxMac

Baidu translation API

Use free ( The standard version ). Support term base ( premium ). The advanced version has a month 200 Million free character access . Standard Edition unlimited use . Because of the shit stick, especially FU There are many new words in it , Adopt term base , It can greatly reduce the problem of inaccurate translation .

Automatic translation

Just a simple command , Can automatically translate all files in the specified directory

Use the tutorial

One 、 Register Baidu translation account , obtain key and appid

You can refer to the previous Semi automatic translation tutorial

Two 、 Installation configuration node

1、 Download installation package

Get into node Official website , Select the platform version corresponding to your system , With windows For example , branch 32 Bit version and 64 Bit version , If you don't clear it, choose 32 position , because 64 Bit compatible 32 Bit program , But today's systems are generally 64 Bit . After downloading, double-click install , No brain, just click next .
node download

2、 Check whether the installation is successful

win+R Call out ’ function ‘, Input cmd
 terminal
determine , Open the terminal , type

node -v

If you can see it node Version information for , Proof of successful installation
cmd

It should be noted that , If your account is not Administrator Account , This step and even subsequent steps may fail . Then you need to call Administrator authority PowerShell. The opening mode is , Hold down shift Right click at the same time win The logo of :
powershell

3、 Download the configuration tool file

Download address :github Portal
Enter the root directory of the source code , It's better not to have Chinese path , In the blank area shift+ Right click , Call up here to open powershell
 here
Type the following command for dependent installation .

npm install

 Insert picture description here
The above picture is a successful screenshot . There may be anti-virus software alarm during installation , allow . In addition, as mentioned earlier , No Adminstrtor In terms of account , Running instructions may fail , Just open the administrator's powershell then cd Enter the source directory for installation .

Next, find the root directory project.config.js file
project.cfg

/** *  Baidu translation api Of key * @type {string} */
const BD_TRANSLATE_KEY = ''
/** *  Baidu translated api Of appid * @type {string} */
const BD_TRANSLATE_APP_ID = ''
/** *  The delay between translated documents , Too often can lead to api Call failed  * @type {number}  millisecond  */
const TRANSLATE_DELAY = 5000
/** *  Whether to overwrite the translation  * @type {boolean} true-- The previous translation will cover the translation  false-- Filter out the previously translated  */
const TRANSLATE_COVER = false
/** *  The source of the translation directory  * @type {string} */
const TARGET_PATH='G:\\workspace\\StarBound\\FrackinUniverse-sChinese-Project\\translations\\texts\\objects\\mantizi'

The relevant configuration is described above , The first two items are translated by Baidu key and appid, It should be noted that TARGET_PATH This target source directory ,windows The file separator under is \, And fill in , To add escape characters , That is, two backslashes .

thus , The project configuration is completed , The next step is to translate instructions .

3、 ... and 、 Perform translation

What we need to do is src Under the folder exe.js file , So first cd Into the src Catalog , Run again node Instructions

PS G:\workspace\StarBound\starbound_auto_transalator_advanced> cd .\src\
PS G:\workspace\StarBound\starbound_auto_transalator_advanced\src> node .\exe.js

On the surface of the above TARGET_PATH For example , After this command is executed, a message appears

[G:\workspace\StarBound\FrackinUniverse-sChinese-Project\translations\texts\objects\mantizi\imperialbanner1\imperialbanner1.object.json
]
 File opened successfully :3  Ready to read :
 Translation results 
 The current file has been translated completely , Skip the file 
------------------------------------------------------------------
 Currently processing file No 2 File :
[G:\workspace\StarBound\FrackinUniverse-sChinese-Project\translations\texts\objects\mantizi\imperialbanner2\imperialbanner2.object.json
]
 File opened successfully :4  Ready to read :
 Find text to be translated :
{
    
  '0': 'A beautifully woven banner.',
  '1': 'A bright woven banner. I wonder what the jewel in the middle means.',
  '2': 'A sun? Or some kind of creature?',
  '3': 'A thick woven banner depicting the imperial crest.',
  '4': 'Floran usually avoid this sssymbol.',
  '5': 'I enjoy the golden accents woven into the fabric.',
  '6': 'Is the Empire nearby?',
  '7': 'Mantizi Imperial Banner',
  '8': 'Servire Imperium.',
  '9': 'This banner looks like it has a beetle woven on it.'
}
 Request parameter composition result :
A beautifully woven banner.
A bright woven banner. I wonder what the jewel in the middle means.
A sun? Or some kind of creature?
A thick woven banner depicting the imperial crest.
Floran usually avoid this sssymbol.
I enjoy the golden accents woven into the fabric.
Is the Empire nearby?
Mantizi Imperial Banner
Servire Imperium.
This banner looks like it has a beetle woven on it.
 Translation results 
[
  {
     src: 'A beautifully woven banner.', dst: ' Weave exquisite flags .' },
  {
    
    src: 'A bright woven banner. I wonder what the jewel in the middle means.',
    dst: ' Bright woven banners . I want to know what the jewelry in the middle means .'
  },
  {
     src: 'A sun? Or some kind of creature?', dst: ' The sun ? Or some kind of creature ?' },
  {
    
    src: 'A thick woven banner depicting the imperial crest.',
    dst: ' A thick woven banner depicting a crown .'
  },
  {
     src: 'Floran usually avoid this sssymbol.', dst: ' Florian usually avoids using this symbol .' },
  {
    
    src: 'I enjoy the golden accents woven into the fabric.',
    dst: ' I like the golden accent woven into the fabric .'
  },
  {
     src: 'Is the Empire nearby?', dst: ' Is the Empire nearby ?' },
  {
     src: 'Mantizi Imperial Banner', dst: ' Mantiz Empire flag ' },
  {
     src: 'Servire Imperium.', dst: ' Imperial service .' },
  {
    
    src: 'This banner looks like it has a beetle woven on it.',
    dst: ' This banner seems to be weaving a beetle .'
  }
]
------------------------------------------------------------------
 Recombination result 
[
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
     Eng: 'A beautifully woven banner.', Chs: ' Weave exquisite flags .' }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
    
      Eng: 'A bright woven banner. I wonder what the jewel in the middle means.',
      Chs: ' Bright woven banners . I want to know what the jewelry in the middle means .'
    }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
     Eng: 'A sun? Or some kind of creature?', Chs: ' The sun ? Or some kind of creature ?' }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
    
      Eng: 'A thick woven banner depicting the imperial crest.',
      Chs: ' A thick woven banner depicting a crown .'
    }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
    
      Eng: 'Floran usually avoid this sssymbol.',
      Chs: ' Florian usually avoids using this symbol .'
    }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
    
      Eng: 'I enjoy the golden accents woven into the fabric.',
      Chs: ' I like the golden accent woven into the fabric .'
    }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
     Eng: 'Is the Empire nearby?', Chs: ' Is the Empire nearby ?' }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
     Chs: 'Mantizi Empire banner ', Eng: 'Mantizi Imperial Banner' }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
     Chs: ' Serve the Empire .', Eng: 'Servire Imperium.' }
  },
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialbanner2/imperialbanner2.object': [Array]
    },
    Texts: {
    
      Eng: 'This banner looks like it has a beetle woven on it.',
      Chs: ' This banner seems to be weaving a beetle .'
    }
  }
]

From the information on the console, you can see the information of the current translation file , When the configuration does not overwrite the translation , Will automatically skip the translated files , Increase translation efficiency .
There will also be corresponding prompts after successful translation :

 Currently processing file No 35 File :
[G:\workspace\StarBound\FrackinUniverse-sChinese-Project\translations\texts\objects\mantizi\shared_imperialvaselarge\shared_imperialvas
elarge.json]
 File opened successfully :4  Ready to read :
 Find text to be translated :
{
     '0': 'A large decorative glazed vase.' }
 Request parameter composition result :
A large decorative glazed vase.
 Translation results 
[ {
     src: 'A large decorative glazed vase.', dst: ' A large decorative glass vase .' } ]
------------------------------------------------------------------
 Recombination result 
[
  {
    
    DeniedAlternatives: [],
    Files: {
    
      'objects/mantizi/imperialvaselarge1/imperialvaselarge1.object': [Array],
      'objects/mantizi/imperialvaselarge2/imperialvaselarge2.object': [Array]
    },
    Texts: {
     Eng: 'A large decorative glazed vase.', Chs: ' A large decorative glass vase .' }
  }
]
*********** All documents have been translated **********

Four 、 Set up the term library

This step is not necessary , However, setting up a term base can increase the accuracy of translation , At present, I have collected some information about minerals 、 Liquid and NPC Terms related to names , The file in doc Below directory :
 Glossary
stay Baidu translation platform You can configure the
 Configure term library

版权声明
本文为[Senzhiqianshou]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231405036828.html