Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“Translate a language in Java” can mean two different jobs:

  • Localize your application: show interface text and other known content in a user’s locale. Java provides Locale and ResourceBundle for this, but you must supply the translations.
  • Translate arbitrary text at runtime: send dynamic text to a machine-translation service such as Google Cloud Translation or Amazon Translate.

Java has no built-in offline engine that automatically translates arbitrary sentences. Choose resource bundles for a finite, reviewable set of messages; use a hosted translation API when the content is dynamic or too extensive to maintain manually.

Localize a Java application with ResourceBundle

For menus, labels, validation messages, emails, and other text controlled by your application, keep one stable message key in code and provide a value for each supported locale. ResourceBundle loads the resource set appropriate for a selected Locale. PropertyResourceBundle is the common implementation backed by .properties files.

1. Create the bundle files

Put the files on the application class path, for example in src/main/resources:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Messages.properties
welcome=Welcome, {0}!
login.button=Sign in

Messages_fr.properties
welcome=Bienvenue, {0} !
login.button=Se connecter

Messages_de.properties
welcome=Willkommen, {0}!
login.button=Anmelden

The base file is the fallback. Locale-specific files contain the translations authored by your team; Java does not generate those values.

2. Select a locale and load the bundle

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public class LocalizedMessages {
    public static String welcome(Locale locale, String name) {
        ResourceBundle messages = ResourceBundle.getBundle("Messages", locale);
        String template = messages.getString("welcome");
        return MessageFormat.format(template, name);
    }

    public static void main(String[] args) {
        System.out.println(welcome(Locale.FRENCH, "Sam"));
        System.out.println(welcome(Locale.GERMAN, "Sam"));
    }
}

getBundle("Messages", locale) uses the bundle base name and requested locale. Java searches for the most specific matching bundle and falls back through less-specific candidates and the base bundle. If no key is available in the resulting bundle hierarchy, a MissingResourceException can be thrown.

3. Keep complete messages and use parameters

Do not build sentences by concatenating translated fragments. Word order, punctuation, plural rules, and grammatical gender can differ between languages. Store a complete message and insert values with MessageFormat or a message-formatting library suited to your framework.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
// Prefer one translatable message:
items.summary=You have {0} items.

// Avoid assembling a sentence from separate fragments:
// "You have " + count + " items."

Have translators review the complete context, including screenshots and notes about placeholders. Treat message keys as an API: renaming a key without updating every bundle creates runtime failures or unintended fallback text.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Locale selection is separate from translation

A Locale identifies language and, optionally, region or script, such as en, en-GB, or zh-Hant-TW. Decide where the user’s preference comes from—browser headers, an account setting, an operating-system setting, or an explicit application choice—and pass that locale through the presentation layer.

Localization also includes formatting data, not just words. Use locale-aware classes for dates, numbers, currencies, and messages rather than hard-coding formats:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
import java.text.NumberFormat;
import java.util.Locale;

NumberFormat currency = NumberFormat.getCurrencyInstance(Locale.GERMANY);
String formatted = currency.format(1234.50);

Formatting APIs do not translate arbitrary prose, and resource bundles do not automatically change number or date formatting. Handle both concerns deliberately.

Translate dynamic text with a machine-translation API

If users submit text that you did not know when the application was shipped—support tickets, chat messages, uploaded documents, or catalog content—call a translation provider from your server. A typical request supplies source language (when known), target language, and one or more text segments. The provider returns translated text and may apply provider-specific limits and options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Google Cloud Translation

Google Cloud provides a Java client library for Cloud Translation. The Java integration is intended for server-side Java applications; Google’s client-library documentation explicitly says that this Java client does not support Android. Android applications need another supported integration approach, such as calling an HTTPS service from an appropriate backend or using a client supported by the provider.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

The client library is published under the artifact name com.google.cloud:google-cloud-translate. Dependency versions change, so use the version shown in the current Google Cloud documentation rather than copying an old version from an example.

A request conceptually contains these fields:

source language: "en"          // optional when auto-detection is supported
 target language: "fr"
 contents: ["Your account is ready."]

Cloud Translation has Basic and Advanced capabilities. Advanced features include options such as glossaries and document translation. Google documents special handling for HTML: tags are preserved while text between them is translated to the extent supported by the service. XML markup is not supported by the cited documentation, and behavior for other markup is undefined. Validate and sanitize markup before sending it.

Amazon Translate

Amazon Translate is available through the AWS SDK for Java 2.x. Its client supports synchronous text translation, while a document operation accepts text, HTML, or Word input subject to AWS’s documented language-direction and feature constraints.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Use the AWS SDK client from a backend with credentials supplied through the normal AWS credential-provider chain. Do not embed long-lived cloud credentials in a desktop or Android application. Check the current AWS documentation for supported language pairs, regions, document limits, and whether options such as formality apply to your target language; AWS notes that a formality parameter fails for languages that do not support it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Resource bundles or an API?

Question ResourceBundle files Hosted translation API
What content fits? Finite, stable interface messages and other maintained resources. Dynamic or large volumes of user-generated and business content.
Where do translations come from? Your translators or localization team author the bundle values. The provider’s machine-translation service returns a result at request time.
Offline operation Works with packaged resources and no network request. Requires network access to the provider unless you operate a separate on-premises model.
Review and consistency Easy to version, test, review, and approve before release. Needs monitoring and, for important text, human review or post-editing.
Customization You control every string directly. Features such as glossaries depend on the provider and service edition.
Platform considerations Runs wherever your Java application runs. Use a provider integration supported by your platform; Google’s Java client does not support Android.
Documents and markup You must implement your own document workflow. Provider-specific document and markup support, limits, and language restrictions apply.
Cost and data handling No per-request translation-service charge, but localization work remains. Pricing, retention, regional processing, quotas, and terms vary; verify the current provider documentation.

A practical architecture for both needs

  1. Localize the product shell with bundles. Store buttons, navigation, errors, and other known messages under stable keys.
  2. Keep locale and formatting decisions in one layer. Pass the selected Locale to views and use locale-aware date, number, and currency formatters.
  3. Translate dynamic content behind a server boundary. Your backend can authenticate to the provider, enforce quotas, redact sensitive fields, cache permitted results, and provide a consistent interface to web and mobile clients.
  4. Define failure behavior. If a translation request times out or is rejected, show the original text or a clearly labeled fallback; do not silently present an empty message.
  5. Review important output. Machine translation can require human correction, especially for legal, medical, safety-critical, brand-sensitive, or highly contextual text.

Common mistakes to avoid

  • Assuming ResourceBundle translates text. It only selects resources that you supplied.
  • Using sentence fragments that force translators into one language’s word order.
  • Hard-coding a single default locale or assuming language alone determines formatting.
  • Sending secrets, personal data, or confidential documents to a provider without checking your organization’s requirements and the provider’s current terms.
  • Calling a cloud API directly from an untrusted client with embedded credentials.
  • Assuming a language pair, document type, markup format, feature, region, quota, or price is available without checking the provider’s current service listings.
  • Treating machine output as publication-ready without review.

Choosing the right approach

Use ResourceBundle when the application owns a known set of messages and you need deterministic, testable, offline behavior. Use Google Cloud Translation or Amazon Translate when text arrives at runtime or maintaining every possible source sentence as a bundle is impractical. Before committing to a provider, verify supported language directions, Android or other platform constraints, text versus document requirements, glossary or terminology features, privacy and deployment rules, quotas, and current pricing.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.