2 // $Id: locale.inc 144 2007-03-28 07:52:20Z thierry $
6 * Admin-related functions for locale.module.
9 // ---------------------------------------------------------------------------------
10 // Language addition functionality (administration only)
13 * Helper function to add a language
15 function _locale_add_language($code, $name, $onlylanguage = TRUE) {
16 db_query("INSERT INTO {locales_meta} (locale, name) VALUES ('%s','%s')", $code, $name);
17 $result = db_query("SELECT lid FROM {locales_source}");
18 while ($string = db_fetch_object($result)) {
19 db_query("INSERT INTO {locales_target} (lid, locale, translation) VALUES (%d,'%s', '')", $string->lid, $code);
22 // If only the language was added, and not a PO file import triggered
23 // the language addition, we need to inform the user on how to start
26 drupal_set_message(t('The language %locale has been created, and can now be used to import a translation. More information is available in the <a href="%locale-help">help screen</a>.', array('%locale' => theme('placeholder', t($name)), '%locale-help' => url('admin/help/locale'))));
29 drupal_set_message(t('The language %locale has been created.', array('%locale' => theme('placeholder', t($name)))));
32 watchdog('locale', t('The %language language (%locale) has been created.', array('%language' => theme('placeholder', $name), '%locale' => theme('placeholder', $code))));
36 * User interface for the language management screen.
38 function _locale_admin_manage_screen() {
39 $languages = locale_supported_languages(TRUE, TRUE);
42 $form['name'] = array('#tree' => TRUE);
43 foreach ($languages['name'] as $key => $lang) {
45 $status = db_fetch_object(db_query("SELECT isdefault, enabled FROM {locales_meta} WHERE locale = '%s'", $key));
46 if ($status->enabled) {
49 if ($status->isdefault) {
53 $form['name']['en'] = array('#value' => check_plain($lang));
56 $original = db_fetch_object(db_query("SELECT COUNT(*) AS strings FROM {locales_source}"));
57 $translation = db_fetch_object(db_query("SELECT COUNT(*) AS translation FROM {locales_target} WHERE locale = '%s' AND translation != ''", $key));
59 $ratio = ($original->strings > 0 && $translation->translation > 0) ? round(($translation->translation/$original->strings)*100., 2) : 0;
61 $form['name'][$key] = array('#type' => 'textfield',
62 '#default_value' => $lang,
66 $form['translation'][$key] = array('#value' => "$translation->translation/$original->strings ($ratio%)");
69 $form['enabled'] = array('#type' => 'checkboxes',
70 '#options' => $options,
71 '#default_value' => $enabled,
73 $form['site_default'] = array('#type' => 'radios',
74 '#options' => $options,
75 '#default_value' => $isdefault,
77 $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
79 return drupal_get_form('_locale_admin_manage_screen', $form, 'locale_admin_manage_screen');
83 * Theme the locale admin manager form.
85 function theme_locale_admin_manage_screen($form) {
86 foreach ($form['name'] as $key => $element) {
87 // Do not take form control structures.
88 if (is_array($element) && element_child($key)) {
89 $rows[] = array(check_plain($key), form_render($form['name'][$key]), form_render($form['enabled'][$key]), form_render($form['site_default'][$key]), ($key != 'en' ? form_render($form['translation'][$key]) : message_na()), ($key != 'en' ? l(t('delete'), 'admin/locale/language/delete/'. $key) : ''));
92 $header = array(array('data' => t('Code')), array('data' => t('English name')), array('data' => t('Enabled')), array('data' => t('Default')), array('data' => t('Translated')), array('data' => t('Operations')));
93 $output = theme('table', $header, $rows);
94 $output .= form_render($form);
100 * Process locale admin manager form submissions.
102 function _locale_admin_manage_screen_submit($form_id, $form_values) {
103 // Save changes to existing languages.
104 $languages = locale_supported_languages(FALSE, TRUE);
105 foreach($languages['name'] as $key => $value) {
106 if ($form_values['site_default'] == $key) {
107 $form_values['enabled'][$key] = 1; // autoenable the default language
109 $enabled = $form_values['enabled'][$key] ? 1 : 0;
111 // Disallow name change for English locale.
112 db_query("UPDATE {locales_meta} SET isdefault = %d, enabled = %d WHERE locale = 'en'", ($form_values['site_default'] == $key), $enabled);
115 db_query("UPDATE {locales_meta} SET name = '%s', isdefault = %d, enabled = %d WHERE locale = '%s'", $form_values['name'][$key], ($form_values['site_default'] == $key), $enabled, $key);
118 drupal_set_message(t('Configuration saved.'));
120 // Changing the locale settings impacts the interface:
123 return 'admin/locale/language/overview';
127 * User interface for the language addition screen.
129 function _locale_admin_manage_add_screen() {
130 $isocodes = _locale_prepare_iso_list();
133 $form['language list'] = array('#type' => 'fieldset',
134 '#title' => t('Language list'),
135 '#collapsible' => TRUE,
137 $form['language list']['langcode'] = array('#type' => 'select',
138 '#title' => t('Language name'),
139 '#default_value' => key($isocodes),
140 '#options' => $isocodes,
141 '#description' => t('Select your language here, or add it below, if you are unable to find it.'),
143 $form['language list']['submit'] = array('#type' => 'submit', '#value' => t('Add language'));
145 $output = drupal_get_form('locale_add_language_form', $form);
148 $form['custom language'] = array('#type' => 'fieldset',
149 '#title' => t('Custom language'),
150 '#collapsible' => TRUE,
152 $form['custom language']['langcode'] = array('#type' => 'textfield',
153 '#title' => t('Language code'),
157 '#description' => t("Commonly this is an <a href=\"%iso-codes\">ISO 639 language code</a> with an optional country code for regional variants. Examples include 'en', 'en-US' and 'zh-cn'.", array('%iso-codes' => 'http://www.w3.org/WAI/ER/IG/ert/iso639.htm')),
159 $form['custom language']['langname'] = array('#type' => 'textfield',
160 '#title' => t('Language name in English'),
163 '#description' => t('Name of the language. Will be available for translation in all languages.'),
165 $form['custom language']['submit'] = array('#type' => 'submit', '#value' => t('Add custom language'));
167 // Use the validation and submit functions of the add language form.
168 $output .= drupal_get_form('locale_custom_language_form', $form, 'locale_add_language_form');
174 * Validate the language addition form.
176 function locale_add_language_form_validate($form_id, $form_values) {
177 if ($duplicate = db_num_rows(db_query("SELECT locale FROM {locales_meta} WHERE locale = '%s'", $form_values['langcode'])) != 0) {
178 form_set_error(t('The language %language (%code) already exists.', array('%language' => theme('placeholder', check_plain($form_values['langname'])), '%code' => theme('placeholder', $form_values['langcode']))));
181 if (!isset($form_values['langname'])) {
182 $isocodes = _locale_get_iso639_list();
183 if (!isset($isocodes[$form_values['langcode']])) {
184 form_set_error('langcode', t('Invalid language code.'));
190 * Process the language addition form submission.
192 function locale_add_language_form_submit($form_id, $form_values) {
193 if (isset($form_values['langname'])) {
194 // Custom language form.
195 _locale_add_language($form_values['langcode'], $form_values['langname']);
198 $isocodes = _locale_get_iso639_list();
199 _locale_add_language($form_values['langcode'], $isocodes[$form_values['langcode']][0]);
202 return 'admin/locale';
206 * User interface for the translation import screen.
208 function _locale_admin_import_screen() {
209 $languages = locale_supported_languages(FALSE, TRUE);
210 $languages = array_map('t', $languages['name']);
211 unset($languages['en']);
213 if (!count($languages)) {
214 $languages = _locale_prepare_iso_list();
218 t('Already added languages') => $languages,
219 t('Languages not yet added') => _locale_prepare_iso_list()
224 $form['import'] = array('#type' => 'fieldset',
225 '#title' => t('Import translation'),
227 $form['import']['file'] = array('#type' => 'file',
228 '#title' => t('Language file'),
230 '#description' => t('A gettext Portable Object (.po) file.'),
232 $form['import']['langcode'] = array('#type' => 'select',
233 '#title' => t('Import into'),
234 '#options' => $languages,
235 '#description' => t('Choose the language you want to add strings into. If you choose a language which is not yet set up, then it will be added.'),
237 $form['import']['mode'] = array('#type' => 'radios',
238 '#title' => t('Mode'),
239 '#default_value' => 'overwrite',
240 '#options' => array('overwrite' => t('Strings in the uploaded file replace existing ones, new ones are added'), 'keep' => t('Existing strings are kept, only new strings are added')),
242 $form['import']['submit'] = array('#type' => 'submit', '#value' => t('Import'));
243 $form['#attributes']['enctype'] = 'multipart/form-data';
245 return drupal_get_form('_locale_admin_import', $form);
249 * Process the locale import form submission.
251 function _locale_admin_import_submit($form_id, $form_values) {
252 // Add language, if not yet supported
253 $languages = locale_supported_languages(TRUE, TRUE);
254 if (!isset($languages['name'][$form_values['langcode']])) {
255 $isocodes = _locale_get_iso639_list();
256 _locale_add_language($form_values['langcode'], $isocodes[$form_values['langcode']][0], FALSE);
259 // Now import strings into the language
260 $file = file_check_upload('file');
261 if ($ret = _locale_import_po($file, $form_values['langcode'], $form_values['mode']) == FALSE) {
262 $message = t('The translation import of %filename failed.', array('%filename' => theme('placeholder', $file->filename)));
263 drupal_set_message($message, 'error');
264 watchdog('locale', $message, WATCHDOG_ERROR);
267 return 'admin/locale';
271 * User interface for the translation export screen
273 function _locale_admin_export_screen() {
274 $languages = locale_supported_languages(FALSE, TRUE);
275 $languages = array_map('t', $languages['name']);
276 unset($languages['en']);
278 // Offer language specific export if any language is set up
279 if (count($languages)) {
281 $form['export'] = array('#type' => 'fieldset',
282 '#title' => t('Export translation'),
283 '#collapsible' => TRUE,
285 $form['export']['langcode'] = array('#type' => 'select',
286 '#title' => t('Language name'),
287 '#options' => $languages,
288 '#description' => t('Select the language you would like to export in gettext Portable Object (.po) format.'),
290 $form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
291 $output = drupal_get_form('_locale_export_po', $form);
294 // Complete template export of the strings
296 $form['export'] = array('#type' => 'fieldset',
297 '#title' => t('Export template'),
298 '#collapsible' => TRUE,
299 '#description' => t('Generate a gettext Portable Object Template (.pot) file with all the interface strings from the Drupal locale database.'),
301 $form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
302 $output .= drupal_get_form('_locale_export_pot', $form, '_locale_export_po');
308 * Process a locale export form submissions.
310 function _locale_export_po_submit($form_id, $form_values) {
311 _locale_export_po($form_values['langcode']);
315 * User interface for the string search screen
317 function _locale_string_seek_form() {
318 // Get *all* languages set up
319 $languages = locale_supported_languages(FALSE, TRUE);
320 asort($languages['name']); unset($languages['name']['en']);
321 $languages['name'] = array_map('check_plain', $languages['name']);
323 // Present edit form preserving previous user settings
324 $query = _locale_string_seek_query();
326 $form['search'] = array('#type' => 'fieldset',
327 '#title' => t('Search'),
329 $form['search']['string'] = array('#type' => 'textfield',
330 '#title' => t('Strings to search for'),
331 '#default_value' => $query->string,
334 '#description' => t('Leave blank to show all strings. The search is case sensitive.'),
336 $form['search']['language'] = array('#type' => 'radios',
337 '#title' => t('Language'),
338 '#default_value' => ($query->language ? $query->language : 'all'),
339 '#options' => array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages['name']),
341 $form['search']['searchin'] = array('#type' => 'radios',
342 '#title' => t('Search in'),
343 '#default_value' => ($query->searchin ? $query->searchin : 'all'),
344 '#options' => array('all' => t('All strings in that language'), 'translated' => t('Only translated strings'), 'untranslated' => t('Only untranslated strings')),
346 $form['search']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
347 $form['#redirect'] = FALSE;
349 return drupal_get_form('_locale_string_seek', $form);
353 * User interface for string editing.
355 function _locale_string_edit($lid) {
356 $languages = locale_supported_languages(FALSE, TRUE);
357 unset($languages['name']['en']);
359 $result = db_query('SELECT DISTINCT s.source, t.translation, t.locale FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE s.lid = %d', $lid);
361 $form['translations'] = array('#tree' => TRUE);
362 while ($translation = db_fetch_object($result)) {
363 $orig = $translation->source;
365 // Approximate the number of rows in a textfield with a maximum of 10.
366 $rows = min(ceil(str_word_count($orig) / 12), 10);
368 $form['translations'][$translation->locale] = array(
369 '#type' => 'textarea',
370 '#title' => $languages['name'][$translation->locale],
371 '#default_value' => $translation->translation,
374 unset($languages['name'][$translation->locale]);
377 // Handle erroneous lid.
379 drupal_set_message(t('String not found.'));
380 drupal_goto('admin/locale/string/search');
383 // Add original text. Assign negative weight so that it floats to the top.
384 $form['item'] = array('#type' => 'item',
385 '#title' => t('Original text'),
386 '#value' => check_plain(wordwrap($orig, 0)),
390 foreach ($languages['name'] as $key => $lang) {
391 $form['translations'][$key] = array(
392 '#type' => 'textarea',
398 $form['lid'] = array('#type' => 'value', '#value' => $lid);
399 $form['submit'] = array('#type' => 'submit', '#value' => t('Save translations'));
401 return drupal_get_form('_locale_string_edit', $form);
405 * Process string editing form submissions.
406 * Saves all translations of one string submitted from a form.
408 function _locale_string_edit_submit($form_id, $form_values) {
409 $lid = $form_values['lid'];
410 foreach ($form_values['translations'] as $key => $value) {
411 $value = filter_xss_admin($value);
412 $trans = db_fetch_object(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND locale = '%s'", $lid, $key));
413 if (isset($trans->translation)) {
414 db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND locale = '%s'", $value, $lid, $key);
417 db_query("INSERT INTO {locales_target} (lid, translation, locale) VALUES (%d, '%s', '%s')", $lid, $value, $key);
420 drupal_set_message(t('The string has been saved.'));
422 // Refresh the locale cache.
423 locale_refresh_cache();
424 // Rebuild the menu, strings may have changed.
427 return 'admin/locale/string/search';
431 * Delete a language string.
433 function _locale_string_delete($lid) {
434 db_query('DELETE FROM {locales_source} WHERE lid = %d', $lid);
435 db_query('DELETE FROM {locales_target} WHERE lid = %d', $lid);
436 locale_refresh_cache();
437 drupal_set_message(t('The string has been removed.'));
439 drupal_goto('admin/locale/string/search');
443 * Parses Gettext Portable Object file information and inserts into database
445 * @param $file Object contains properties of local file to be imported
446 * @param $lang Language code
447 * @param $mode should existing translations be replaced?
449 function _locale_import_po($file, $lang, $mode) {
450 // If not in 'safe mode', increase the maximum execution time:
451 if (!ini_get('safe_mode')) {
455 // Check if we have the language already in the database
456 if (!db_fetch_object(db_query("SELECT locale FROM {locales_meta} WHERE locale = '%s'", $lang))) {
457 drupal_set_message(t('The language selected for import is not supported.'), 'error');
461 // Get strings from file (returns on failure after a partial import, or on success)
462 $status = _locale_import_read_po($file, $mode, $lang);
463 if ($status === FALSE) {
464 // error messages are set in _locale_import_read_po
468 // Get status information on import process
469 list($headerdone, $additions, $updates) = _locale_import_one_string('report', $mode);
472 drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.', array('%filename' => theme('placeholder', $file->filename))), 'error');
475 // rebuild locale cache
476 cache_clear_all("locale:$lang");
478 // rebuild the menu, strings may have changed
481 drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings and %update strings were updated.', array('%number' => $additions, '%update' => $updates)));
482 watchdog('locale', t('Imported %file into %locale: %number new strings added and %update updated.', array('%file' => theme('placeholder', $file->filename), '%locale' => theme('placeholder', $lang), '%number' => $additions, '%update' => $updates)));
487 * Parses Gettext Portable Object file into an array
489 * @param $file Object with properties of local file to parse
490 * @author Jacobo Tarrio
492 function _locale_import_read_po($file, $mode, $lang) {
494 $message = theme('placeholder', $file->filename);
495 $fd = fopen($file->filepath, "rb"); // File will get closed by PHP on return
497 drupal_set_message(t('The translation import failed, because the file %filename could not be read.', array('%filename' => $message)), 'error');
501 $context = "COMMENT"; // Parser context: COMMENT, MSGID, MSGID_PLURAL, MSGSTR and MSGSTR_ARR
502 $current = array(); // Current entry being read
503 $plural = 0; // Current plural form
504 $lineno = 0; // Current line
507 $line = fgets($fd, 10*1024); // A line should not be this long
509 $line = trim(strtr($line, array("\\\n" => "")));
511 if (!strncmp("#", $line, 1)) { // A comment
512 if ($context == "COMMENT") { // Already in comment context: add
513 $current["#"][] = substr($line, 1);
515 elseif (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one
516 _locale_import_one_string($current, $mode, $lang);
518 $current["#"][] = substr($line, 1);
519 $context = "COMMENT";
521 else { // Parse error
522 drupal_set_message(t('The translation file %filename contains an error: "msgstr" was expected but not found on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
526 elseif (!strncmp("msgid_plural", $line, 12)) {
527 if ($context != "MSGID") { // Must be plural form for current entry
528 drupal_set_message(t('The translation file %filename contains an error: "msgid_plural" was expected but not found on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
531 $line = trim(substr($line, 12));
532 $quoted = _locale_import_parse_quoted($line);
533 if ($quoted === false) {
534 drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
537 $current["msgid"] = $current["msgid"] ."\0". $quoted;
538 $context = "MSGID_PLURAL";
540 elseif (!strncmp("msgid", $line, 5)) {
541 if ($context == "MSGSTR") { // End current entry, start a new one
542 _locale_import_one_string($current, $mode, $lang);
545 elseif ($context == "MSGID") { // Already in this context? Parse error
546 drupal_set_message(t('The translation file %filename contains an error: "msgid" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
549 $line = trim(substr($line, 5));
550 $quoted = _locale_import_parse_quoted($line);
551 if ($quoted === false) {
552 drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
555 $current["msgid"] = $quoted;
558 elseif (!strncmp("msgstr[", $line, 7)) {
559 if (($context != "MSGID") && ($context != "MSGID_PLURAL") && ($context != "MSGSTR_ARR")) { // Must come after msgid, msgid_plural, or msgstr[]
560 drupal_set_message(t('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
563 if (strpos($line, "]") === false) {
564 drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
567 $frombracket = strstr($line, "[");
568 $plural = substr($frombracket, 1, strpos($frombracket, "]") - 1);
569 $line = trim(strstr($line, " "));
570 $quoted = _locale_import_parse_quoted($line);
571 if ($quoted === false) {
572 drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
575 $current["msgstr"][$plural] = $quoted;
576 $context = "MSGSTR_ARR";
578 elseif (!strncmp("msgstr", $line, 6)) {
579 if ($context != "MSGID") { // Should come just after a msgid block
580 drupal_set_message(t('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
583 $line = trim(substr($line, 6));
584 $quoted = _locale_import_parse_quoted($line);
585 if ($quoted === false) {
586 drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
589 $current["msgstr"] = $quoted;
592 elseif ($line != "") {
593 $quoted = _locale_import_parse_quoted($line);
594 if ($quoted === false) {
595 drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
598 if (($context == "MSGID") || ($context == "MSGID_PLURAL")) {
599 $current["msgid"] .= $quoted;
601 elseif ($context == "MSGSTR") {
602 $current["msgstr"] .= $quoted;
604 elseif ($context == "MSGSTR_ARR") {
605 $current["msgstr"][$plural] .= $quoted;
608 drupal_set_message(t('The translation file %filename contains an error: there is an unexpected string on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
614 // End of PO file, flush last entry
615 if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) {
616 _locale_import_one_string($current, $mode, $lang);
618 elseif ($context != "COMMENT") {
619 drupal_set_message(t('The translation file %filename ended unexpectedly at line %line.', array('%filename' => $message, '%line' => $lineno)), 'error');
626 * Imports a string into the database
628 * @param $value Information about the string
629 * @author Jacobo Tarrio
631 function _locale_import_one_string($value, $mode, $lang = NULL) {
632 static $additions = 0;
634 static $headerdone = FALSE;
636 // Report the changes made (called at end of import)
637 if ($value == 'report') {
638 return array($headerdone, $additions, $updates);
640 // Current string is the header information
641 elseif ($value['msgid'] == '') {
642 $hdr = _locale_import_parse_header($value['msgstr']);
644 // Get the plural formula
645 if ($hdr["Plural-Forms"] && $p = _locale_import_parse_plural_forms($hdr["Plural-Forms"], $file->filename)) {
646 list($nplurals, $plural) = $p;
647 db_query("UPDATE {locales_meta} SET plurals = %d, formula = '%s' WHERE locale = '%s'", $nplurals, $plural, $lang);
650 db_query("UPDATE {locales_meta} SET plurals = %d, formula = '%s' WHERE locale = '%s'", 0, '', $lang);
654 // Some real string to import
656 $comments = filter_xss_admin(_locale_import_shorten_comments($value['#']));
658 // Handle a translation for some plural string
659 if (strpos($value['msgid'], "\0")) {
660 $english = explode("\0", $value['msgid'], 2);
661 $entries = array_keys($value['msgstr']);
662 for ($i = 3; $i <= count($entries); $i++) {
663 $english[] = $english[1];
665 $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries);
666 $english = array_map('_locale_import_append_plural', $english, $entries);
667 foreach ($translation as $key => $trans) {
671 $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english[$key]));
672 if ($loc->lid) { // a string exists
674 // update location field
675 db_query("UPDATE {locales_source} SET location = '%s' WHERE lid = %d", $comments, $lid);
676 $trans2 = db_fetch_object(db_query("SELECT lid, translation, plid, plural FROM {locales_target} WHERE lid = %d AND locale = '%s'", $lid, $lang));
677 if (!$trans2->lid) { // no translation in current language
678 db_query("INSERT INTO {locales_target} (lid, locale, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $lang, filter_xss_admin($trans), $plid, $key);
680 } // translation exists
681 else if ($mode == 'overwrite' || $trans2->translation == '') {
682 db_query("UPDATE {locales_target} SET translation = '%s', plid = %d, plural = %d WHERE locale = '%s' AND lid = %d", filter_xss_admin($trans), $plid, $key, $lang, $lid);
683 if ($trans2->translation == '') {
692 db_query("INSERT INTO {locales_source} (location, source) VALUES ('%s', '%s')", $comments, filter_xss_admin($english[$key]));
693 $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english[$key]));
695 db_query("INSERT INTO {locales_target} (lid, locale, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $lang, filter_xss_admin($trans), $plid, $key);
704 // A simple translation
706 $english = $value['msgid'];
707 $translation = $value['msgstr'];
708 $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english));
709 if ($loc->lid) { // a string exists
711 // update location field
712 db_query("UPDATE {locales_source} SET location = '%s' WHERE source = '%s'", $comments, $english);
713 $trans = db_fetch_object(db_query("SELECT lid, translation FROM {locales_target} WHERE lid = %d AND locale = '%s'", $lid, $lang));
714 if (!$trans->lid) { // no translation in current language
715 db_query("INSERT INTO {locales_target} (lid, locale, translation) VALUES (%d, '%s', '%s')", $lid, $lang, filter_xss_admin($translation));
717 } // translation exists
718 else if ($mode == 'overwrite') { //overwrite in any case
719 db_query("UPDATE {locales_target} SET translation = '%s' WHERE locale = '%s' AND lid = %d", filter_xss_admin($translation), $lang, $lid);
720 if ($trans->translation == '') {
726 } // overwrite if empty string
727 else if ($trans->translation == '') {
728 db_query("UPDATE {locales_target} SET translation = '%s' WHERE locale = '%s' AND lid = %d", $translation, $lang, $lid);
733 db_query("INSERT INTO {locales_source} (location, source) VALUES ('%s', '%s')", $comments, $english);
734 $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english));
736 db_query("INSERT INTO {locales_target} (lid, locale, translation) VALUES (%d, '%s', '%s')", $lid, $lang, filter_xss_admin($translation));
737 if ($translation != '') {
746 * Parses a Gettext Portable Object file header
748 * @param $header A string containing the complete header
749 * @return An associative array of key-value pairs
750 * @author Jacobo Tarrio
752 function _locale_import_parse_header($header) {
755 $lines = explode("\n", $header);
756 foreach ($lines as $line) {
759 list($tag, $contents) = explode(":", $line, 2);
760 $hdr[trim($tag)] = trim($contents);
768 * Parses a Plural-Forms entry from a Gettext Portable Object file header
770 * @param $pluralforms A string containing the Plural-Forms entry
771 * @param $filename A string containing the filename
772 * @return An array containing the number of plurals and a
773 * formula in PHP for computing the plural form
774 * @author Jacobo Tarrio
776 function _locale_import_parse_plural_forms($pluralforms, $filename) {
777 // First, delete all whitespace
778 $pluralforms = strtr($pluralforms, array(" " => "", "\t" => ""));
780 // Select the parts that define nplurals and plural
781 $nplurals = strstr($pluralforms, "nplurals=");
782 if (strpos($nplurals, ";")) {
783 $nplurals = substr($nplurals, 9, strpos($nplurals, ";") - 9);
788 $plural = strstr($pluralforms, "plural=");
789 if (strpos($plural, ";")) {
790 $plural = substr($plural, 7, strpos($plural, ";") - 7);
796 // Get PHP version of the plural formula
797 $plural = _locale_import_parse_arithmetic($plural);
799 if ($plural !== FALSE) {
800 return array($nplurals, $plural);
803 drupal_set_message(t('The translation file %filename contains an error: the plural formula could not be parsed.', array('%filename' => theme('placeholder', $filename))), 'error');
809 * Parses and sanitizes an arithmetic formula into a PHP expression
811 * While parsing, we ensure, that the operators have the right
812 * precedence and associativity.
814 * @param $string A string containing the arithmetic formula
815 * @return The PHP version of the formula
816 * @author Jacobo Tarrio
818 function _locale_import_parse_arithmetic($string) {
819 // Operator precedence table
820 $prec = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
821 // Right associativity
822 $rasc = array("?" => 1, ":" => 1);
824 $tokens = _locale_import_tokenize_formula($string);
826 // Parse by converting into infix notation then back into postfix
830 foreach ($tokens as $token) {
833 // Numbers and the $n variable are simply pushed into $elarr
834 if (is_numeric($token)) {
837 elseif ($ctok == "n") {
840 elseif ($ctok == "(") {
843 elseif ($ctok == ")") {
844 $topop = array_pop($opstk);
845 while (($topop != NULL) && ($topop != "(")) {
847 $topop = array_pop($opstk);
850 elseif ($prec[$ctok]) {
851 // If it's an operator, then pop from $oparr into $elarr until the
852 // precedence in $oparr is less than current, then push into $oparr
853 $topop = array_pop($opstk);
854 while (($topop != NULL) && ($prec[$topop] >= $prec[$ctok]) && !(($prec[$topop] == $prec[$ctok]) && $rasc[$topop] && $rasc[$ctok])) {
856 $topop = array_pop($opstk);
859 $opstk[] = $topop; // Return element to top
861 $opstk[] = $ctok; // Parentheses are not needed
868 // Flush operator stack
869 $topop = array_pop($opstk);
870 while ($topop != NULL) {
872 $topop = array_pop($opstk);
875 // Now extract formula from stack
876 $prevsize = count($elstk) + 1;
877 while (count($elstk) < $prevsize) {
878 $prevsize = count($elstk);
879 for ($i = 2; $i < count($elstk); $i++) {
884 $f = $elstk[$i - 2] ."):". $elstk[$i - 1] .")";
886 elseif ($op == "?") {
887 $f = "(". $elstk[$i - 2] ."?(". $elstk[$i - 1];
890 $f = "(". $elstk[$i - 2] . $op . $elstk[$i - 1] .")";
892 array_splice($elstk, $i - 2, 3, $f);
898 // If only one element is left, the number of operators is appropriate
899 if (count($elstk) == 1) {
908 * Backward compatible implementation of token_get_all() for formula parsing
910 * @param $string A string containing the arithmetic formula
911 * @return The PHP version of the formula
912 * @author Gerhard Killesreiter
914 function _locale_import_tokenize_formula($formula) {
915 $formula = str_replace(" ", "", $formula);
917 for ($i = 0; $i < strlen($formula); $i++) {
918 if (is_numeric($formula[$i])) {
921 while($j < strlen($formula) && is_numeric($formula[$j])) {
922 $num .= $formula[$j];
928 elseif ($pos = strpos(" =<>!&|", $formula[$i])) { // We won't have a space
929 $next = $formula[$i + 1];
936 $tokens[] = $formula[$i] .'=';
940 $tokens[] = $formula[$i];
949 $tokens[] = $formula[$i];
958 $tokens[] = $formula[$i];
964 $tokens[] = $formula[$i];
971 * Modify a string to contain proper count indices
973 * This is a callback function used via array_map()
975 * @param $entry An array element
976 * @param $key Index of the array element
978 function _locale_import_append_plural($entry, $key) {
979 // No modifications for 0, 1
980 if ($key == 0 || $key == 1) {
984 // First remove any possibly false indices, then add new ones
985 $entry = preg_replace('/(%count)\[[0-9]\]/', '\\1', $entry);
986 return preg_replace('/(%count)/', "\\1[$key]", $entry);
990 * Generate a short, one string version of the passed comment array
992 * @param $comment An array of strings containing a comment
993 * @return Short one string version of the comment
995 function _locale_import_shorten_comments($comment) {
997 while (count($comment)) {
998 $test = $comm . substr(array_shift($comment), 1) .', ';
999 if (strlen($comm) < 130) {
1006 return substr($comm, 0, -2);
1010 * Parses a string in quotes
1012 * @param $string A string specified with enclosing quotes
1013 * @return The string parsed from inside the quotes
1015 function _locale_import_parse_quoted($string) {
1016 if (substr($string, 0, 1) != substr($string, -1, 1)) {
1017 return FALSE; // Start and end quotes must be the same
1019 $quote = substr($string, 0, 1);
1020 $string = substr($string, 1, -1);
1021 if ($quote == '"') { // Double quotes: strip slashes
1022 return stripcslashes($string);
1024 elseif ($quote == "'") { // Simple quote: return as-is
1028 return FALSE; // Unrecognized quote
1033 * Exports a Portable Object (Template) file for a language
1035 * @param $language Selects a language to generate the output for
1037 function _locale_export_po($language) {
1040 // Get language specific strings, or all strings
1042 $meta = db_fetch_object(db_query("SELECT * FROM {locales_meta} WHERE locale = '%s'", $language));
1043 $result = db_query("SELECT s.lid, s.source, s.location, t.translation, t.plid, t.plural FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE t.locale = '%s' ORDER BY t.plid, t.plural", $language);
1046 $result = db_query("SELECT s.lid, s.source, s.location, t.plid, t.plural FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid ORDER BY t.plid, t.plural");
1049 // Build array out of the database results
1051 while ($child = db_fetch_object($result)) {
1052 if ($child->source != '') {
1053 $parent[$child->lid]['comment'] = $child->location;
1054 $parent[$child->lid]['msgid'] = $child->source;
1056 $parent[$child->lid][$child->plid]['plural'] = $child->lid;
1057 $parent[$child->lid][$child->plid]['translation'] = $child->translation;
1058 $parent[$child->lid][$child->plid]['msgid'] = $child->source;
1061 $parent[$child->lid]['translation'] = $child->translation;
1066 // Generating Portable Object file for a language
1068 $filename = $language .'.po';
1069 $header .= "# $meta->name translation of ". variable_get('site_name', 'Drupal') ."\n";
1070 $header .= '# Copyright (c) '. date('Y') .' '. $user->name .' <'. $user->mail .">\n";
1072 $header .= "msgid \"\"\n";
1073 $header .= "msgstr \"\"\n";
1074 $header .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
1075 $header .= "\"POT-Creation-Date: ". date("Y-m-d H:iO") ."\\n\"\n";
1076 $header .= "\"PO-Revision-Date: ". date("Y-m-d H:iO") ."\\n\"\n";
1077 $header .= "\"Last-Translator: ". $user->name .' <'. $user->mail .">\\n\"\n";
1078 $header .= "\"Language-Team: ". $meta->name .' <'. $user->mail .">\\n\"\n";
1079 $header .= "\"MIME-Version: 1.0\\n\"\n";
1080 $header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
1081 $header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
1082 if ($meta->formula && $meta->plurals) {
1083 $header .= "\"Plural-Forms: nplurals=". $meta->plurals ."; plural=". strtr($meta->formula, '$', '') .";\\n\"\n";
1086 watchdog('locale', t('Exported %locale translation file: %filename.', array('%locale' => theme('placeholder', $meta->name), '%filename' => theme('placeholder', $filename))));
1089 // Generating Portable Object Template
1091 $filename = 'drupal.pot';
1092 $header .= "# LANGUAGE translation of PROJECT\n";
1093 $header .= "# Copyright (c) YEAR NAME <EMAIL@ADDRESS>\n";
1095 $header .= "msgid \"\"\n";
1096 $header .= "msgstr \"\"\n";
1097 $header .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
1098 $header .= "\"POT-Creation-Date: ". date("Y-m-d H:iO") ."\\n\"\n";
1099 $header .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n";
1100 $header .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n";
1101 $header .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n";
1102 $header .= "\"MIME-Version: 1.0\\n\"\n";
1103 $header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
1104 $header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
1105 $header .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n";
1107 watchdog('locale', t('Exported translation file: %filename.', array('%filename' => theme('placeholder', $filename))));
1110 // Start download process
1111 header("Content-Disposition: attachment; filename=$filename");
1112 header("Content-Type: text/plain; charset=utf-8");
1116 foreach ($parent as $lid => $message) {
1117 if (!isset($done[$lid])) {
1118 if ($message['comment']) {
1119 print '#: '. $message['comment'] ."\n";
1121 print 'msgid '. _locale_export_print($message['msgid']);
1122 if (isset($message[1]['plural'])) {
1123 print 'msgid_plural '. _locale_export_print($message[1]['msgid']);
1125 for ($i = 0; $i < $meta->plurals; $i++) {
1126 print 'msgstr['. $i .'] '. _locale_export_print(_locale_export_remove_plural($message[${i}]['translation']));
1127 $done[$message[${i}]['plural']] = 1;
1131 print 'msgstr[0] ""'. "\n";
1132 print 'msgstr[1] ""'. "\n";
1133 $done[$message[0]['plural']] = 1;
1134 $done[$message[1]['plural']] = 1;
1139 print 'msgstr '. _locale_export_print($message['translation']);
1142 print 'msgstr ""'. "\n";
1152 * Print out a string on multiple lines
1154 function _locale_export_print($str) {
1155 $stri = addcslashes($str, "\0..\37\\\"");
1158 // Cut text into several lines
1159 while ($stri != "") {
1160 $i = strpos($stri, "\\n");
1166 $curstr = substr($stri, 0, $i + 2);
1167 $stri = substr($stri, $i + 2);
1169 $curparts = explode("\n", _locale_export_wrap($curstr, 70));
1170 $parts = array_merge($parts, $curparts);
1173 if (count($parts) > 1) {
1174 return "\"\"\n\"". implode("\"\n\"", $parts) ."\"\n";
1177 return "\"$parts[0]\"\n";
1182 * Custom word wrapping for Portable Object (Template) files.
1184 * @author Jacobo Tarrio
1186 function _locale_export_wrap($str, $len) {
1187 $words = explode(' ', $str);
1192 while (count($words)) {
1193 $word = array_shift($words);
1198 elseif (strlen("$cur $word") > $len) {
1199 $ret[] = $cur . " ";
1203 $cur = "$cur $word";
1208 return implode("\n", $ret);
1212 * Removes plural index information from a string
1214 function _locale_export_remove_plural($entry) {
1215 return preg_replace('/(%count)\[[0-9]\]/', '\\1', $entry);
1219 * List languages in search result table
1221 function _locale_string_language_list($translation) {
1222 $languages = locale_supported_languages(FALSE, TRUE);
1223 unset($languages['name']['en']);
1225 foreach ($languages['name'] as $key => $value) {
1226 if (isset($translation[$key])) {
1227 $output .= ($translation[$key] != '') ? $key .' ' : "<em class=\"locale-untranslated\">$key</em> ";
1235 * Build object out of search criteria specified in request variables
1237 function _locale_string_seek_query() {
1238 static $query = NULL;
1240 if (is_null($query)) {
1241 $fields = array('string', 'language', 'searchin');
1242 $query = new StdClass;
1243 if (is_array($_REQUEST['edit'])) {
1244 foreach ($_REQUEST['edit'] as $key => $value) {
1245 if (!empty($value) && in_array($key, $fields)) {
1246 $query->$key = $value;
1251 foreach ($_REQUEST as $key => $value) {
1252 if (!empty($value) && in_array($key, $fields)) {
1253 $query->$key = strpos(',', $value) ? explode(',', $value) : $value;
1262 * Perform a string search and display results in a table
1264 function _locale_string_seek() {
1265 // We have at least one criterion to match
1266 if ($query = _locale_string_seek_query()) {
1267 $join = "SELECT s.source, s.location, s.lid, t.translation, t.locale FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid ";
1269 $arguments = array();
1270 // Compute LIKE section
1271 switch ($query->searchin) {
1273 $where = "WHERE (t.translation LIKE '%%%s%%' AND t.translation != '')";
1274 $orderby = "ORDER BY t.translation";
1275 $arguments[] = $query->string;
1277 case 'untranslated':
1278 $where = "WHERE (s.source LIKE '%%%s%%' AND t.translation = '')";
1279 $orderby = "ORDER BY s.source";
1280 $arguments[] = $query->string;
1284 $where = "WHERE (s.source LIKE '%%%s%%' OR t.translation LIKE '%%%s%%')";
1286 $arguments[] = $query->string;
1287 $arguments[] = $query->string;
1291 switch ($query->language) {
1292 // Force search in source strings
1294 $sql = $join ." WHERE s.source LIKE '%%%s%%' ORDER BY s.source";
1295 $arguments = array($query->string); // $where is not used, discard its arguments
1297 // Search in all languages
1299 $sql = "$join $where $orderby";
1301 // Some different language
1303 $sql = "$join $where AND t.locale = '%s' $orderby";
1304 $arguments[] = $query->language;
1307 $result = pager_query($sql, 50, 0, NULL, $arguments);
1309 $header = array(t('String'), t('Locales'), array('data' => t('Operations'), 'colspan' => '2'));
1311 while ($locale = db_fetch_object($result)) {
1312 $arr[$locale->lid]['locales'][$locale->locale] = $locale->translation;
1313 $arr[$locale->lid]['location'] = $locale->location;
1314 $arr[$locale->lid]['source'] = $locale->source;
1316 foreach ($arr as $lid => $value) {
1317 $rows[] = array(array('data' => check_plain(truncate_utf8($value['source'], 150, FALSE, TRUE)) .'<br /><small>'. $value['location'] .'</small>'), array('data' => _locale_string_language_list($value['locales']), 'align' => 'center'), array('data' => l(t('edit'), "admin/locale/string/edit/$lid"), 'class' => 'nowrap'), array('data' => l(t('delete'), "admin/locale/string/delete/$lid"), 'class' => 'nowrap'));
1321 if (count($query)) {
1322 foreach ($query as $key => $value) {
1323 $request[$key] = (is_array($value)) ? implode(',', $value) : $value;
1328 $output .= theme('table', $header, $rows);
1330 if ($pager = theme('pager', NULL, 50, 0, $request)) {
1338 // ---------------------------------------------------------------------------------
1339 // List of some of the most common languages (administration only)
1342 * Prepares the language code list for a select form item with only the unsupported ones
1344 function _locale_prepare_iso_list() {
1345 $languages = locale_supported_languages(FALSE, TRUE);
1346 $isocodes = _locale_get_iso639_list();
1347 foreach ($isocodes as $key => $value) {
1348 if (isset($languages['name'][$key])) {
1349 unset($isocodes[$key]);
1352 if (count($value) == 2) {
1353 $tname = t($value[0]);
1354 $isocodes[$key] = ($tname == $value[1]) ? $tname : "$tname ($value[1])";
1357 $isocodes[$key] = t($value[0]);
1365 * Some of the common languages with their English and native names
1367 * Based on ISO 639 and http://people.w3.org/rishida/names/languages.html
1369 function _locale_get_iso639_list() {
1371 "aa" => array("Afar"),
1372 "ab" => array("Abkhazian", "аҧсуа бызшәа"),
1373 "ae" => array("Avestan"),
1374 "af" => array("Afrikaans"),
1375 "ak" => array("Akan"),
1376 "am" => array("Amharic", "አማርኛ"),
1377 "ar" => array("Arabic", "العربية"),
1378 "as" => array("Assamese"),
1379 "av" => array("Avar"),
1380 "ay" => array("Aymara"),
1381 "az" => array("Azerbaijani", "azərbaycan"),
1382 "ba" => array("Bashkir"),
1383 "be" => array("Belarusian", "Беларуская"),
1384 "bg" => array("Bulgarian", "Български"),
1385 "bh" => array("Bihari"),
1386 "bi" => array("Bislama"),
1387 "bm" => array("Bambara", "Bamanankan"),
1388 "bn" => array("Bengali"),
1389 "bo" => array("Tibetan"),
1390 "br" => array("Breton"),
1391 "bs" => array("Bosnian", "Bosanski"),
1392 "ca" => array("Catalan", "Català"),
1393 "ce" => array("Chechen"),
1394 "ch" => array("Chamorro"),
1395 "co" => array("Corsican"),
1396 "cr" => array("Cree"),
1397 "cs" => array("Czech", "Čeština"),
1398 "cu" => array("Old Slavonic"),
1399 "cv" => array("Welsh", "Cymraeg"),
1400 "cy" => array("Welch"),
1401 "da" => array("Danish", "Dansk"),
1402 "de" => array("German", "Deutsch"),
1403 "dv" => array("Maldivian"),
1404 "dz" => array("Bhutani"),
1405 "ee" => array("Ewe", "Ɛʋɛ"),
1406 "el" => array("Greek", "Ελληνικά"),
1407 "en" => array("English"),
1408 "eo" => array("Esperanto"),
1409 "es" => array("Spanish", "Español"),
1410 "et" => array("Estonian", "Eesti"),
1411 "eu" => array("Basque", "Euskera"),
1412 "fa" => array("Persian", "فارسی"),
1413 "ff" => array("Fulah", "Fulfulde"),
1414 "fi" => array("Finnish", "Suomi"),
1415 "fj" => array("Fiji"),
1416 "fo" => array("Faeroese"),
1417 "fr" => array("French", "Français"),
1418 "fy" => array("Frisian", "Frysk"),
1419 "ga" => array("Irish", "Gaeilge"),
1420 "gd" => array("Scots Gaelic"),
1421 "gl" => array("Galician", "Galego"),
1422 "gn" => array("Guarani"),
1423 "gu" => array("Gujarati"),
1424 "gv" => array("Manx"),
1425 "ha" => array("Hausa"),
1426 "he" => array("Hebrew", "עברית"),
1427 "hi" => array("Hindi", "हिन्दी"),
1428 "ho" => array("Hiri Motu"),
1429 "hr" => array("Croatian", "Hrvatski"),
1430 "hu" => array("Hungarian", "Magyar"),
1431 "hy" => array("Armenian", "Հայերեն"),
1432 "hz" => array("Herero"),
1433 "ia" => array("Interlingua"),
1434 "id" => array("Indonesian", "Bahasa Indonesia"),
1435 "ie" => array("Interlingue"),
1436 "ig" => array("Igbo"),
1437 "ik" => array("Inupiak"),
1438 "is" => array("Icelandic", "Íslenska"),
1439 "it" => array("Italian", "Italiano"),
1440 "iu" => array("Inuktitut"),
1441 "ja" => array("Japanese", "日本語"),
1442 "jv" => array("Javanese"),
1443 "ka" => array("Georgian"),
1444 "kg" => array("Kongo"),
1445 "ki" => array("Kikuyu"),
1446 "kj" => array("Kwanyama"),
1447 "kk" => array("Kazakh", "Қазақ"),
1448 "kl" => array("Greenlandic"),
1449 "km" => array("Cambodian"),
1450 "kn" => array("Kannada", "ಕನ್ನಡ"),
1451 "ko" => array("Korean", "한국어"),
1452 "kr" => array("Kanuri"),
1453 "ks" => array("Kashmiri"),
1454 "ku" => array("Kurdish", "Kurdî"),
1455 "kv" => array("Komi"),
1456 "kw" => array("Cornish"),
1457 "ky" => array("Kirghiz", "Кыргыз"),
1458 "la" => array("Latin", "Latina"),
1459 "lb" => array("Luxembourgish"),
1460 "lg" => array("Luganda"),
1461 "ln" => array("Lingala"),
1462 "lo" => array("Laothian"),
1463 "lt" => array("Lithuanian", "Lietuviškai"),
1464 "lv" => array("Latvian", "Latviešu"),
1465 "mg" => array("Malagasy"),
1466 "mh" => array("Marshallese"),
1467 "mi" => array("Maori"),
1468 "mk" => array("Macedonian", "Македонски"),
1469 "ml" => array("Malayalam", "മലയാളം"),
1470 "mn" => array("Mongolian"),
1471 "mo" => array("Moldavian"),
1472 "mr" => array("Marathi"),
1473 "ms" => array("Malay", "Bahasa Melayu"),
1474 "mt" => array("Maltese", "Malti"),
1475 "my" => array("Burmese"),
1476 "na" => array("Nauru"),
1477 "nd" => array("North Ndebele"),
1478 "ne" => array("Nepali"),
1479 "ng" => array("Ndonga"),
1480 "nl" => array("Dutch", "Nederlands"),
1481 "no" => array("Norwegian", "Norsk"),
1482 "nr" => array("South Ndebele"),
1483 "nv" => array("Navajo"),
1484 "ny" => array("Chichewa"),
1485 "oc" => array("Occitan"),
1486 "om" => array("Oromo"),
1487 "or" => array("Oriya"),
1488 "os" => array("Ossetian"),
1489 "pa" => array("Punjabi"),
1490 "pi" => array("Pali"),
1491 "pl" => array("Polish", "Polski"),
1492 "ps" => array("Pashto", "پښتو"),
1493 "pt" => array("Portuguese", "Português"),
1494 "qu" => array("Quechua"),
1495 "rm" => array("Rhaeto-Romance"),
1496 "rn" => array("Kirundi"),
1497 "ro" => array("Romanian", "Română"),
1498 "ru" => array("Russian", "Русский"),
1499 "rw" => array("Kinyarwanda"),
1500 "sa" => array("Sanskrit"),
1501 "sc" => array("Sardinian"),
1502 "sd" => array("Sindhi"),
1503 "se" => array("Northern Sami"),
1504 "sg" => array("Sango"),
1505 "sh" => array("Serbo-Croatian"),
1506 "si" => array("Singhalese"),
1507 "sk" => array("Slovak", "Slovenčina"),
1508 "sl" => array("Slovenian", "Slovenščina"),
1509 "sm" => array("Samoan"),
1510 "sn" => array("Shona"),
1511 "so" => array("Somali"),
1512 "sq" => array("Albanian", "Shqip"),
1513 "sr" => array("Serbian", "Српски"),
1514 "ss" => array("Siswati"),
1515 "st" => array("Sesotho"),
1516 "su" => array("Sudanese"),
1517 "sv" => array("Swedish", "Svenska"),
1518 "sw" => array("Swahili", "Kiswahili"),
1519 "ta" => array("Tamil", "தமிழ்"),
1520 "te" => array("Telugu", "తెలుగు"),
1521 "tg" => array("Tajik"),
1522 "th" => array("Thai", "ภาษาไทย"),
1523 "ti" => array("Tigrinya"),
1524 "tk" => array("Turkmen"),
1525 "tl" => array("Tagalog"),
1526 "tn" => array("Setswana"),
1527 "to" => array("Tonga"),
1528 "tr" => array("Turkish", "Türkçe"),
1529 "ts" => array("Tsonga"),
1530 "tt" => array("Tatar", "Tatarça"),
1531 "tw" => array("Twi"),
1532 "ty" => array("Tahitian"),
1533 "ug" => array("Uighur"),
1534 "uk" => array("Ukrainian", "Українська"),
1535 "ur" => array("Urdu", "اردو"),
1536 "uz" => array("Uzbek", "o'zbek"),
1537 "ve" => array("Venda"),
1538 "vi" => array("Vietnamese", "Tiếng Việt"),
1539 "wo" => array("Wolof"),
1540 "xh" => array("Xhosa", "isiXhosa"),
1541 "yi" => array("Yiddish"),
1542 "yo" => array("Yoruba", "Yorùbá"),
1543 "za" => array("Zhuang"),
1544 "zh-hans" => array("Chinese, Simplified", "简体中文"),
1545 "zh-hant" => array("Chinese, Traditional", "繁體中文"),
1546 "zu" => array("Zulu", "isiZulu"),