Layout issues when usin Yii:t()...

I’m using Yii:t() to translate my website core messages. Pages that have this function instantiated presents one or more line carries not present on the main layout. When I get back to source language the lines disappears.

Anyone has experienced this issue? Am I forgetting some thing?

ciao thiagovidal,

I’m afraid I don’t understand what your problem is ? Maybe you could provide more details and code sample ?

8)

Please see the 2 images attached to know what I mean.

On first image before the translation, there isn’t another return space between the page title and the breadcrumbs

on second image you can see that the entire content after breadcrumbs gone down one line.

The code analysed on firefox with firebug show the same code but rendered different after translation.




<div class="container">

	<div id="content">

		<h1>Create new account</h1>




<p>Please fill out the following form to create a new account.</p>



after




<div class="container">

	<div id="content">

		<h1>Criar uma nova conta</h1>




<p>Preencha o formulário a seguir para criar uma nova conta.</p>


<div class="form">



hum … This is strange indeed. I’ve used translation function yii::t() with no problem so far. Can you post your translation file please ? (located under messages/)

ciao

B)

Yeah off-course.

Thank for you interest.




<?php

return array(

	'About'	=>	'Sobre',

	'April'	=>	'Abril',

	'August'	=>	'Agosto',

	'Birthday'	=>	'Data de nascimento',

	'Can not access your account?'	=>	'Não consegue acessar sua conta?',

	'Clear form'	=>	'Apagar formulário',

	'Clear form anyway?'	=>	'Deseja realmente apagar formulário?',

	'Contact'	=>	'Contato',

	'Create new account'	=>	'Criar uma nova conta',

	'Day'	=>	'Dia',

	'December'	=>	'Dezembro',

	'Email'	=>	'Email',

	'February'	=>	'Fevereiro',

	'Fields with <span class="required">*</span> are required.'	=>	'Campos com <span class="required">*</span> são obrigatórios.',

	'First name'	=>	'Primeiro nome',

	'Home'	=>	'Início',

	'Incorrect username or password'	=>	'Nome de  usuário ou senha inválidos',

	'January'	=>	'Janeiro',

	'July'	=>	'Julho',

	'June'	=>	'Junho',

	'Last name'	=>	'Ultimo nome',

	'March'	=>	'Março',

	'May'	=>	'Maio',

	'Month'	=>	'Mês',

	'Name'	=>	'Nome',

	'Names cannot contain numbers or special characters.'	=>	'Nomes não podem conter números ou caracteres especiais.',

	'November'	=>	'Novembro',

	'Password'	=>	'Senha',

	'Password confirmation'	=>	'Confirmação de senha',

	'Please enter the letters as they are shown in the image.'	=>	'Por favor entre a letras como mostrado na imagem.',

	'Please fill out the following form'	=>	'Por favor preencha o formulário a seguir',

	'Please fill out the following form to create a new account.'	=>	'Preencha o formulário a seguir para criar uma nova conta.',

	'Register'	=>	'Registre-se',

	'Registration'	=>	'Registrar',

	'Retrive password'	=>	'Recuperar senha',

	'Secret answer'	=>	'Resposta de segurança',

	'Secret question'	=>	'Questão de segurança',

	'Select one from the list'	=>	'Selecione uma da lista',

	'Send message'	=>	'Enviar mensagem',

	'September'	=>	'Setembro',

	'Sign in'	=>	'Entrar',

	'Sign out'	=>	'Sair',

	'Stay signed in'	=>	'Continuar conectado',

	'Subject'	=>	'Assunto',

	'Thank you'	=>	'Obrigado',

	'Thank you for creating your account. You may now go to login form to enter site.'	=>	'Obrigado por criar sua conta. Você já pode ir para a área de login e acessar sua conta.',

	'Thank you!'	=>	'Obrigado!',

	'This email address already existis in our database.'	=>	'Este endereço de email já existe em nosso banco de dados.',

	'This username already existis.'	=>	'Este usuário ja existe.',

	'to contact us.'	=>	'para enviar sua mensagem.',

	'to create a new account.'	=>	'para criar uma nova conta.',

	'to request a new password.'	=>	'para solicitar uma nova senha.',

	'Username'	=>	'Nome de usuário',

	'Username only can contain letters and numbers.'	=>	'Nomes de usuário só podem conter letras e números.',

	'Username or email'	=>	'Nome de usuário ou email',

	'Verification code'	=>	'Código de verificação',

	'Year'	=>	'Ano',

	'You already have your account. You cannot create a new one. Please go to another page.'	=>	'Você ja possui uma conta. Você não pode criar outra. Por favor acesse outra página.',

	"What is your father's middle name?"	=>	'Qual é o nome do meio do seu pai?',

	'What is your favorite car?'	=>	'Qual é o seu carro favorito?',

	'What is your favorite place on world?'	=>	'Qual é o seu lugar favorito no mundo?',

	"What is your gradmother's middle name?"	=>	'Qual é o nome do meio da sua avó?',

	'What is your library card number?'	=>	'Qual é o número do seu cartão da biblioteca?',

	'What is your primary frequent flyer number?'	=>	'Qual é o número do seu cartão de viagens principal?',

	'What was your first phone number?'	=>	'Qual foi o seu primeiro número de telefone?',

	"What was your first teacher's name?"	=>	'Qual é o nome do seu primeiro professor?',

);




I wish I could help you better but right now I have no idea what could cause this problem ! is you message file utf-8 encoded ? The only option I see is you post HTML files for the english and portuguese pages. I’ll try (tomorrow) to see why they don’t render the same way.

ciao

B)

yeahhh… my main config file charset is set to utf-8. I try change this to iso-… but same issue again.

I dont know if this is the same problem, but I experienced something similar.

In one of my view files I had the folllowing:




<?php

/* $this CController */

/* $model CActiveRecord */

?>


<?php

echo $model->name;

?>



The empty line between the codeblocks caused an extra line in my layout when nothing is outputtet in the first codeblock.

Maybe is the damned BOM?

Check if the language file is encoded in UTF-8 WITHOUT BOM.

Some editor add this byte that can create problem. Check if the encode of all file is UTF-8 WITHOUT BOM.

I think you are right! But i don’t know how to do this… Can u help me?

You have to open the file with the editor and check the encoding.

It can be in some menu of the editor, or format menu, or preference->encoding, dipends from the editor.

If is encoded with UTF-8 with BOM change to UTF-8 without BOM

hum… not work! Now it’s getting worse, my layout is following apart.

What do you mean with "following apart"?

If you are part of some unlucky people, wich has not-ascii character in their language, you have to pay attention to:

  • In layout/main.php you should have this line:<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  • All files have to be encoded in utf-8 without BOM

  • In your dbConnection you should have:

[list=1]

  • ‘charset’ => ‘utf8’,

  • ‘initSQLs’=>array(‘SET NAMES utf8’)

[/list]

With all this precaution, you should avoid any problem with encoding, your db will be readable and all character displayed in a proper way.

[size="3"]Sorry. My mistake. I meant falling apart.[/size]

I did this but still not working. I don’t understand. I really believe that is something with page encode.