YAFLogo

Wyverex
  • Wyverex
  • 53% (Neutral)
  • YAF Forumling Topic Starter
15 years ago
Hi,

I've recently switched my DNN portal to multi-language and users can now change the language by clicking on small flag icons. While this works fine for DNN, naturally YAF does not know about the language that is currently active in DNN and just keeps displaying everything in the default language that can be configured in the admin options.

So how do I tell YAF which language to use at runtime? Is there an easy way for this or do I have to make changes to the DNN module (since I believe that YAF itself has an API for doing this... right?) ? Can someone give me some pointers on how to approach this?

Many thanks,

Wyverex

Sponsor
Wyverex
  • Wyverex
  • 53% (Neutral)
  • YAF Forumling Topic Starter
15 years ago
Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
15 years ago
Can't think of a basic way to do this since it's user configurable. It's an interesting question. Could be added to the YAFWebServices.
Wyverex
  • Wyverex
  • 53% (Neutral)
  • YAF Forumling Topic Starter
15 years ago
Just to let you know, I managed to do this in a quite simple (and dirty) way.

All you have to do is call this code:

			
protected void Page_Load(object sender, EventArgs e)
{
	string langFile = <get the name of the desired language file here>
	YAF.Classes.Utils.YafContext.Current.BoardSettings.Language = langFile;
}

Of course, this requires that users cannot choose the board language themselves but this would be rather pointless anyway if they can choose the whole portal language.

I don't know if this can break anything, but so far I haven't seen any unexpected behavior. And although I'm not using DNN anymore as stated in my initial post, I guess the DNN module can be easily accommodated for this as well.

svenni
  • svenni
  • 60.2% (Friendly)
  • YAF Forumling
15 years ago
Hi,

I would like to get YAF inside of DNN 5.2.3 running, but I have no clue how to do it, the instructions are less than minimal 😢 Any hint?

But I've already managed to get the language-switch running by the use of a new URL-Parameter. It should be easy to determine the DNN-language parameter from the DNN-URL and pass it in here?

Here is the code for the URL-based language-switch:

forum.ascx.cs


		protected void Page_Init( object sender, System.EventArgs e)
		{
		    String strlquery = Request.QueryString["l"];
			if (strlquery != null)
			{
			 // switch board-language with parameter
			 switch (strlquery)
			 {
			 case "en":
			     PageContext.BoardSettings.Language = "english.xml";	
                 // keep in Session
                 Session["forumlanguage"] = "en";				 
			     break;
			 case "de":			
			      PageContext.BoardSettings.Language = "german-du.xml";
                  Session["forumlanguage"] = "de";				 
				  break;			
			 }
			}
			else
			{
			// when there are no parameters, check if session has been set before
			String strSessionLng = (string)Session["forumlanguage"];
			if (strSessionLng != null)
			{
			 switch (strSessionLng)
			 {
			 case "en":
			     PageContext.BoardSettings.Language = "english.xml";	
			     break;
			 case "de":			
			      PageContext.BoardSettings.Language = "german-du.xml";
                  Session["forumlanguage"] = "de";				 
				  break;					     
			 }		
			}
			}
		
		}
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.1 BETA
15 years ago
Why so complicated??

There is an easy solution to change the language based on the Current DNN language.

Here is my Solution (Modification of the Yaf source is not neeeded)..

The DotNetNukeModule.ascx.cs has to be edited

1. In Method OnInit(EventArgs e) i added


 this.Forum1.BoardID = int.Parse(Settings["forumboardid"].ToString());

 [color=green]SetDnnLangToYaf();[/color]

2. Then i added the new Method set will switch the Language based on the DNN Language

private void SetDnnLangToYaf()
        {
            try
            {
                CultureInfo currentCulture = Thread.CurrentThread.CurrentUICulture;

                string sLangCode = currentCulture.TwoLetterISOLanguageName;

                switch (sLangCode)
                {
                    case "de":
                        YafContext.Current.BoardSettings.Language = "german-du.xml";
                        break;
                    case "zh":
                        YafContext.Current.BoardSettings.Language = "china.xml";
                        break;
                    case "cz":
                        YafContext.Current.BoardSettings.Language = "czech.xml";
                        break;
                    case "dk":
                        YafContext.Current.BoardSettings.Language = "danish.xml";
                        break;
                    case "nl":
                        YafContext.Current.BoardSettings.Language = "dutch.xml";
                        break;
                    case "fi":
                        YafContext.Current.BoardSettings.Language = "finnish.xml";
                        break;
                    case "fr":
                        YafContext.Current.BoardSettings.Language = "french.xml";
                        break;
                    case "he":
                        YafContext.Current.BoardSettings.Language = "hebrew.xml";
                        break;
                    case "it":
                        YafContext.Current.BoardSettings.Language = "italian.xml";
                        break;
                    case "lt":
                        YafContext.Current.BoardSettings.Language = "lithuanian.xml";
                        break;
                    case "nr":
                        YafContext.Current.BoardSettings.Language = "norwegian.xml";
                        break;
                    case "fa":
                        YafContext.Current.BoardSettings.Language = "persian.xml";
                        break;
                    case "pl":
                        YafContext.Current.BoardSettings.Language = "polish.xml";
                        break;
                    case "pt":
                        YafContext.Current.BoardSettings.Language = "portugues.xml";
                        break;
                    case "ro":
                        YafContext.Current.BoardSettings.Language = "romanian.xml";
                        break;
                    case "ru":
                        YafContext.Current.BoardSettings.Language = "russian.xml";
                        break;
                    case "sk":
                        YafContext.Current.BoardSettings.Language = "slovak.xml";
                        break;
                    case "es":
                        YafContext.Current.BoardSettings.Language = "spanish.xml";
                        break;
                    case "sv":
                        YafContext.Current.BoardSettings.Language = "swedish.xml";
                        break;
                    case "tr":
                        YafContext.Current.BoardSettings.Language = "turkish.xml";
                        break;
                    case "vi":
                        YafContext.Current.BoardSettings.Language = "vietnam.xml";
                        break;
                    default:
                        YafContext.Current.BoardSettings.Language = "english.xml";
                        break;
                }
            }
            catch (Exception)
            {
                YafContext.Current.BoardSettings.Language = "english.xml";
            }
        }

