function i18nprofile_translation_overview in Internationalization 5
Same name and namespace in other branches
- 5.3 i18nprofile/i18nprofile.module \i18nprofile_translation_overview()
- 5.2 i18nprofile/i18nprofile.module \i18nprofile_translation_overview()
Overview profile translations
1 call to i18nprofile_translation_overview()
- i18nprofile_translation in i18nprofile/
i18nprofile.module - Menu callback: profile translations
File
- i18nprofile/
i18nprofile.module, line 236
Code
function i18nprofile_translation_overview($lang_curr = 'en') {
$path = 'admin/user/profile/translation';
// Get languages and remove english from the list
$languages = i18n_supported_languages();
if ($lang_curr == 'en') {
unset($languages['en']);
}
else {
foreach ($languages as $key => $name) {
if ($key != $lang_curr) {
unset($languages[$key]);
}
}
}
$destination = drupal_get_destination();
// Categories
$output .= '<h2>' . t('Categories') . "</h2>\n";
$categories = profile_categories();
$translations = array();
foreach ($languages as $key => $name) {
$translations[$key] = variable_get('i18nprofile_' . $key, array());
}
foreach ($categories as $category) {
$row = array(
$category['title'],
);
//English name
$cat = $category['name'];
foreach ($languages as $key => $name) {
if (isset($translations[$key][$cat])) {
$row[] = l($translations[$key][$cat], "{$path}/category/{$key}", array(), $destination);
}
else {
$row[] = '-- ' . l(t('add'), "{$path}/category/{$key}", array(), $destination);
}
}
$rows[] = $row;
}
$header = array(
t('English'),
) + $languages;
$output .= theme('table', $header, $rows);
// Fields
$output .= '<h2>' . t('Fields') . "</h2>\n";
$result = db_query('SELECT * FROM {i18n_profile_fields}');
$translations = array();
while ($field = db_fetch_object($result)) {
$translations[$field->fid][$field->language] = check_plain($field->title);
}
// Fetch fields and prepare data
$result = db_query('SELECT * FROM {profile_fields} ORDER BY category, weight');
$rows = array();
$rows = array();
while ($field = db_fetch_object($result)) {
$row = array(
$field->name,
$field->category,
check_plain($field->title),
);
foreach ($languages as $key => $name) {
if (isset($translations[$field->fid][$key])) {
$row[] = l($translations[$field->fid][$key], "{$path}/field/{$field->fid}/{$key}", array(), $destination);
}
else {
$row[] = '-- ' . l(t('add'), "{$path}/field/{$field->fid}/{$key}", array(), $destination);
}
}
$rows[] = $row;
}
if (count($rows) == 0) {
$rows[] = array(
array(
'data' => t('No fields defined.'),
'colspan' => 3 + count($languages),
),
);
}
$header = array(
t('Name'),
t('Category'),
t('English'),
) + $languages;
$output .= theme('table', $header, $rows);
return $output;
}