Skip to content

Commit

Permalink
Check for mecab then enable mecab
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgramComputer committed Oct 6, 2023
1 parent 2ffec1a commit 8261681
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions inc/session_utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -4706,19 +4706,23 @@ function trim_value(&$value): void
* is supported, using MeCab.
*
* @param string $text Text to be converted
* @param string $lang Language code (usually BCP 47 or ISO 639-1)
* @param string $languageName Name of the language
* @return string Parsed text in a phonetic format.
*
* @since 2.9.0 Any language starting by "ja" or "jp" is considered phonetic.
*/
function phonetic_reading($text, $lang)
function phonetic_reading($text, $languageName)
{
global $tbpref;
$mecab = get_first_value('select LgRegexpWordCharacters as value from ' . $tbpref . 'languages where LgName = ' . '"'.$languageName.'"');

// Many languages are already phonetic
if (!str_starts_with($lang, "ja") && !str_starts_with($lang, "jp")) {
if ( $mecab != "mecab") {

return $text;
}


// Japanese is an exception
$mecab_file = sys_get_temp_dir() . "/" . $tbpref . "mecab_to_db.txt";
$mecab_args = ' -O yomi ';
Expand Down

0 comments on commit 8261681

Please sign in to comment.