> For the complete documentation index, see [llms.txt](https://jsverse.gitbook.io/transloco/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jsverse.gitbook.io/transloco/additional-functionality/key-referencing.md).

# Key Referencing

You can reference specific keys within other keys in the same translation file. This feature allows for dynamic translations, where one key can depend on another.

**Example:**

{% code title="en.json" %}

```json
{
  "alert": "alert {{value}} english",
  "home": "home english",
  "fromList": "from {{home}}"
}
```

{% endcode %}

In this case, calling `service.translate('fromList')` will return:\
\&#xNAN;**"from home english"**.

***

### Key Referencing Within Scopes

When using key references inside a scope, be sure to prefix the referenced key with the scope name.

**Example:**

{% code title="admin/en.json" %}

```json
{
  "alert": "alert {{value}} english",
  "home": "home english",
  "fromList": "from {{admin.home}}"
}
```

{% endcode %}

Here, calling `service.translate('admin.fromList')` will return:\
\&#xNAN;**"from home english"**.

***

### Passing Parameters to Reused Keys

You can also pass parameters to the reused key. This allows you to dynamically insert values into the translation.

**Example:**

{% code title="en.json" %}

```json
{
  "hello": "Hello {{name}},",
  "greet": "{{hello}}, have a good day!"
}
```

{% endcode %}

In this case, calling `service.translate('greet', {name: 'John'})` will return:\
\&#xNAN;**"Hello John, have a good day!"**.

***

### Avoid Circular References

Be cautious when creating key references that may result in circular references. This can lead to infinite loops and unexpected behavior.

**Example:**

{% code title="en.json" %}

```json
{
  "key": "{{key2}}",
  "key2": "{{key}}"
}
```

{% endcode %}

This will create a circular reference, which should be avoided.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://jsverse.gitbook.io/transloco/additional-functionality/key-referencing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
