⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Validation messages translation



sergio.lara
  • profile picture
  • Member

Posted 29 June 2012 - 23:20 PM

Hello everyone!

How can I translate all standard messages from CI form_validation, into Grocery Crud? Ok... Let me explain....

I use to set this on every controller's construct function I use:


$this->form_validation->set_message(set_rules_messages());


Where 'set_rules_messages()' is my function. Here's the code:


function set_rules_messages()
{
$messages['required'] = 'Campo %s não informado!';
$messages['integer'] = 'O campo %s aceita somente valores numéricos!';
$messages['valid_email'] = 'O E-Mail informado não é válido!';
$messages['valida_data'] = '%s inválida! O formato deve ser 99/99/9999.';
$messages['valida_diafreq'] = 'Campo %s não informado !';
$messages['valida_dest'] = 'Campo %s não informado!';
$messages['valida_notif'] = 'Campo %s não informado!';
$messages['valida_datainicial'] = 'Campo %s não informado!';
$messages['valida_filtro'] = 'Um filtro deve ser informado! (Marca ou Linha)';

return ($messages);
}


Now, on a regular CI app, the messages are translated ok, but it doesn't work in the Grocery's forms. The messages continue to be shown in english.


Thanks in advance!

fdias
  • profile picture
  • Member

Posted 30 June 2012 - 02:34 AM

Edit the the file:

application\config\grocery_crud.php

And set the language you wish:
$config['grocery_crud_default_language']    = 'pt-br.portuguese';


To view all the languages go to the folder assets/grocery_crud/languages/

Cheers

Kirk
  • profile picture
  • Member

Posted 30 June 2012 - 14:13 PM

Hey fdias! Thanks for helping. I've already done this. That's why I find it strange that it didn't changed.

fdias
  • profile picture
  • Member

Posted 01 July 2012 - 01:18 AM

That's very odd.

Try clearing your browser cache and make sure the language file is there and also double check the string and remember it's
pt-br.portuguese without the .php extension

Hope this helps.

Kirk
  • profile picture
  • Member

Posted 01 July 2012 - 02:53 AM

Hey fdias!

Sorry... but it still doesn't work. :(
Man... this is really annoying...

Thanks again.

fdias
  • profile picture
  • Member

Posted 01 July 2012 - 16:31 PM

Suggestion:

1 - Check the portuguese language file and see if the messages are in PT.
2 - Change the contents of the english file to see if it will reflect on your messages.
3 - Change CI language also to portuguese
4 - Make sure you encode your files with UTF-8 and on your editor such as notepad++ make sure you save them as UTF-8 without BOM (this makes a difference)
5 - Test a different browser

Usually this kind of error is some little thing that we miss.

If none of this steps makes any difference I suggest you recreate an environment (CI+Grocery Crud) on a different site and see what happens.

Good luck!