Thanks for reading this.
I have two separate websites based on Laravel but connected to the same database. I don't want to use two databases because my two sites are related in content and differs basicaly only at language and some graphic elements. Thus, I believe it's much better to have just one DB.
The problem is, I would need to translate categories names from database. Currently is my approach this:
<div class="widget-body">
<ul class="categories">
@if(isset($categories))
@foreach ($categories as $category)
<li>
<a href=""><i class="fa fa-angle-right"></i></a>
<span class="badge pull-right"></span>
</li>
@endforeach
@endif
</ul>
</div>
What would you suggest for translating them?
Solutions that I had in my mind:
-
Just create second column in database. But I had rejected this idea very quickly. I think it's very bad solution, which brings unnecessary records and wasted database space. I think it's against common good database practises. If I would add another site to this webiste family, that would be even worse.
-
Translate it with JavaScript. That seems to me like quite good idea. But it can maybe bring slight permormance issues(?).
-
Use PHP condition.
There is a problem for solution 2. and 3. because every time new category is created, I would need to edit code. On the other hand, categories are not created that frequently.
Which soulution do you think is the best? Or is there any better solution I'm missing that you would suggest? Maybe some Laravel feature or PHP trick?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire