> ## Documentation Index
> Fetch the complete documentation index at: https://ugcore.urging.ch/llms.txt
> Use this file to discover all available pages before exploring further.

# UgLib.Locale

> Translations from your resource's locale files.

<Badge color="purple">Shared</Badge> Runs in your resource.

```lua theme={"dark"}
UgLib.Locale.Create(options?) -> t
UgLib.Locale.GetCode() -> string
t(key, vars?) -> string
```

<ResponseField name="options.resource" type="string">Defaults to the calling resource.</ResponseField>
<ResponseField name="options.fallback" type="string" default="en">Language used when a key is missing.</ResponseField>

* The language is `settings.locale` of ug-lib (convar `ug-lib:Locale`), `en` until config arrives.
* Texts come from `locales/<code>.json`. Keys are flat (`"shop.title"`) or nested objects.
* Placeholders are `{name}`. A missing key falls back to the `fallback` language, then to the key itself, with one Debug log per key.
* Locale files MUST be in your `files {}` to be read on clients.

## Example

```json locales/en.json theme={"dark"}
{ "shop": { "title": "Shop of {owner}" } }
```

```lua fxmanifest.lua theme={"dark"}
files { 'locales/*.json' }
```

```lua theme={"dark"}
local t = UgLib.Locale.Create()

print(t('shop.title', { owner = 'Bob' })) -- Shop of Bob
```


## Related topics

- [Configuration](/ug-lib/configuration.md)
- [UgLib.Version](/ug-lib/version.md)
- [UgLib.Enums](/ug-lib/enums.md)
- [UgLib.Menu](/ug-lib/menu.md)
- [UgLib.Context](/ug-lib/context.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.