YAFLogo

GendrixonEvgeny
7 years ago
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
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
7 years ago

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.

Originally Posted by: GendrixonEvgeny 

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>

GendrixonEvgeny
7 years ago
Thank you! You are the best!)

Only until it is clear where this symbol came from))) http :// prntscr. com/hx68yk

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
7 years ago

Thank you! You are the best!)

Only until it is clear where this symbol came from))) http :// prntscr. com/hx68yk

Originally Posted by: GendrixonEvgeny 

Remove the  :

GendrixonEvgeny
7 years ago

Thank you! You are the best!)

Only until it is clear where this symbol came from))) http :// prntscr. com/hx68yk

Originally Posted by: tha_watcha 

Remove the  :

Originally Posted by: GendrixonEvgeny 

I tried http :// prntscr. com/hx6jlm

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
7 years ago
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>
GendrixonEvgeny
7 years ago

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>

Originally Posted by: tha_watcha 

Yes it works. Thank you very much!

Update:

 

TO

../Content/images/flags/us.png" title="Select English"/>

 ../Content/images/flags/ru.png" title="Select Russian"/>