php - What is the most effective way to translate string names from database in Laravel -
i building small social network language select. problem i'm clueless have user groups saved in database.
id name 1 model 2 photographer 3 makeup artist
i select these , place in signup form
<div class="form-group"> {{ form::label('group', lang::get('auth.group'), array("class" => "col-lg-3 control-label ")) }} <div class="col-lg-8"> <select class="col-lg-12" name="group_id[]" id="" multiple size="6" > @foreach($groups $group) <option value="{{ $group->id }}">{{ $group->name }}</option> @endforeach </select> </div> </div>
but i'm totally clueless how translate these, using laravel's localization
.
could please give me hint this?
if want localize string come database, have store keys database tables. in views translate in laravel.
a database table have following structure (note apart name store key):
------------------------------------------- | id | name | namekey | =========================================== | 1 | model | group.model | | 2 | photographer | group.photographer | | 3 | makeup artist | group.makeupartist | -------------------------------------------
the name not me mandatory, useful when key not understandable.
then view, instead of rendering name render key localized:
<option value="{{ $group->id }}">{{ lang::get($group->namekey) }}
another suggestions using name key, problematic when 2 words same has different meaning in language, in language written differently.
Comments
Post a Comment