How do you get language localization for a layout called via beginContent() within another layout / view?

Hi,

I’m encountering an issue where a specific layout ‘purchase’ is rendered from within another view as follows:

< from within /user/showinfo.php >

		&#036;this-&gt;beginContent('/layouts/detaillist', &#036;params);


		&#036;this-&gt;endContent();

I’ve generated and setup the following i18n files:

messages/en/detaillist.php

messages/en/user/showinfo.php

None of the configured strings in the i18n files would show up on the final page.

Could anyone advise what would be the proper way to getting this to work?

Read more about translation here.

The translation files is used with Yii::t(’<your translation file>’, ‘<string to be translated>’). This will take place only if the selected language differs from sourceLanguage.

Another way to translate complete views is to store them in subdirectories named as <selected language>.

/Tommy

Hi Tommy,

Yes, the translation files have the strings plugged in and were actually generated using the yiic message command, via the Yii::t lines which are already inserted into the code.

However, for some reason, accessing this layout only shows up the <string to be translated>.

For my other layout, e.g. /layout/main.php ( with a corresponding /messages/en/main.php ) , Yii::t(’<your translation file>’, ‘<string to be translated>’) statements do pull up the corresponding strings from the EN translations array. ( as i’m using identification strings for the <string to be translated>, such as COMMON_NAV_HOME , so that the actual strings are only stored within the message arrays for each language.

Any idea why this might be happening perhaps? Could it be due to the beginContent block , if there’s any params I should be passing to it?

How do you specify language and sourceLanguage in config? If set later in the request, did you consider side effects due to rendering order?

/Tommy

Oh my bad! Thanks for the hint. I overlooked the fact that the code that set the $lang had been omitted in the particular view I was working on. Fixed that and its working fine now.