Coder Social home page Coder Social logo

naver-translation-localapp's Introduction

Naver Translation API Python 3.11 Sample

Originally meant to use for myself, but it's very usable so I'm updating the readme.

Prepare

  1. Install Python 3. You'll need to install Python 3.9 or later.
  2. Clone this git.
  3. Create translationApp/secret.py based on translationApp/secret-example.py.
  • Since it's using OpenAPI but you need "App" created, API configuration is required.

Practice

Run: shell

python3 ./app.py

Run: windows (Both CMD and Powershell)

ren Please note that you've installed Python 3.
ren If you installed both Python 2 and 3, maybe you'll need to
ren use python3 to properly boot the app.
python .\app.py

Source String Syntax

You should type \n for line breaks on input.
On output, the raw \n will be automatically decoded to line breaks.

Output example if success

Before you start, you can change the default language type
of your inputs and target at ./translationApp/settings.py.
The target is set to "ko" as default,
so you might want to change it.


Please input the string to translate and press Enter
(Input line break as \n): <Type your own source string> [ENTER]

Please type which language you've entered
(If you don't know, please enter "auto"
 or leave it as blank.)


e.g. korean -> ko | english -> en | japanese -> ja
Please check the list from here: https://developers.naver.com/docs/papago/papago-detectlangs-overview.md
Type here: <Type the lang code> [ENTER]
Source language has set to (your input)

Please type which language you're to translate into
(If you want to use this from settings
 (at "translationApp/settings.py"),
 leave it blank.)

e.g. korean -> ko | english -> en | japanese -> ja
Type here: <Type the lang code> [ENTER]
Target language has set to (your input)

Translation successful!

Source language: (your input or detected)
Target Language: (your input)

Result:
(Translation result displays here. Line breaks are auto-applied.)

Secret

This app uses NAVER OpenAPI which is for registered applications.
You should register your app to Naver Developers.

After that you'll have to create secret file.
The example file is included in this repositiory.
Please check secret-example.py for more details.

Default language I/O settings

You can set the default I/O language code at settings.py.
The language code you can use can be found here.

Source language can be set to auto, which is "automatical detection".
Target language can't be set to auto.

Prompt will be displayed to override the language settings when running.
You can just press Enter to skip.
To override, type the code there.

Troubleshooting

I've done the minimum test for this app, so you'll meet some exceptions.
Please raise issues if found.

You'll have to include Python version, OS type, and the tracebacks.
Please hide your secrets from traceback!

My test environment

  • Python: 3.11.2, x64 (Python 3.9 works)
  • OS: Windows 11 Pro
    • Locale: ko-KR
    • Code page: 949 MS949 (65001 UTF-8 support for modern CLI apps)
  • Tested file encoding: CRLF, LF

naver-translation-localapp's People

Contributors

hotoras avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.