In case you've missed it, you are looking at an older version of the website. Checkout our latest version, we promise you will love it 😍

Getting things multilingual

If you have install version 1.1.6 or later you will be able to use the multilingual functionality for all your projects. Here is how it works.

Step 1. First of all make sure that you have copied all the files of grocery CRUD in your project. Even if you update from older version, make sure that you copy ALL the files and folders to your project. If you just copy the library and/or the model , probably you will not be able to use this functionality

Step 2. Go to application/config/grocery_crud.php and select you own language. The available languages are: Afrikaans, Arabic, Bulgarian, Chinese, Danish, Dutch, English, French, German, Greek, Indonesian, Italian, Japanese, Persian, Polish, pt-BR.portuguese, pt-PT.portuguese, Romanian, Russian, Spanish, Thai, Turkish, Ukrainian, Vietnamese.

Step 3. It's that simple. Now when you change for example the config to "greek", you will see all the CRUD grid and forms to be translated to greek. But what if someone want to add his own language? Go to step 4, below

Step 4 - Adding your own language. The languages folder is at: your_project/assets/grocery_crud/languages/ ( The languages are in different folder that codeigniter uses. The main reason is to be absolutely independent from the language functionality of CI. This means that even if you have an update at codeigniter, or you add your own MY_Language , grocery CRUD will still works the same.) There you can add your own language by naming it with the name that you want to call it at the application/config/grocery_crud.php .

When you have done your file will look like the this:

    $lang['list_add']                 = 'Add';
    $lang['list_actions']             = 'Actions';
    $lang['list_page']                 = 'Page';    
    $lang['list_paging_of']         = 'of';
    $lang['list_displaying']        = 'Displaying {start} to {end} of {results} items';
    $lang['list_filtered_from']        = '(filtered from {total_results} total entries)';
    $lang['list_show_entries']        = 'Show {paging} entries';
    $lang['list_no_items']            = 'No items to display';
    $lang['list_zero_entries']        = 'Displaying 0 to 0 of 0 items';
    $lang['list_search']             = 'Search';    
    $lang['list_search_all']         = 'Search all';
    $lang['list_clear_filtering']     = 'Clear filtering';
    $lang['list_delete']             = 'Delete';
    $lang['list_edit']                 = 'Edit';    
    $lang['list_paging_first']         = 'First';
    $lang['list_paging_previous']     = 'Previous';
    $lang['list_paging_next']         = 'Next';
    $lang['list_paging_last']         = 'Last';
    $lang['list_loading']             = 'Loading...';    
    $lang['form_edit']                 = 'Edit';
    $lang['form_back_to_list']         = 'Back to list';
    $lang['form_update_changes']     = 'Update changes';
    $lang['form_cancel']             = 'Cancel';    
    $lang['form_update_loading']     = 'Loading, updating changes...';
    $lang['update_success_message'] = 'Your data has been successfully updated.';    
    $lang['form_go_back_to_list']     = 'Go back to list';
    $lang['form_add']                 = 'Add';
    $lang['insert_success_message'] = 'Your data has been successfully stored into the database.';
    $lang['form_or']                = 'or';
    $lang['form_save']                 = 'Save';
    $lang['form_insert_loading']     = 'Loading, saving data...';
    $lang['form_upload_a_file']     = 'Upload a file';
    $lang['form_upload_delete']     = 'delete';
    $lang['form_button_clear']         = 'Clear';    
    $lang['delete_success_message'] = 'Your data has been successfully deleted from the database.';
    $lang['delete_error_message']     = 'Your data was not deleted from the database.';
    /* Javascript messages */
    $lang['alert_add_form']            = 'The data you had insert may not be saved.\\nAre you sure you want to go back to list?';
    $lang['alert_edit_form']        = 'The data you had change may not be saved.\\nAre you sure you want to go back to list?';
    $lang['alert_delete']            = 'Are you sure that you want to delete this record?';
    $lang['insert_error']            = 'An error has been occured at the insert.';
    $lang['update_error']            = 'An error has been occured on Saving.';

So let's have an example that you add your own language and named it "spanish.php", you can go straight away to your application/config/grocery_crud.php and change it to:
    $config['grocery_crud_default_language']    = 'spanish';
and that's it

If you still want more...

The new multilingual functionality offers you also two amazing functions.

  • set_language. You can simply change your language at your method. So for example in your project if you have the default language to "greek" you can have one situation that you don't want to have the default language but another, just type $crud->set_language("english"). And you will have English only at this method.
  • set_lang_string. Set your lang string directly. This is really useful if you want just for some cases to change the language string.