Welcome Guest, Not a member yet? Register   Sign In
localize databases with working searching and ordering?
#11

For an easy solution, your color tables should be:

color_id - color_name_en - color_name_de - color_name_it etc.

in your Controller you can catch your language easily, it is generally the first segment after your base_url. And also you can catch it after you send the form. You can send the language with a hidden input.

From your Controller to the view, send the current language with:

Code:
$data['lang'] = $this->request->uri->getSegment(1);


Later, it is time to display. No need for the translation file. Just catch your $lang variable and on top of your site, in a common file - maybe a top menu one - set your names :

Code:
<?php

$color_name_lang = 'color_name_'.$lang;

?>



And wherever you want to display them:

Code:
<ul>

<?php foreach($colors as $color) { ?>

    <li><?php echo $color->$color_name_lang; ?></li>

<?php } ?>

</ul>


This part is important. Not $color->color_name_lang but $color->$color_name_lang

Hope it helps

P.S. You are going to make your search via color_id, not names. Names are just sth visual that you display.
Reply


Messages In This Thread
RE: localize databases with working searching and ordering? - by demyr - 06-11-2024, 02:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB