Multilingual Menu stored in the database

4 years ago

Armin Schmidtke
Member | 20
+
0
-

Hi folks,
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!

4 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

Hey, what exactly do you need to know? What do you want to achieve?

4 years ago

Armin Schmidtke
Member | 20
+
0
-

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?

4 years ago

Tomáš Votruba
Moderator | 1154
+
+1
-

I see.

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:

Last edited by Tomáš Votruba (2016-06-05 11:20)

4 years ago

Armin Schmidtke
Member | 20
+
0
-

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 specifically.
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?

4 years ago

Armin Schmidtke
Member | 20
+
0
-

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.

4 years ago

Tomáš Votruba
Moderator | 1154
+
+1
-

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.

4 years ago

Armin Schmidtke
Member | 20
+
0
-

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 (:

4 years ago

Tomáš Votruba
Moderator | 1154
+
+1
-

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.

4 years ago

Armin Schmidtke
Member | 20
+
+1
-

Thanks!! I added your link to my bookmarks 👍

3 years ago

obertuckerz112
Member | 3
+
0
-

I'm trying to determine where the menu names for our Joomla site are stored. For instance, we have one of the pre-installed menus, called “mainmenu”, but I'm not sure where “mainmenu”, the name of the menu itself, is stored.