3. Dont forget to add 2 new usings.


using System.Globalization;
using System.Threading;

Thats all! 😁

If needed i can provide full source or an install package.

http://www.watchersnet.de/Service/Forum.aspx  It can be tested on my Forum.

Note: The Language settings in Yaf will be ignored.

svenni
  • svenni
  • 60.2% (Friendly)
  • YAF Forumling
15 years ago
Hi tha_watcha,

this is indeed more efficient!!! Thanks a lot...

Yes, a running full source + install-package for getting the latest YAF running inside DNN 5.x would be very helpful.

Currently there is no up-to-date documentation and especially no up-to-date "dnn.config"-File (the most complicated part).

I've managed to install the package from YAF-SVN... But as a sample "dnn.config" is missing, I was not able to figure out how to patch "all together".

Thanks a lot in advance!

Sven

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.1 BETA
15 years ago
http://forum.yetanotherforum.net/yaf_postst9794_DNN-5-2-1-and-YAF-1-9-3-Module.aspx 

Did you read this Thread?

The last post contains a sample web.config, but i will make a better dnn5 module package.

svenni
  • svenni
  • 60.2% (Friendly)
  • YAF Forumling
15 years ago
Thanks for the fast reply.

Unfortunately there is a problem with the link...

Anyways, this is for 1.9.3 and the author told me it is not valid any more for 1.9.4...

He told me that for the final release of 1.9.4. there will be again a working dnn-module...

There is currently something in SVN which I was able to install as module in DNN 5.x, but the sample-config-files are missing (most critical part)

Again: Thanks a lot!

Sven

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.1 BETA
15 years ago
Ok i uploaded the COMPLETE Package, it contains all files you need.

- The DNN Module for Installing

- Readme for the manual Steps

- a sample.web.config, provided by balbes in the other Thread - THANKS!

http://www.watchersnet.de/Downloads/tabid/53/rrcid/51/rrscid/54/rreid/382/rrpid/1/rrepp/10/Default.aspx 

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.1 BETA
15 years ago

Ok i uploaded the COMPLETE Package, it contains all files you need.

- The DNN Module for Installing

- Readme for the manual Steps

- a sample.web.config, provided by balbes in the other Thread - THANKS!

http://www.watchersnet.de/Downloads/tabid/53/rrcid/51/rrscid/54/rreid/382/rrpid/1/rrepp/10/Default.aspx 

tha_watcha wrote:

svenni
  • svenni
  • 60.2% (Friendly)
  • YAF Forumling
15 years ago
Cool! I'll give it a try...
svenni
  • svenni
  • 60.2% (Friendly)
  • YAF Forumling
15 years ago

Ok i uploaded the COMPLETE Package, it contains all files you need.

- The DNN Module for Installing

- Readme for the manual Steps

- a sample.web.config, provided by balbes in the other Thread - THANKS!

http://www.watchersnet.de/Downloads/tabid/53/rrcid/51/rrscid/54/rreid/382/rrpid/1/rrepp/10/Default.aspx 

tha_watcha wrote:

tha_watcha wrote:

Thanks again for this great stuff!

As my DNN-Installation is in a subfolder I made the following changes:

- added my subfolder everywhere in YAF-web.config-section where "/Desktopmodules..." was written

(to "/mysubfolder/Desktopmodules..."), (YAF.FileRoot, YAF.AppRoot, YAF.RadEditor...,

- did not change all "~/DesktopModules/"-Entries (this should point to the correct root?)

- copied all files from /Desktopmodules/YetAnotherForumDotNet/App_Code/YAF to

/mysubfolder/App_Code/YAF

This way I was able to run the install-wizard...

But when I'm inserting the module (logged in as "host"), I'll get this error:

------------------------------------

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name 'ForumPages' does not exist in the namespace 'YAF.Classes.Utils' (are you missing an assembly reference?)

Source Error:

Line 36: private string _origHeaderClientID;

Line 37: private string _origFooterClientID;

Line 38: private YAF.Classes.Utils.ForumPages _page;

Line 39: public event EventHandler PageTitleSet;

Line 40:

Source File: c:\inetpub\wwwroot\dnnapp\App_Code\YAF\Forum.cs Line: 38

------------------------------------

Any idea?

Thanks a lot...

Sven

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.1 BETA
15 years ago
Did you run the installer, as i wrote in the readme?

http://yourwebsite.com  /desktopmodules/yaf/install/default.aspx.When you get to the step of defining the Host administrator for YAF, make sure you select an exsisting user. Select the DotNetNuke HOST account.

svenni
  • svenni
  • 60.2% (Friendly)
  • YAF Forumling
15 years ago
Yes, installer was running fine! And I selected "existing user" and entered "host" as user-name.
Users browsing this topic