# LocaleService
> Reads translations, with fallback from the requested locale to the default locale to the raw key.
`gg.lode.bookshelflocales.LocaleService`
---
## Signature
```java
public interface LocaleService
```
Implemented by [[LocaleManager]].
---
## Methods
### Reading
| Method | Return Type | Description |
|--------|-------------|-------------|
| `get(String translationKey)` | `Component` | Rendered translation in the default locale. |
| `get(String translationKey, String languageCode)` | `Component` | Rendered translation in a locale. |
| `get(String translationKey, String languageCode, VariableContext context)` | `Component` | Rendered with placeholders applied. |
| `_get(String translationKey)` | `String` | Raw MiniMessage string, default locale. |
| `_get(String translationKey, String languageCode)` | `String` | Raw MiniMessage string in a locale. |
| `_get(String translationKey, String languageCode, VariableContext context)` | `String` | Raw string with placeholders applied. |
| `getIntoList(String translationKey)` | `List<Component>` | One component per line, default locale. |
| `getIntoList(String translationKey, String languageCode)` | `List<Component>` | One component per line. |
| `getIntoList(String translationKey, String languageCode, VariableContext context)` | `List<Component>` | One component per line, with placeholders. |
| `_getIntoList(...)` | `List<String>` | Same three overloads, as raw strings. |
Values split into lines on `\n` and on `<br>`. Rendered components have italics explicitly disabled, since the same strings serve chat and item lore.
### Inspecting
| Method | Return Type | Description |
|--------|-------------|-------------|
| `hasLocale(String languageCode)` | `boolean` | Whether that locale loaded at all. |
| `hasKey(String translationKey, String languageCode)` | `boolean` | Whether that locale defines the key itself, ignoring fallback. |
| `getLocales()` | `List<String>` | Loaded codes, ordered by `locale.sort_order` then display name. |
| `getDisplayName(String languageCode)` | `String` | The locale's own name for itself, or its code when unset. |
| `getDefaultLocale()` | `String` | The fallback locale. |
| `setDefaultLocale(String languageCode)` | `void` | Changes the fallback locale at runtime. |
### Reloading
| Method | Return Type | Description |
|--------|-------------|-------------|
| `reload()` | `void` | Re-reads every source, network included. |
| `reloadFromDisk()` | `void` | Re-reads local sources only. No network, works offline. |
| `reloadFromCloud()` | `void` | Re-fetches remote sources only. Blocks on HTTP. |
[[LocaleManager]] adds async variants of all three.
---
## Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| `translationKey` | `String` | Key to look up, e.g. `myplugin.welcome`. |
| `languageCode` | `String` | Locale code, e.g. `en_us`. Case-insensitive. `null` means the default locale. |
| `context` | `VariableContext` | Placeholder values substituted into the resolved string. |
---
## Fallback Order
Every lookup falls back the same way:
1. The requested locale
2. The default locale
3. The translation key itself
Because of step 3, a plugin with no locale files still runs — it renders raw keys.
---
## Usage
```java
String locale = locales.localeOrDefault(player.locale().toString());
player.sendMessage(locales.get("myplugin.welcome", locale,
VariableContext.of("player", player.getName())));
List<Component> lore = locales.getIntoList("myplugin.lore", locale);
```
---
## Related Pages
- [[LocaleManager]]
- [[LocaleSource]]
- [[Bookshelf/Developers/Locales]]