Multi language banner load variables from text question (AS3)

New Here ,
Nov 06, 2021 Nov 06, 2021

Copy link to clipboard

Copied

Hey,

I have a banner example and want to make it multilingual.

I would prefer to load words from 1 external text file (language_txt.txt) for each translation.

I have dynamic text fields with instance names. (Header_001, Slogan_001, Button_001)

With what code do I load the variables from (language_txt.txt) ?
And in which frame do I put that code in the *.fla? (970x250-multi-language-banner.fla)

What code do I put in the *.text (language_txt.txt) files to link the translated words to the dynamic text fields.

 

Goal: An explanation and tuturiol for many creative people who can't program very well 😉

 

----------------------------------------------------------------
this.Header_001 = new cjs.Text("Sun is shining the weather is sweet", "normal 700 44px 'Roboto'", "#FFFFFF");
this.Slogan_001 = new cjs.Text("Make you want to move your dancing feet", "normal 700 28px 'Roboto'");
this.Button_001 = new cjs.Text("CLICK HERE", "normal 700 28px 'Roboto'", "#FFFFFF");
----------------------------------------------------------------

Files: Attachments - Github
970x250-multi-language-banner.fla
970x250-multi-language-banner.html
970x250-multi-language-banner.js
Multi-language-banner-load-variables-from-text-question-as3-adobe-animate
- language_txt.txt

More @ https://github.com/ZZWWBUG/oldskool
More @ https://github.com/ZZWWBUG/oldskool/find/main

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

Language 1 - (language_txt.txt)
Header_001 = Sun is shining the weather is sweet
Slogan_001 = Make you want to move your dancing feet
Button_001 = CLICK HERE

Language 1 - (language_txt.txt)
Header_001 = El sol está brillando, el clima es dulce
Slogan_001 = Te dan ganas de mover tus pies bailando
Button_001 = HAGA CLIC AQUÍ

Language 1 - (language_txt.txt)
Header_001 = Die Sonne scheint, das Wetter ist schön
Slogan_001 = Machen Sie Lust, Ihre tanzenden Füße zu bewegen
Button_001 = KLICKE HIER

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

Views

114

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Nov 07, 2021 Nov 07, 2021
Hi. Here is a sample using a JSON file. JavaScript code: var root = this; var xhttp = new XMLHttpRequest(); var languages = [ "enUS", "ptBR" ]; var language = 1; var json; function main() { xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) loadComplete(xhttp.responseText); }; xhttp.open("GET", "languages.json", true); xhttp.send(); } function loadComplete(data) { json = JSON.parse(data); root.win.Header_001.text = json[languages[language]]...

Likes

Translate

Translate
Adobe Community Professional ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Hi.

 

Here is a sample using a JSON file.

 

JavaScript code:

var root = this;
var xhttp = new XMLHttpRequest();
var languages = [ "enUS", "ptBR" ];
var language = 1;
var json;

function main()
{
	xhttp.onreadystatechange = function()
	{
		if (this.readyState == 4 && this.status == 200)
			loadComplete(xhttp.responseText);
	};

	xhttp.open("GET", "languages.json", true);
	xhttp.send();
}

function loadComplete(data)
{
	json = JSON.parse(data);
	root.win.Header_001.text = json[languages[language]].Header_001;
	root.win.Slogan_001.text = json[languages[language]].Slogan_001;
	root.win.clickHereButton.button.Button_001.text = json[languages[language]].Button_001;
}

main();

 

FLA / code / source download:

https://bit.ly/3CYxndS

 

I hope this helps.

 

Regards,

JC

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

Thank you mister JoãoCésar 🙂

It works realy nice... I also added a Dutch translation and that works fine.

 

970x250-multi-language-banner_dutch.png

If I run into a problem in the further development of this option, I'll post another question here.

Now I'm going to see how this works in an HTML5 banner/presentation with lots of layers and texts.

Greetings From Holland!

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 07, 2021 Nov 07, 2021

Copy link to clipboard

Copied

LATEST

Awesome! You're welcome!

 

Just let us know if you need further assistance and I wish success in your journey.

 

Greetings from Brazil!

 

Regards,

JC

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines