I will create a temporal table to make it easy to read. But you can use a derivated table.
SqlFiddleDemo
lenguaje
will be the column header, and I use the last 3 characters to get that lenguaje.
CREATE TABLE result as
SELECT b.id, b.name, SUBSTRING(name_translate, -3 ) lenguaje, name_translate
FROM books b
LEFT JOIN books_translates bt
ON bt.book_id = b.id
LEFT JOIN translates t
ON t.id = bt.translate_id;
Then you need create the query dynamically
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'MAX(IF(lenguaje = ''',
lenguaje,
''', name_translate, NULL)) AS ',
lenguaje
)
) INTO @sql
FROM result
;
SET @sql = CONCAT('SELECT id, name, ', @sql, ' FROM result GROUP BY id');
^^^^^^^^^^
(..query..) <- derivated table instead
PREPARE stmt FROM @sql;
EXECUTE stmt;
OUTPUT
| id | name | ENG | LAT |
|----|-------|----------|----------|
| 1 | Mario | MarioENG | MarioLAT |
| 2 | Artur | ArturENG | (null) |