LogoLogo
โค๏ธ SponserMore
  • ๐Ÿš€Getting Started
    • Installation
    • Angular Compatibility
    • Config Options
  • ๐Ÿ’กCore Concepts
    • Translation in the Template
    • Signals
    • Translation API
    • Language API
  • ๐Ÿง Advanced Topics
    • ๐ŸฆฅLazy Load
      • Scope Configuration
      • Inline Loaders
    • The Transpiler
    • SSR Support
    • Unit Testing
    • Hack the Library
  • ๐ŸงชSandbox & Examples
  • โš™๏ธAdditional Functionality
    • Loading Template
    • Key Referencing
    • Utility Functions
    • Comments for Translators
    • Multiple Languages Simultaneously
  • ๐Ÿ“ฆMigration Guides
    • Migrate from ngx-translate
    • Migrate from Angular's i18n
  • ๐Ÿ”งTools
    • Keys Manager (TKM)
      • Keys Extractor
      • Keys Detective
      • Options
      • Debugging
      • Using with Nx ๐Ÿ‹
    • Validator
    • Optimize
    • Scoped Library Extractor
  • ๐Ÿ”ŒPlugins
    • Message Format
    • Persist Translations
    • Persist Lang
    • Preload Langs
    • Locale l10n
    • Community Plugins
  • ๐ŸงฐSchematics
    • :ng-add
    • :scope
    • :join
    • :split
  • ๐ŸณRecipies
    • Prefetch User Language
    • Using Xliff
    • Generate Locale Files using Google Translate
  • ๐Ÿ“šBlog Posts
    • Transloco Team Posts
      • Transloco Goes Functional: A Guide to Transloco's Functional Transpiler
    • From the Community
  • โ“FAQs
Powered by GitBook

@ 2025 Transloco

On this page
  • Key Referencing Within Scopes
  • Passing Parameters to Reused Keys
  • Avoid Circular References

Was this helpful?

  1. Additional Functionality

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:

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

In this case, calling service.translate('fromList') will return: "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:

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

Here, calling service.translate('admin.fromList') will return: "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:

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

In this case, calling service.translate('greet', {name: 'John'}) will return: "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:

en.json
{
  "key": "{{key2}}",
  "key2": "{{key}}"
}

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

PreviousLoading TemplateNextUtility Functions

Last updated 5 months ago

Was this helpful?

โš™๏ธ