Skip to content

Frontend Localization documentation appears incorrect or incomplete #6003

Closed Answered by marcobax
pstephan1187 asked this question in Q&A
Discussion options

You must be logged in to vote

For those who come across this discussion and want to use it in a nova-component tool, here's how to correctly use this functionality:

  1. Create a (resource) tool
  2. Open up nova-components/<your-tool>/src/ToolServiceProvider.php
  3. Create the directory nova-components/<your-tool>/resources/lang
  4. Create a file en.json into the new directory
  5. Add below code

Nova::translations(__DIR__.'/../resources/lang/en.json');
or when using multiple locales
Nova::translations(__DIR__.'/../resources/lang/' . app()->getLocale() . '.json');

Now add a translation key and value into the en.json file.

{
    "My translation key": "My value"
}

Open up your Tool.vue file in the resources/js/components directory and use…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by crynobone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants