How to change default language Viewer

Stimulsoft Reports.JS discussion
lfcapacio
Posts: 15
Joined: Fri Jun 29, 2012 4:43 pm
Location: Brazil

How to change default language Viewer

Post by lfcapacio »

Hi,
How i can change default language a Viewer Report.JS ?

Thank you
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to change default language Viewer

Post by Alex K. »

Hello,

Use next commands to change language of viewer's GUI.
Add a new language to the Select UI language menu. The file is uploaded to a client when the language is selected.

Code: Select all

Stimulsoft.Base.Localization.StiLocalization.addLocalizationFile("Localizations/pt-BR.xml", false, "Portuguese (Brazil)");
Add a new language to the Select UI language menu and set it as a current language.

Code: Select all

Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("Localizations/es.xml");
Remove all languages from the Select UI language menu, upload it to a client and set it as a current language.

Code: Select all

Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("Localizations/es.xml", true);
All these commands should be used before the viewer is created.

Thank you.
lfcapacio
Posts: 15
Joined: Fri Jun 29, 2012 4:43 pm
Location: Brazil

Re: How to change default language Viewer

Post by lfcapacio »

Hi,

It's work !

Thank you !
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to change default language Viewer

Post by Alex K. »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
jcmmde
Posts: 8
Joined: Fri Mar 17, 2017 9:06 pm

Re: How to change default language Viewer

Post by jcmmde »

Can you help me get the language localization into the create viewer code? For example changing the viewer to Spanish or es.xml?

Code: Select all

function createViewer() {
				
			// Specify necessary options for the viewer
			var options = new Stimulsoft.Viewer.StiViewerOptions();
			options.height = "100%";
			options.appearance.scrollbarsMode = true;
			options.toolbar.showDesignButton = true;
			options.toolbar.printDestination = Stimulsoft.Viewer.StiPrintDestination.Direct;
			options.appearance.htmlRenderMode = Stimulsoft.Report.Export.StiHtmlExportMode.Table;
			options.toolbar.showAboutButton = false;
						
			// Create an instance of the viewer
			viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);
			
			// Add the design button event
			viewer.onDesignReport = function (e) {
				this.visible = false;
				if (designer == null) createDesigner();
				designer.visible = true;
				designer.report = e.report;
			};
			
			viewer.renderHtml("viewerContent");
		}
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to change default language Viewer

Post by HighAley »

Hello.

You could load the localization files like in described in the article from our Help Center.

Thank you.
jcmmde
Posts: 8
Joined: Fri Mar 17, 2017 9:06 pm

Re: How to change default language Viewer

Post by jcmmde »

I tried adding the following line;

Code: Select all

Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("Localizations/es.xml");
at the start of my createViewer function. But then the viewer doesn't load, without this line it works fine, in English. I'm trying to run the web page Client Side only. Could this cause the problem? or perhaps I'm just not understanding how to code it correctly?

Thanks for your help and patience.
jcmmde
Posts: 8
Joined: Fri Mar 17, 2017 9:06 pm

Re: How to change default language Viewer

Post by jcmmde »

Debugging, running the web page locally. The code snippet;

Code: Select all

Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("localizations/es.xml");
Generates an error "Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource."
Which I believe is the browser security not wanting to let one file open up another file locally.

Perhaps there is another way for me to use localization for a client side web page?

Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to change default language Viewer

Post by Alex K. »

Hello,

We couldn't reproduce this bug.
Please send, show us all .html file for analysis.

Also, please try to check the last prerelease build.

Thank you.
jcmmde
Posts: 8
Joined: Fri Mar 17, 2017 9:06 pm

Re: How to change default language Viewer

Post by jcmmde »

I've been migrating my current application over using the download trial, before l purchase. When I test localization with the Demo.html file, I get the Cross Origin request.

Thanks for your help, last thing I need to get figured out.
Attachments
error message
error message
Error_Message.jpg (214.32 KiB) Viewed 9062 times
demo_test.zip
sample html
(5.6 MiB) Downloaded 437 times
Post Reply