Of course your foreigner users can call the browser translator to read the forum in their language, but I found pretty to put this option directly in my menu
The code to insert the google translator is this and you can put it everywhere you want
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({ pageLanguage: 'it', layout: google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
I decided to put it near the login menu, so I opened the
/controls/YafHeader.ascx and I inserted a table to integrate the translator code in the same line of other login buttons
.....
<asp:Panel ID="UserContainer" CssClass="menuMyContainer" runat="server">
<table>
<tr style="vertical-align: middle;">
<td style="font-weight: bold;">Translate language:
</td>
<td>
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({ pageLanguage: 'it', layout: google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</td>
<td>
</td>
<td>
<ul class="menuMyList">
<li class="menuMy myProfile">
<asp:HyperLink ID="MyProfile" runat="server" Target="_top"></asp:HyperLink>
</li>
<asp:PlaceHolder ID="MyInboxItem" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="MyBuddiesItem" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="MyAlbumsItem" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="MyTopicItem" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="LogutItem" runat="server" OnPreRender="LogutItem_PreRender" Visible="false">
<li class="menuAccount">
<asp:LinkButton ID="LogOutButton" runat="server" OnClick="LogOutButton_Click" OnClientClick="if(!confirm('Vuoi veramente uscire dal sito?'))return false;else return true;"></asp:LinkButton>
</li>
</asp:PlaceHolder>
</ul>
</td>
<td>
<asp:LinkButton ID="LinkButtonLogout" runat="server" OnPreRender="LinkButtonLogout_PreRender" OnClick="LinkButtonLogout_Click" Style="font-weight: bold; margin-right: 10px;">Logout</asp:LinkButton>
</td>
</tr>
</table>
</asp:Panel>
.....
It's only a little touch... but it makes your site/forum much more professional!
Edited by user
7 years ago
|
Reason: Corrected error in the code