[solved] Translation inside module adds line break on view title?

Hi Guys!

I have noticed something strange when translating view titles inside modules.

When using “Module::t” the “Space” between the breadcrumbs and the title is getting bigger and I don’t know why.

Result (correct) when using Yii:t with the translate file app/messages/de/app.php



Result (wrong) when useing Module:t with translate file /app/modules/myModule/messages/de/app.php



I translate modules exactly like described here:


So far I was not able to figure out where this comes from…

And it only seems to appear at first element which is translated below the breadcrumbs.

This inside a module view is already enough to reproduce the issue:

use app\modules\myModule\Module;

$this->title = Module::t('app', 'test translated text');

$this->params['breadcrumbs'][] = $this->title;


<h1><?= Html::encode($this->title); ?></h1>

The app.php in both (app and module) look like:

return [

    'test translated text'  => 'das wurde übersetzt',


… Like I said this only appears on titles below the breadcrumbs.

All other items seem to be translated correctly.

Anyone else can reproduce this issue or has any idea what is going wrong here?

I know this is a minor "issue" but this bugs me for awhile now…

Thanks and Regards

Would you please check the difference in the final HTML output between the two?

Probably an extra white space or LF should be the cause of the space, I guess.

Hey softark!

I found the solution!

Thanks for pointing me in the right direction…

Seems to be an encoding issue with the source files.

The Problem was:

The translation file in my module was encoded in "UTF8 with BOM".

After chaning the file to UTF8 without BOM the spacing issue disappeared immediately.

Now I somehow have to check if all my project files are encoded the same way to avoid such weird behaviour in future…