No, that function will do the translation for you based on the user's language code.So only i write this code in functions.php and thats it? No others modifies to the php?Some php events are missing (mcp) to completely convert that MOD into an extension.
If you want to translate the forum names and descriptions only for the user then it is possible.
If you want only two languages, you could simply skip the ACP part and use the following:
Note: this will force you to use | as a delimiter for your translations.
"My first forum|Primul meu forum
".Code:
function get_text_for_language($input, $lang){ $delimiter = '|'; $languages = ['en', 'ro']; $forum_names = explode($delimiter, $input); if (count($forum_names) == count($languages)) { $i = array_search($lang, $languages); if ($i !== false) { return $forum_names[$i]; } else { return $input; } } else { return $input; }}
For example, you can use that function in an extension to translate the forum names and descriptions on the index page like this:
Code:
public function display_forums_modify_template_vars($event) { $forum_row = $event['forum_row']; $tra_forum_name = $this->translate_forum($forum_row['FORUM_NAME'], $this->user->data['user_lang']); $tra_forum_desc = $this->translate_forum($forum_row['FORUM_DESC'], $this->user->data['user_lang']); $forum_row['FORUM_NAME'] = $tra_forum_name; $forum_row['FORUM_DESC'] = $tra_forum_desc; $event['forum_row'] = $forum_row; }
Statistics: Posted by Anișor — Sun Jan 19, 2025 4:24 pm