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
  • translate()
  • translateObject()
  • getBrowserLang()
  • getBrowserCultureLang()

Was this helpful?

  1. Additional Functionality

Utility Functions

translate()

The translate() function allows you to translate a single key without needing to inject the TranslocoService each time.

import { translate } from '@jsverse/transloco';

translate('hello');

Important This function is a proxy to the TranslocoService.translate method. It will not work if the service hasn't been initialized. Ensure that the translation files are successfully loaded before calling this method.

translateObject()

The translateObject() function allows you to translate an entire object, similarly to the translate() function, without needing to inject the service.

import { translateObject } from '@jsverse/transloco';

translateObject('some.object');

Important This function is a proxy to the TranslocoService.translateObject method. It will not work if the service hasn't been initialized. Ensure that the translation files are successfully loaded before calling this method.


getBrowserLang()

The getBrowserLang() function returns the language code (e.g., "en") detected from the user's browser settings.

import { getBrowserLang } from '@jsverse/transloco';

getBrowserLang();

getBrowserCultureLang()

The getBrowserCultureLang() function returns the culture language code (e.g., "en-US") detected from the user's browser settings.

import { getBrowserCultureLang } from '@jsverse/transloco';

getBrowserCultureLang();
PreviousKey ReferencingNextComments for Translators

Last updated 5 months ago

Was this helpful?

โš™๏ธ