Dashboard-Plugin
Docs HomeDashboard plugins and appsInfomakerNaviga global
  • About
  • Intro
  • Getting started
  • The anatomy of a plugin
  • Manifest structure
  • Getting started
    • Get Dashboard-Plugin
    • Build
  • What's new
  • Components
    • Agent
      • Actions
    • Application
    • Widget
    • Health
    • Modal
    • Settings
  • API and GUI
    • API
      • Overview
      • register
        • Reducers
        • Portals
        • Requirements
        • Permissions
        • Default config
        • Config Modifiers
      • cache
      • store
      • encrypt
      • decrypt
      • createUUID
      • getLanguage
      • getTextDirection
      • getTimeFormat
      • getKeyCharFromCode
      • getKeyCodeFromChar
      • event
      • Logger
      • buildRouteUrlWithDispatchableEvent
      • getUser
      • getAction
      • getPortal
      • getConfig
      • getLocalize
      • getAvailableActions
      • getAvailablePortals
      • request
      • setHealth
      • openModal
      • closeModal
      • confirm
      • notifications
      • hasPermission
      • standalone
      • withUser
      • useModal
      • useSheet
      • useUser
      • useConfig
      • useLocalize
      • useApplication
      • useMappings
      • useStandalone
    • GUI
      • Core GUI
      • Style-Guide
    • Modules
      • GUI
      • Utility
      • NavigaID
        • getUserToken
        • getApplicationToken
        • getGroupsFromToken
  • Mappings
  • Plugins deployments
  • S3 upload
  • Deprecations
    • 4.1.0
    • 4.0.0
    • 2.1.0
Powered by GitBook
On this page

Was this helpful?

  1. API and GUI
  2. API

useLocalize

useLocalize is a helper hook that will return the plugin's localizations

How to use

import { Plugin } from '@root'

const MyCustomComponent = () => {
    const localization = Plugin.useLocalize()
    
    return (
        <div>
            <p>title: {localization.myLocalizedTitle}</p>
        </div>
    )
}

export default MyCustomComponent

useLocalize accepts a selector as an argument to select a part of the localization object instead of returning all

Let's say that your localization object looks something like this:

{
    [...]
    
    error_pages: {
        not_found: "404 page not found",
        internal_error: "500 Internal error occurred"
    }
    
    [...]
}

And you want to get the error_handlers object in your code:

import { Plugin } from '@root'
import { useEffect } from 'react'

const MyCustomComponent = () => {
    const localizedErrroMessages = Plugin.useLocalize(lc => lc.error_pages)
    
    return (
        <div>
            <p>{localizedErrroMessages.not_found}</p>
        </div>
    )
}

export default MyCustomComponent
PrevioususeConfigNextuseApplication

Last updated 4 years ago

Was this helpful?