Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Multilingual Site
  • Hi
    I am new to fuelphp, much of the things are really fast and efficient unlike other framewors. These days i am working on a site that is in multiple language so i want to ask you people a few question
    >> What is the best option for translatable site
    >> how will i create yaml files and how will i integrate it into my existing site If you provide me some existing code snippet of yaml file or some multilingual site it will be great!!
    Thanks in advance
  • Use language files, in combination with the language code set in your app/config/config.php. Then in your views do something like
    <label for="username"><?php echo __('language.groupname.username'); ?></label>...
    

    There are a lot of ways to determine the language to be used, so I don't have a clear answer for that. You could use a URI segment, browser autodetection, stored data in a user record, or in a cookie after the user has selected the language on your site, ... The documentation of the Lang class shows you how to configure the different file formats, and how language files are loaded, groups are made, etc. See http://docs.fuelphp.com/classes/lang.html
  • Hi, i came up with this solution https://github.com/keevitaja/fuel-i18n recently
  • What i want to do is to make a yml file of my translatable string and have that yaml file in many languages so i can load the correct yaml file based on the language selection. how will i do it in fuelphp
  • Start by reading the documentation: http://docs.fuelphp.com/classes/lang.html.
  • Thanks Harro Verton that link worked for me but i have a little confusion however ;(
    'form'          => 'Entry form :name',
       'body'          => 'The following details can and will be used for official printing and online publication. :name',
       'formgroup'     => array('form' =>'Entry form',
       'body'          => 'The following details can and will be used for official printing and online publication.',
       'step1'         => 'Step 1 of 5',
       'step2'         => 'Step 2 of 5',
       'step3'         => 'Step 3 of 5',
       'step4'         => 'Step 4 of 5',
       'step5'         => 'Step 5 of 5',
       'entrydetail'   => 'Entry details',
       'entrybody'     => array('title' => 'Title for entry','language' => 'Language of entry' , 
       'country'       => 'Country' ,'end-customer' => 'Name of end-customer', 'designer' => 'Name of designer'),
       'printerdetail' => 'printer\'s details',
       'printerbody'   => array('company' => 'Company' , 'fname' => 'First Name', 'lname' => 'Last Name', 'function' => 'Function',
       'address'       => 'Address' , 'city' => 'City', 'phone' => 'Phone', 'postal-code' => 'Postal Code', 'fax' => 'Fax',
       'email'         => ' Email ' , 'website' => 'Website' , 'env-manage' => 'Environmental Management Systems',
       ),
       'form-errors'   => 'Please fill in all required fields',
       'form-next'     => 'Next Step >',
    
    the above is my sample string array. how i will convert it to multiple languages keeping the indices of the array same. is there any automatic tool ?
  • I assume that should be
    return array (
        'form' => 'Entry form :name',
        // and the rest here
    );
    

    If you store this in app/lang/en/test.php, you can load it with:
    Lang::load('test', true);
    
    and get a string using
    // will echo Entry form my first formname
    echo Lang::get('test.form', array('name' => 'my first form'));
    

    If you also want for example French, copy the file to app/lang/fr/test.php, and translate it. You can then do
    Config::set('language', 'fr');
    
    // will echo your french translation
    echo Lang::get('test.form', array('name' => 'my first form'));
    
  • |If you also want for example French, copy the file to app/lang/fr/test.php, and translate it.
    How? thats what i am asking. i have translated it to translate.google.com but again i have to manually set the indexes. Is there any automatic way that only translate strings and keep the leys same
  • Shabir, do not look the example link i gave you. it is full of sh*t

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion