How to translate code into other languages using GitHub Copilot
Tags: beginners, codenewbie, tutorial, productivity
Published: 2022-04-14 14:01:03

Whether you're a seasoned coder, or just starting out, [GitHub Copilot](https://copilot.github.com/)'s new feature will have everyone in a buzz.

If you have access to GitHub Copilot, you can download an additional extension, [GitHub Copilot Labs](https://next.github.com/projects/copilot-labs/). This gives you access to some cool new features. One of these features allows you translate code into any language you choose. Let's show you how to do that.

## Step 1. Install Copilot Labs

Make sure you have [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) installed*. If you have access to Copilot, you'll also be able download and install [GitHub Copilot Labs](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-labs).

## Step 2. Choose code to translate

Open your [VS Code](https://code.visualstudio.com/) editor and open a file where you'd like to translate some code.

Also, make sure you have Copilot turned on. You find the Copilot icon in the bottom tray on the left hand side. Click it, and sure you select "Enable".

![enable-copilot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pp100xay6p2dvvy7gtt8.JPG)

I always click "Enable Globally" because then Copilot works for everything and not just the file I have open.

## Step 3. GitHub Copilot Labs sidebar

The GitHub Copilot Labs sidebar has everything you need to explain and translate code. You'll find the toolbar on the left side of the screen. If you can't see it, click the ellipses and you'll find a list of any additional extensions you have installed.

![toolbar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/abh2iujw4jztu2r2vny8.JPG)

The GitHub Copilot Labs icon will only appear if you have installed GitHub Copilot Labs. Click the icon and it will toggle open a new pane. If you still have your code highlighted, your screen should look something like:

![Copilot Pane](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91wrpjrs7mbyokwg4g3h.JPG)

## Step 4. Highlight Code

Now that you have the Copilot Labs sidebar open, highlight the chunk of code you'd like to translate.

![fizzbuzz](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ukh4urpvw119v4ywhwp.JPG)
 
## Step 5. Translate Code

The GitHub Copilot Labs pane will show a section called "Language Translation". Under this section, your highlighted code will appear, along with a box saying "Translate code into:"

![Translate Language](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ru7jut6ajojkzuty9usv.JPG)

Here, you can choose the language you would like to translate your code into. There are lots of languages to choose from, including Python, Ruby, Java, CSS, PHP, C#, Go, Typescript, and many more.

Select one, and click "Ask Copilot". Your result will be immediately displayed:

![Translate Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1q4t2reb1o9r4nvima8p.JPG)

## Step 6. Feedback

GitHub Copilot and GitHub Copilot Labs are very new features. They are both in technical preview stage. After your code has been translated you'll be able to provide feedback on how well Copilot did.

![feedback](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cs2nosoav1guo508x9i4.JPG)

You can read more about how GitHub Copilot works and the training set that powers this technology by heading to the [Copilot website](https://copilot.github.com/), and clicking "Learn more" in the top right.
 
## Watch the tutorial

{% youtube RBj3BKm54BY %}

*GitHub Copilot is in technical preview, and thus not all users will be able to access this feature. If you'd like to sign up to the technical preview, please [join the waitlist](https://github.com/features/copilot/signup).