what is your preferred way / best practices to store a multilingual menu in a database with nette?
I'm trying to figure out a simple way for multilingual support and future translations, if there will be added any additional language.
Thanks for any advice!
I'm looking for a good starting point on how to achieve a clean multilingual menu dynamically from the database. My problem, I don't know exactly how to start. So this was meant more global if anybody has some best practise, an example link to an app on github or any advice?
After I made my own “Menu builder”, I've decided to drop it and to use something more established and standardized. Worth it :)
I meant to say I have good experience with KnpMenu package.
Some year ago made also an repository with implementation to Nette. Check it for inspiration.
There are 2 good starting points:
- EventSubscriber that adds item's to the menu – this the place for getting items from database
- test, that validates this
Last edited by Tomáš Votruba (2016-06-05 11:20)
Cool, this package looks good. Thanks a lot for taking your time and helping me out! This already solved another problem I had and I was researching for.
But even with this package I have still no clue on how to translate my menu.
Maybe my preview posts didn't make much sense so let me try to explain it more
I'm writing a Blog where my Categories are the main menu. The app uses Kdyby/Translation which works great. But how can I store the translations of the menu in the database?
just came up with something this:
Table "categories": ---------------- id : int Table "category_translations" --------------------------- category_id : int language : varchar name : varchar <any other localized data>
I guess my question is a bit off topic because it isn't really related to nette but more on how I design the database. Sorry for that.
Well, Kdyby\Translation is rather for string translations, not dynamic ones. There had been some PR for database translations, but I don't recall it was finished.
But I have some good news too! If you use Doctrine, the solution would be simple.
For translated entities you can use:
Then decorate your entities with traits as in following example.
No, I'm not using Doctrine.. Anyway, thanks a lot for your help!! I'll think about it. It's a small project (a Blog where I want to post articles in multiple languages) so I may stick to something like I posted earlier. But your solution is definitely worth to try out on the next project.
I just need some time to get comfortable with doctrine (:
I understand that, Doctrine needs time :)
I think I can make learning Doctrine easier for you.
There is a nice list with selection of top Doctrine resources, from slides, videos or articles to blog series. Mostly up to date and from recent years.
Check it out, when you need it – Awesome Doctrine.