transliteration.module in Transliteration 5.2
Same filename and directory in other branches
Provides transliteration for UTF-8 text input and sanitzes file names.
Uses data from the Text::Unidecode Perl library.
File
transliteration.moduleView source
<?php
/**
* @file
* Provides transliteration for UTF-8 text input and sanitzes file names.
*
* Uses data from the Text::Unidecode Perl library.
* @see http://search.cpan.org/~sburke/Text-Unidecode-0.04/lib/Text/Unidecode.pm
*/
/**
* Transliterate UTF-8 text to ASCII.
*
* Takes an input string in any language and character set, and tries to
* represent it in ASCII characters by conveying, in Roman letters, the
* pronunciation expressed by the text in some other writing system.
*
* @param $input
* UTF-8 text input.
* @param $unknown
* Replacement string for characters that do not have a suitable ASCII
* equivalent.
* @param $locale
* Optional ISO 639 language code that denotes the language of the input.
* Used to apply language-specific variations and defaults to the current
* display language. If transliteration takes place during output (instead
* of creation) and the source language is not known at that time, it is
* recommended to set this argument to 'en' to produce consistent results
* for all enabled languages.
* @return
* Transliterated text.
*/
function transliteration_get($input, $unknown = '?', $locale = NULL) {
require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
return transliteration_process($input, $unknown, $locale);
}
/**
* Implementation of hook_menu().
*
* Transliterate and clean the names of files currently being uploaded.
*/
function transliteration_menu($may_cache) {
if (!$may_cache && !empty($_FILES['files'])) {
require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
foreach ($_FILES['files']['name'] as $field => $filename) {
// Keep a copy of the unaltered file name.
$_FILES['files']['orig_name'][$field] = $filename;
$_FILES['files']['name'][$field] = transliteration_clean_filename($filename);
}
}
}
Functions
Name | Description |
---|---|
transliteration_get | Transliterate UTF-8 text to ASCII. |
transliteration_menu | Implementation of hook_menu(). |