Skip to Content Skip to Menu

Impossible to translate 'Not a valid input'

  • yann.fr
  • yann.fr
  • OFFLINE
  • Posts: 33
  • Thanks: 1
  • Karma: 1
12 years 11 months ago #184711 by yann.fr
Impossible to translate the string 'Not a valid input' displayed in the event of input error on the username field with a PERL regular expression verification.

In the code of CB in cb.core.php, lines 64 and 96 are buggy.
I do not correct the line 64 which does not correspond to the error that I see.
I propose
- New line to replace the line 96
- Added the import file cbteamplugins_language.php
then
- Added error text in cbteamplugins_language.php

Replace line 89
Code:
function validate( &$field, &$user, $columnName, &$value, &$postdata, $reason ) { $validated = parent::validate( $field, $user, $columnName, $value, $postdata, $reason ); if ( $validated && ( $value !== '' ) && ( $value !== null ) ) { // empty values (e.g. non-mandatory) are treated in the parent validation. $pregExp = $this->_getRegexp( $field ); if ( $pregExp ) { $validated = preg_match( $pregExp, $value ); if ( ! $validated ) { $pregExpError = $field->params->get( 'pregexperror', CBTxt::T('Not a valid input') );

by
Code:
function validate( &$field, &$user, $columnName, &$value, &$postdata, $reason ) { cbimport( 'language.cbteamplugins' ); $validated = parent::validate( $field, $user, $columnName, $value, $postdata, $reason ); if ( $validated && ( $value !== '' ) && ( $value !== null ) ) { // empty values (e.g. non-mandatory) are treated in the parent validation. $pregExp = $this->_getRegexp( $field ); if ( $pregExp ) { $validated = preg_match( $pregExp, $value ); if ( ! $validated ) { $pregExpError = ISOtoUtf8( CBTxt::P($field->params->get( 'pregexperror', 'Not a valid input' ))) ;

We must also add in the file .../default_language/cbteamplugins_language.php
Code:
'Not a valid input' => 'Not a valid input.',

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • ONLINE
  • Posts: 2169
  • Thanks: 463
  • Karma: 352
12 years 11 months ago #184736 by beat
Good find, thank you very much for your fix proposal.

I reviewed line 64, which is for the Javascript browser-side validations, and i don't see a similar bug there, since the customized error message is translated properly.

Here is how I just committed line 96 for next CB release:
Code:
$pregExpError = CBTxt::P( $field->params->get( 'pregexperror', 'Not a valid input'), array( '[FIELDNAME]' => $field->title ) ); // CBTxt::T('Not a valid input')

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum