Login   Register  
PHP Classes
elePHPant
Icontem

Using another language than english

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      HtmlForm PHP 5  >  All threads  >  Using another language than english  >  (Un) Subscribe thread alerts  
Subject:Using another language than english
Summary:When using another language than english an error occured
Messages:5
Author:w. studer
Date:2013-02-11 12:41:53
Update:2013-02-11 13:40:45
 

  1. Using another language than english   Reply   Report abuse  
Picture of w. studer
w. studer
2013-02-11 12:41:53
Hi

me ;-)

I create my form:
------------------------------------------------
ini_set ( 'default_charset', 'UTF-8' );
ini_set ( 'mbstring.internal_encoding', 'UTF-8' );
ini_set ( 'mbstring.http_output', 'UTF-8' );

// Create the form.
$dataForm = HtmlForm::get ( $formname )
->addCssClasses('dataform')
->showMessages('Errors:')
->setLanguage( 'german' )
->useExternalFormDeclaration()
->setPackagePath('/////htmlform///')
->setEnctype('multipart/form-data')
->useReducedErrorMarking()
;

... adding the fields ...

// Complete the form
if( isset($_GET['nojsvalidation']) && ($_GET['nojsvalidation'] == 'true') ):
$dataForm->suppressJavascriptValidation();
endif;

$dataForm->prepareJavascriptValidation()
->suppressJqueryInclude()
;

// Result handling
// Check if form has been sent before validating it, otherwise there's little sense in it.
$successContainer = '';
if ( $dataForm->hasBeenSent() ):

// Retrieve a complete valueset from the form.
$valueSet = $dataForm->getValueSet();

// save handler
if ( $valueSet->btn_save ):

// Start form validation. It knows its validity-state after this.
$dataForm->validate();

if ( $dataForm->isValid() ):
....
------------------------------------------------

Note the ->setLanguage command when creating the form!

As long as I do not validate, all is OK.
But as soon as validation starts and an error occured, I get errors:

Notice: Constant MSG_CUSTOMCASE already defined in /my server path>/htmlform/messages/german.inc.php on line 12
Notice: Constant MSG_REQUIRED already defined in /my server path>/htmlform/messages/german.inc.php on line 13
....
Notice: Constant MSG_CHARACTERCLASS already defined in /my server path>/htmlform/messages/german.inc.php on line 36


And the error I get is in english
-------------------------------------
Errors:
"Abschnitt:" has a minimum size of 1.
-------------------------------------

With
> $dataForm = HtmlForm::get ( $formname )
the language is set per default to "english".

When adding in english.inc.php and german.inc.php an echo showing which file is loaded, it shows "englsh.inc.php" even when form start.

If then later on the system tries to load the german constant file, the error occurs.


Do I do something wrong or ???

kind regards
Wolfgang

  2. Re: Using another language than english   Reply   Report abuse  
Picture of w. studer
w. studer
2013-02-11 12:56:54 - In reply to message 1 from w. studer
btw, ...
In the index.php for the "HtmlForm Testcase Scenario", I've changed in form initialization to
->setLanguage('german').

Then I add
> error_reporting(E_ALL);
on top in your index.php.

I get exactly same NOTICE errors and validation errors only in english.

(So it does not look like I'm doing something wrong .. Ufff ;-))


  3. Re: Using another language than english   Reply   Report abuse  
Picture of w. studer
w. studer
2013-02-11 13:24:25 - In reply to message 1 from w. studer
Think I found the issue ..

In HtmlForm.FormValidator.class.php, there is following function:
-------------
public function activateJavascriptValidation($selector = null, $errorSelector = null, $prepareMessages = true){

$this->usesJavascriptValidation = true;

if( !is_null($selector) && ($this->selector == '') ){
$this->selector = "$selector";
}

if( !is_null($errorSelector) ){
$this->errorSelector = "$errorSelector";
}

if( $prepareMessages ){
require_once 'messages/'.$this->messageLanguage.'.inc.php';
}

return $this;
}
---------------

When checking here $this->messageLanguage, it is english due to default value in construct function of this class.

The function itself is called when declaring the fields.
But at this time, the setLanguage for Validator has not occured.

  4. Re: Using another language than english   Reply   Report abuse  
Picture of Sebastian Schlapkohl
Sebastian Schlapkohl
2013-02-11 13:30:12 - In reply to message 1 from w. studer
That's a bug I introduced when adding JS-validation.

I fixed and reuploaded

HtmlForm.FormElement.absclass.php
HtmlForm.FormValidator.class.php

Please try the new version of those files.

  5. Re: Using another language than english   Reply   Report abuse  
Picture of w. studer
w. studer
2013-02-11 13:40:45 - In reply to message 1 from w. studer
Yep, is running now with german language too ;-)


Thanks for very fast reply.