Example Code

Google Translate in LabVIEW Using the LabVIEW Python Node.

代码和文档

添加附件

Overview

This example allows you to use Google translate API in LabVIEW through the LabVIEW Python Node.

 

Description

This example consists of Python Node Google Translate.vi and Google_Translate.py. There are methods for using the Google Translate API with Python, and LabVIEW Python Nodes can call these methods to use the Google Translate API in LabVIEW.

 

Among the many features provided by the Google Translate API, the core "Translate" and "Detect" features are written. You must be online on the network to use the Google Translate API.

 

Hardware and Software Requirements

Software:

LabVIEW 2018 or higher

Python 2.7 or 3.6 with the same bitness as LabVIEW.

Google Translate API for Python.

 

Steps to Implement or Execute Code

1. At the command prompt, install googletrans via pip or conda.

pip install googletrans
conda install -c conda-forge googletrans 

2. Open Python Node Google Translate.vi.

3. Select your Python version you installed.

4. Type a sentence into the "Text" control.

5. Set the language to the "Source Language" control. The default is "auto" to automatically detect and translate the language. If you want to choose the language you want, the language options are listed below.

6. Set the language to the "Destination Language" control.

7. Run the VI.

 

[Language options]
'uk': 'ukrainian', 'ps': 'pashto', 'hr': 'croatian', 'ku': 'kurdish (kurmanji)', 'ar': 'arabic', 'so': 'somali', 'vi': 'vietnamese', 'my': 'myanmar (burmese)', 'tr': 'turkish', 'ne': 'nepali', 'bs': 'bosnian', 'es': 'spanish', 'mg': 'malagasy', 'id': 'indonesian', 'ig': 'igbo', 'sk': 'slovak', 'mi': 'maori', 'ro': 'romanian', 'iw': 'hebrew', 'zu': 'zulu', 'st': 'sesotho', 'he': 'Hebrew', 'si': 'sinhala', 'lv': 'latvian', 'fy': 'frisian', 'km': 'khmer', 'no': 'norwegian', 'su': 'sundanese', 'sw': 'swahili', 'fr': 'french', 'gd': 'scots gaelic', 'ta': 'tamil', 'fi': 'finnish', 'tl': 'filipino', 'fil': 'Filipino', 'ny': 'chichewa', 'gu': 'gujarati', 'ru': 'russian', 'pa': 'punjabi', 'sl': 'slovenian', 'ha': 'hausa', 'co': 'corsican', 'la': 'latin', 'sv': 'swedish', 'it': 'italian', 'ceb': 'cebuano', 'sr': 'serbian', 'uz': 'uzbek', 'xh': 'xhosa', 'hi': 'hindi', 'en': 'english', 'nl': 'dutch', 'ur': 'urdu', 'ht': 'haitian creole', 'de': 'german', 'sq': 'albanian', 'te': 'telugu', 'haw': 'hawaiian', 'is': 'icelandic', 'gl': 'galician', 'zh-cn': 'chinese (simplified)', 'ml': 'malayalam', 'el': 'greek', 'ca': 'catalan', 'pl': 'polish', 'lo': 'lao', 'ms': 'malay', 'cs': 'czech', 'th': 'thai', 'zh-tw': 'chinese (traditional)', 'be': 'belarusian', 'mn': 'mongolian', 'bg': 'bulgarian', 'sm': 'samoan', 'eu': 'basque', 'ko': 'korean', 'ka': 'georgian', 'hy': 'armenian', 'yo': 'yoruba', 'kn': 'kannada', 'lt': 'lithuanian', 'eo': 'esperanto', 'et': 'estonian', 'kk': 'kazakh', 'tg': 'tajik', 'mk': 'macedonian', 'jw': 'javanese', 'mt': 'maltese', 'da': 'danish', 'ja': 'japanese', 'fa': 'persian', 'sn': 'shona', 'bn': 'bengali', 'am': 'amharic', 'pt': 'portuguese', 'hu': 'hungarian', 'mr': 'marathi', 'lb': 'luxembourgish', 'ky': 'kyrgyz', 'hmn': 'hmong', 'cy': 'welsh', 'az': 'azerbaijani', 'yi': 'yiddish', 'ga': 'irish', 'sd': 'sindhi', 'af': 'afrikaans'

 

Additional Information or References

Front panel

image.png

NI社区“代码范例交流区”(Example Code Exchange)中的代码范例已获得MIT许可

贡献者