GendrixonEvgeny
2018-01-07T00:29:33Z
Hello. Thank you for this wonderful product! I have a question. Is it possible to change the language for non-registered users? My forum for example is visited from different countries, and the default language is Russian. I would like to make English and Russian on the main page.
Sponsor
tha_watcha
2018-01-07T08:28:33Z
Originally Posted by: GendrixonEvgeny 

Hello. Thank you for this wonderful product! I have a question. Is it possible to change the language for non-registered users? My forum for example is visited from different countries, and the default language is Russian. I would like to make English and Russian on the main page.



At the moment guest users can not change the language, but you could add a simple language selection to the default.aspx

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" Inherits="YAF.ForumPageBase" %>
<%@ Register TagPrefix="YAF" Assembly="YAF" Namespace="YAF" %>
<%@ Register TagPrefix="url" Namespace="Intelligencia.UrlRewriter" Assembly="Intelligencia.UrlRewriter" %>
<script runat="server">

protected void english_OnClick(object sender, EventArgs e)
    {
        YafContext.Current.Get<YafBoardSettings>().Language = "english.xml";
Response.Redirect(Request.RawUrl);
    }

    protected void russian_OnClick(object sender, EventArgs e)
    {
        YafContext.Current.Get<YafBoardSettings>().Language = "russian.xml";
Response.Redirect(Request.RawUrl);
    }
</script>
<!doctype html>
<html lang="en">
<head id="YafHead" runat="server">
     <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge"><meta id="YafMetaScriptingLanguage" http-equiv="Content-Script-Type" runat="server"
        name="scriptlanguage" content="text/javascript" />
    <meta id="YafMetaStyles" http-equiv="Content-Style-Type" runat="server" name="styles"
        content="text/css" />
    <meta id="YafMetaDescription" runat="server" name="description" content="Yet Another Forum.NET -- A bulletin board system written in ASP.NET" />
    <meta id="YafMetaKeywords" runat="server" name="keywords" content="Yet Another Forum.net, Forum, ASP.NET, BB, Bulletin Board, opensource" />
    <title></title>
</head>
<body id="YafBody" runat="server" style="margin: 0; padding: 5px">
    <asp:HyperLink runat="server" id="BannerLink" >
        <img src="~/forumlogo.jpg" runat="server" alt="logo" style="border: 0;" id="imgBanner" />
    </asp:HyperLink>
    <br />

<url:Form id="form1" runat="server" enctype="multipart/form-data">
<asp:PlaceHolder runat="server" Visible='<%# YafContext.Current.IsGuest %>'>
Select Language: <asp:LinkButton runat="server" id="english" OnClick="english_OnClick">
                          <img src="Content/images/flags/us.png" title="Select English"/>
                    </asp:LinkButton> &nbsp;
                    <asp:LinkButton runat="server" id="russian" OnClick="russian_OnClick">
                        <img src="Content/images/flags/ru.png" title="Select Russian"/>
                    </asp:LinkButton>
</asp:PlaceHolder>
    <YAF:Forum runat="server" ID="forum" BoardID="1">
    </YAF:Forum>
    </url:Form>
</body>
</html>



UserPostedImage
GendrixonEvgeny
2018-01-07T11:43:27Z
Thank you! You are the best!)
Only until it is clear where this symbol came from))) http :// prntscr. com/hx68yk
tha_watcha
2018-01-07T12:30:04Z
Originally Posted by: GendrixonEvgeny 

Thank you! You are the best!)
Only until it is clear where this symbol came from))) http :// prntscr. com/hx68yk



Remove the &nbsp:
UserPostedImage
GendrixonEvgeny
2018-01-07T12:37:02Z
Originally Posted by: tha_watcha 

Originally Posted by: GendrixonEvgeny 

Thank you! You are the best!)
Only until it is clear where this symbol came from))) http :// prntscr. com/hx68yk



Remove the &nbsp:



I tried http :// prntscr. com/hx6jlm
tha_watcha
2018-01-07T12:50:49Z
change it to...

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" Inherits="YAF.ForumPageBase" %>
<%@ Register TagPrefix="YAF" Assembly="YAF" Namespace="YAF" %>
<%@ Register TagPrefix="url" Namespace="Intelligencia.UrlRewriter" Assembly="Intelligencia.UrlRewriter" %>
<script runat="server">

protected void english_OnClick(object sender, EventArgs e)
    {
        YafContext.Current.Get<YafBoardSettings>().Language = "english.xml";
Response.Redirect(Request.RawUrl);
    }

    protected void russian_OnClick(object sender, EventArgs e)
    {
        YafContext.Current.Get<YafBoardSettings>().Language = "russian.xml";
Response.Redirect(Request.RawUrl);
    }
