Comments (6)
First, you need to enable it in the configuration 'translate_title' => true,
and then every title will be auto-translated,
'navigation' => [
[
'title' => 'Resource Title', // this will auto transform into __('Resource Title')
.....
'groups' => [
[
'title' => 'Assets', /// and __('Assets')
....
]
]
]
]
however you resource class still needs to be translated through the static label method:
/**
* Get the displayable label of the resource.
*
* @return string
*/
public static function label()
{
return __('Pages');
}
The reason why you can't just call __('Title')
directly inside the config file is that laravel will cache the files, and it will permanently be cached in a single language... so switching language does not work without always cleaning your config cache
from collapsible-resource-manager.
yes i am doing exactly like you suggested.
I meant on this function in your file CollapsibleResourceManager.php
private function translateKey(?string $key): string
{
if ($key && config('collapsible-resource-manager.translate_title', false)) {
return trans($key);
}
return $key;
}
If i replace trans with __() it works, otherwise it doesn't translate. I think we need to replace this function in the function so it works for nova. If there anything else i am missing please let me know.
from collapsible-resource-manager.
I'm not sure what's going on, if you see the __()
function it is just calling trans()
behind the scenes
if (! function_exists('__')) {
/**
* Translate the given message.
*
* @param string|null $key
* @param array $replace
* @param string|null $locale
* @return \Illuminate\Contracts\Translation\Translator|string|array|null
*/
function __($key = null, $replace = [], $locale = null)
{
if (is_null($key)) {
return $key;
}
return trans($key, $replace, $locale);
}
}
And just to confirm are you updating the right file?
from collapsible-resource-manager.
i tried all three paths issue is still there.. but as soon i replace trans function with __() it works.
In nova docs they have mentioned to use __() function here is the reference.
https://nova.laravel.com/docs/2.0/customization/localization.html#overview
My suggestion is we can change to __() instead of trans() if it's ok with you. And i can update from code otherwise i think i can extend class and override the function. But it will help others if we change in the package class itself.
from collapsible-resource-manager.
I just pushed a new version v0.1.7
that uses __()
instead of trans
see if works for you.
This issue is very odd because I'm personally using this package and having multi-language in Chinese/English and it works fine with trans(), perhaps it's your nova version? currently im 2.4.0
and laravel 6
from collapsible-resource-manager.
Thanks a lot, it worked for me.
Yes i also find it strange i have nova 2.4.0 too only difference is laravel 5.8.* but still it should be working it's for you.
Anyway thanks it worked for me now.
from collapsible-resource-manager.
Related Issues (20)
- Vertical menu? HOT 4
- Can you add icon support to MenuGroup? HOT 1
- Append HTML to the top of the collapsible block? HOT 2
- Link to a resource on root section click HOT 3
- Incorrect path MenuSection HOT 6
- Fix design issue
- Feature request: Ability to keep default notification & logout & theme
- Dashboards link doesn't works HOT 3
- There is an extra space between resources and menu not sure why? HOT 1
- Features request: nested navigation and panel width
- Menu doesn't scroll on mobile device HOT 6
- Iconset for menu? HOT 1
- Menu issue on mobile devices HOT 5
- Breaking word to a new line if menu item is too long HOT 2
- Collapsing doesn't work after release v2.0.5 HOT 1
- New feature: close side panel manually HOT 9
- Enable/Disable Toggle Switch HOT 3
- Collapse menu after refresh HOT 1
- Markdown field width split when attribute name is `content`
- Scroll is necesary for desktop too
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from collapsible-resource-manager.