/** * Return full text translated to language label for a key. Store key-label in a cache. * This function need module "numberwords" to be installed. If not it will return * same number (this module is not provided by default as it use non GPL source code). * * @param int $number Number to encode in full text * @param int $isamount 1=It's an amount, 0=it's just a number * @return string Label translated in UTF8 (but without entities) * 10 if setDefaultLang was en_US => ten * 123 if setDefaultLang was fr_FR => cent vingt trois */ function getLabelFromNumber($number, $isamount = 0) { global $conf; $newnumber = $number; $dirsubstitutions = array_merge(array(), $conf->modules_parts['substitutions']); foreach ($dirsubstitutions as $reldir) { $dir = dol_buildpath($reldir, 0); $newdir = dol_osencode($dir); // Check if directory exists if (!is_dir($newdir)) { continue; } // We must not use dol_is_dir here, function may not be loaded $fonc = 'numberwords'; if (file_exists($newdir . '/functions_' . $fonc . '.lib.php')) { include_once $newdir . '/functions_' . $fonc . '.lib.php'; $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount); break; } } return $newnumber; }
/** * Return full text translated to language label for a key. Store key-label in a cache. * This function need module "numberwords" to be installed. If not it will return * same number (this module is not provided by default as it use non GPL source code). * @param number Number to encode in full text * @param isamount 1=It's an amount, 0=it's just a number * @return string Label translated in UTF8 (but without entities) * 10 if setDefaultLang was en_US => ten * 123 if setDefaultLang was fr_FR => cent vingt trois */ function getLabelFromNumber($number, $isamount = 0) { global $conf; /* $outlang=$this->defaultlang; // Output language we want $outlangarray=explode('_',$outlang,2); // If lang is xx_XX, then we use xx if (strtolower($outlangarray[0]) == strtolower($outlangarray[1])) $outlang=$outlangarray[0]; */ $newnumber = $number; foreach ($conf->file->dol_document_root as $dirroot) { $dir = $dirroot . "/includes/modules/substitutions"; $fonc = 'numberwords'; if (file_exists($dir . '/functions_' . $fonc . '.lib.php')) { include_once $dir . '/functions_' . $fonc . '.lib.php'; $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount); break; } } return $newnumber; }