</script>
<!doctype html>
<html lang="en">
<head id="YafHead" runat="server">
     <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge"><meta id="YafMetaScriptingLanguage" http-equiv="Content-Script-Type" runat="server"
        name="scriptlanguage" content="text/javascript" />
    <meta id="YafMetaStyles" http-equiv="Content-Style-Type" runat="server" name="styles"
        content="text/css" />
    <meta id="YafMetaDescription" runat="server" name="description" content="Yet Another Forum.NET -- A bulletin board system written in ASP.NET" />
    <meta id="YafMetaKeywords" runat="server" name="keywords" content="Yet Another Forum.net, Forum, ASP.NET, BB, Bulletin Board, opensource" />
    <title></title>
</head>
<body id="YafBody" runat="server" style="margin: 0; padding: 5px">
    <asp:HyperLink runat="server" id="BannerLink" >
        <img src="~/forumlogo.jpg" runat="server" alt="logo" style="border: 0;" id="imgBanner" />
    </asp:HyperLink>
    <br />

<url:Form id="form1" runat="server" enctype="multipart/form-data">
<asp:PlaceHolder runat="server" Visible='<%# YafContext.Current.IsGuest %>'>
Select Language: <asp:LinkButton runat="server" id="english" OnClick="english_OnClick"><img src="Content/images/flags/us.png" title="Select English"/></asp:LinkButton>
                 &nbsp;<asp:LinkButton runat="server" id="russian" OnClick="russian_OnClick"><img src="Content/images/flags/ru.png" title="Select Russian"/></asp:LinkButton>
</asp:PlaceHolder>
    <YAF:Forum runat="server" ID="forum" BoardID="1">
    </YAF:Forum>
    </url:Form>
</body>
</html>

UserPostedImage
GendrixonEvgeny
2018-01-07T13:08:42Z
Originally Posted by: tha_watcha 

change it to...

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" Inherits="YAF.ForumPageBase" %>
<%@ Register TagPrefix="YAF" Assembly="YAF" Namespace="YAF" %>
<%@ Register TagPrefix="url" Namespace="Intelligencia.UrlRewriter" Assembly="Intelligencia.UrlRewriter" %>
<script runat="server">

protected void english_OnClick(object sender, EventArgs e)
    {
        YafContext.Current.Get<YafBoardSettings>().Language = "english.xml";
Response.Redirect(Request.RawUrl);
    }

    protected void russian_OnClick(object sender, EventArgs e)
    {
        YafContext.Current.Get<YafBoardSettings>().Language = "russian.xml";
Response.Redirect(Request.RawUrl);
    }
</script>
<!doctype html>
<html lang="en">
<head id="YafHead" runat="server">
     <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge"><meta id="YafMetaScriptingLanguage" http-equiv="Content-Script-Type" runat="server"
        name="scriptlanguage" content="text/javascript" />
    <meta id="YafMetaStyles" http-equiv="Content-Style-Type" runat="server" name="styles"
        content="text/css" />
    <meta id="YafMetaDescription" runat="server" name="description" content="Yet Another Forum.NET -- A bulletin board system written in ASP.NET" />
    <meta id="YafMetaKeywords" runat="server" name="keywords" content="Yet Another Forum.net, Forum, ASP.NET, BB, Bulletin Board, opensource" />
    <title></title>
</head>
<body id="YafBody" runat="server" style="margin: 0; padding: 5px">
    <asp:HyperLink runat="server" id="BannerLink" >
        <img src="~/forumlogo.jpg" runat="server" alt="logo" style="border: 0;" id="imgBanner" />
    </asp:HyperLink>
    <br />

<url:Form id="form1" runat="server" enctype="multipart/form-data">
<asp:PlaceHolder runat="server" Visible='<%# YafContext.Current.IsGuest %>'>
Select Language: <asp:LinkButton runat="server" id="english" OnClick="english_OnClick"><img src="Content/images/flags/us.png" title="Select English"/></asp:LinkButton>
                 &nbsp;<asp:LinkButton runat="server" id="russian" OnClick="russian_OnClick"><img src="Content/images/flags/ru.png" title="Select Russian"/></asp:LinkButton>
</asp:PlaceHolder>
    <YAF:Forum runat="server" ID="forum" BoardID="1">
    </YAF:Forum>
    </url:Form>
</body>
</html>




Yes it works. Thank you very much!

Update:

<asp:LinkButton runat="server" id="english" OnClick="english_OnClick"><img src="Content/images/flags/us.png" title="Select English"/></asp:LinkButton>
&nbsp;<asp:LinkButton runat="server" id="russian" OnClick="russian_OnClick"><img src="Content/images/flags/ru.png" title="Select Russian"/></asp:LinkButton>

TO

<asp:LinkButton runat="server" id="english" OnClick="english_OnClick"><img src="../Content/images/flags/us.png" title="Select English"/></asp:LinkButton>
&nbsp;<asp:LinkButton runat="server" id="russian" OnClick="russian_OnClick"><img src="../Content/images/flags/ru.png" title="Select Russian"/></asp:LinkButton>

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved