Copy link to clipboard
Copied
Hello All,
I am new in After Effects and thus need help. I am writing a javascript which reads the text from the Json file and replaces the content under the text frame in the AE Project file. This works fine if the Text is in English. But If I try to replace the Arabic text then the text looses the formation and breaks the words. I tried changing the keyboard language to Arabic. But it still doesn't work.
The value under the javascript variable looks correct.
Can anyone please help.
Thanks all in advance.
Farzana.
Doesn't have to be a new project, just a new text layer created when text engine is set correctly. Maybe you could have one text layer for Arabic, one for not, and maybe they'll then work as expected regardless of the current text engine pref setting, but I haven't tried that yet.
Paul
Copy link to clipboard
Copied
Have you tried changing Preferences > Type > Text Engine to South Asian and Middle Eastern? The last few versions of AE have included native support for right to left languages like Arabic and this is by far the easiest approach to use.
Paul
Copy link to clipboard
Copied
Hi Paul,
Thanks for the quick reply, but I tried and it didn't work. It does work If I try to type the Text directly. But with replacement of Text using through javascript code [layername].sourcetext.setValue(javaScriptvalue) it is not replacing correctly.
Farzana.
Copy link to clipboard
Copied
It's definitely possible to do through a script as my pt_ImportSubtitles script does when that pref is selected. I guess the next thing I'd look at is whether the text is being preserved correctly both inside and during import of the json file. Maybe you should start by just reading it from a basic UTF-8 encoded text file (i.e. not json) and work from there.
Paul
Copy link to clipboard
Copied
The Json file is saved as UTF-8 format file. Otherwise we wouldn't have got correct value after parsing the JSON file. I have attached the snapshot of the Text we are receiving from the Json and after setting source text of the frame.
Not sure where I am loosing the content format.
Thanks,
Farzana.
Copy link to clipboard
Copied
I don't read Arabic so I couldn't tell what's correct or not without a reference of what is verified as looking correct, then what it looks like in AE. The screenshots show that nothing's changed from what you read to what you set in the text layer then read back but that's not unexpected. Does it look the same when the json is viewed in TextEdit?
Paul
Copy link to clipboard
Copied
Yes the Json file is also shows same text. But after import in AE project it shows as the attached image.
Farzana.
Copy link to clipboard
Copied
Was the text layer created after you switched the Text pref? It seems to make a difference.
For example, this will work when the Source Text prop is selected on a text layer created after the pref switch but not on one created before:
var test = "العَرَبِيَّة";
var comp = app.project.item(1);
var prop = comp.selectedProperties[0]
prop.setValue(test);
Copy link to clipboard
Copied
No we did not change anything in the template after changing the settings. I guess you are right we will try to create a new project first change the settings and then create the Frames.
Thanks for all the help. Will let you know if it was successful.
Regards
Farzana.
Copy link to clipboard
Copied
Doesn't have to be a new project, just a new text layer created when text engine is set correctly. Maybe you could have one text layer for Arabic, one for not, and maybe they'll then work as expected regardless of the current text engine pref setting, but I haven't tried that yet.
Paul
Copy link to clipboard
Copied
Hi Paul,
Thank you so much that worked. As you suggested we just recreated the layer frame after changing the setting and it is now flowing the content properly.
Once again thank you for all the help.
Regards
Farzana.