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 MyCustomComponentuseLocalize 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 MyCustomComponentLast updated
Was this helpful?
