I have a block that querys the database for a node, however the node can be translated to english/spanish/...
Is there a way to get the user's selected language so I can update the query to something like "AND node.language = 'x'" (en/sp/..)?
<?php
$args = explode("/",$_GET['q']);
$result = db_query("
SELECT node_revisions.body AS body FROM
{node} AS node
INNER JOIN {node_revisions} AS node_revisions ON node.vid = node_revisions.vid
INNER JOIN {term_node} AS term_node ON term_node.nid = node.nid
INNER JOIN {term_data} AS term_data ON term_data.tid = term_node.tid
WHERE term_data.name = '".$args[1]."' AND node.type = 'country_page'
LIMIT 1
", $user->uid);
while($row = db_fetch_object($result)){
echo($row->body);
}
?>
I think you can get the user's current language in Drupal with this:
global $language;
$lang_name = $language->language;
That should work in both Drupal 6 and Drupal 7.
Reference: Drupal API docs