To see the translation feature, make sure that your Gboard app is updated to version 1.42.0 and then navigate to the Messages app. Open the keyboard, and then tap the globe icon in the bottom left corner to cycle to Gboard. In Gboard, the new translation feature is represented by an icon immediately to the right of the white G button in the top left corner.
From here, you can choose which language you want to translate your text into, and when you tap the translate button it will automatically be applied to the iMessage entry field so you can send it to your contact. The translation feature in Gboard first launched on Android smartphones back in 2017.
Besides translating text, in Gboard you can send GIFs, emoji, stickers, and access features like glide typing and performing a Google search. The keyboard app also connects to other Google services like YouTube, Google Maps, and Google Contacts.