I have the below query:

It works except the line: ->propertyCondition('langcode', $language->langcode, '=')

The query always returns english titles. How can i fix this?

<?php
global $language;

$query = new EntityFieldQuery();
$query
	->entityCondition('entity_type', 'node', '=')
	->entityCondition('bundle', 'page', '=')
	->propertyCondition('status', NODE_PUBLISHED, '=')
	->propertyCondition('langcode', $language->langcode, '=')
	->propertyOrderBy("nid", "ASC")
	->addMetaData('account', user_load(1));
$entities = $query->execute();

$items = '<option value="" selected="selected">Default</option>';
if (isset($entities['node'])) {
	foreach($entities['node'] as $obj) {
		$node = node_load($obj->entity_id);
		$title = $node->title;
		$items .= "<option value={$title}>{$title}</option>";
	}
}
?>

<form id="textures-form" accept-charset="UTF-8">
<div class="form-wrapper">
	<div class="form-item form-type-select" id="form-group-floors">
		<label for="floor-texture">Floors Texture:</label>
		<select id="floor-texture" name="floor_texture" class="form-select">
			<?php print $items; ?>
		</select>
	</div>
	<input type="button" value="Change" class="form-submit" onclick="return sendMessage()" />
	<input type="reset" value="Reset" class="form-submit" />
</div>
</form>

<div class="full">
<h3>How to use</h3>
<p>
Please wait until software loads the simulator, then choose wall and/or floor textures and click Change button to see the new materials applied.
</p>
</div>

Accepted answer

After alot of trials, i have done the obvious and translated the whole block for different languages with each property condition as follows:

->propertyCondition('langcode', 'en', '=')

->propertyCondition('langcode', 'tr', '=')

->propertyCondition('langcode', 'de', '=')

...etc

Comments

Sorry the query works.

The problem is, the global $language doesnt update unless page cache is rebuilt anytime the site language changes.

Question is why and how to fix?

The new question is; how do i prevent a custom block to be cached?

After alot of trials, i have done the obvious and translated the whole block for different languages with each property condition as follows:

->propertyCondition('langcode', 'en', '=')

->propertyCondition('langcode', 'tr', '=')

->propertyCondition('langcode', 'de', '=')

...etc